The Linux Programming Interface
File I/O: The Universal I/O Model 77 (In reality, for an unprivileged process, it is the process’s file-system user ID, rather t ...
78 Chapter 4 EISDIR The specified file is a directory, and the caller attempted to open it for writ- ing. This isn’t allowed. (O ...
File I/O: The Universal I/O Model 79 result, creat() returns a file descriptor that can be used in subsequent system calls. Call ...
80 Chapter 4 doesn’t place a terminating null byte at the end of the string that printf() is being asked to print. A moment’s re ...
File I/O: The Universal I/O Model 81 It is usually good practice to close unneeded file descriptors explicitly, since this makes ...
82 Chapter 4 The offset argument specifies a value in bytes. (The off_t data type is a signed integer type specified by SUSv3.) ...
File I/O: The Universal I/O Model 83 We can’t apply lseek() to all types of files. Applying lseek() to a pipe, FIFO, socket, or ...
84 Chapter 4 Section 14.4 describes how holes are represented in a file, and Section 15.1 describes the stat() system call, whic ...
File I/O: The Universal I/O Model 85 buf = malloc(len); if (buf == NULL) errExit("malloc"); numRead = read(fd, buf, len); if (nu ...
86 Chapter 4 $ ls -l tfile Check size of file -rw-r--r-- 1 mtk users 100003 Feb 10 10:35 tfile $ ./seek_io tfile s10000 R5 Seek ...
File I/O: The Universal I/O Model 87 For each open file, the kernel maintains a file offset, which determines the location at wh ...
...
Chapter 5: File I/O: Further Details In this chapter, we extend the discussion of file I/O that we started in the previous chapt ...
90 Chapter 5 5.1 Atomicity and Race Conditions Atomicity is a concept that we’ll encounter repeatedly when discussing the opera- ...
File I/O: Further Details 91 exist, but by the time of the second open(), some other process had created the file. This could ha ...
92 Chapter 5 If we run two simultaneous instances of the program in Listing 5-1, we see that they both claim to have exclusively ...
File I/O: Further Details 93 The cmd argument can specify a wide range of operations. We examine some of them in the following s ...
94 Chapter 5 Using fcntl() to modify open file status flags is particularly useful in the follow- ing cases: z The file was not ...
File I/O: Further Details 95 z status flags specified when opening the file (i.e., the flags argument to open()); z the file acc ...
96 Chapter 5 In process A, descriptors 1 and 20 both refer to the same open file description (labeled 23). This situation may ar ...
«
2
3
4
5
6
7
8
9
10
11
»
Free download pdf