The File System Interface
Explore the UNIX file system interface by learning how to create, access, and delete files using system calls like open and unlink. Understand how file descriptors function as process-specific handles that allow reading and writing operations. This lesson clarifies file system basics and demystifies core UNIX file management concepts.
We'll cover the following...
Let’s now discuss the file system interface in more detail. We’ll start with the basics of creating, accessing, and deleting files. You may think this is straightforward, but along the way we’ll discover the mysterious call that is used to remove files, known as unlink(). Hopefully, by the end of this chapter, this mystery won’t be so mysterious to you!
Creating files
We’ll start with the most basic of operations: creating a file. This can be accomplished with the open system call; by calling open() and passing it the O_CREAT flag, a program can create a new file. Here is some example code to create a file called “foo” in the current working directory:
ASIDE: THE
creat()SYSTEM CALL ...