Advanced Programming in the UNIX® Environment
ptg10805159 Section 3.6 lseekFunction 67 An open file’s offset can be set explicitly by callinglseek. #include <unistd.h> ...
ptg10805159 68 File I/O Chapter 3 If we invoke this program interactively, we get $./a.out < /etc/passwd seek OK $cat < /e ...
ptg10805159 Section 3.6 lseekFunction 69 if (lseek(fd, 16384, SEEK_SET) == -1) err_sys("lseek error"); /* offset now = 16384 */ ...
ptg10805159 70 File I/O Chapter 3 Name of option Description nameargument _POSIX_V7_ILP32_OFF32 int,long,pointer,andoff_ttypes _ ...
ptg10805159 Section 3.7 readFunction 71 3.7 readFunction Data is read from an open file with thereadfunction. #include <unist ...
ptg10805159 72 File I/O Chapter 3 3.8 writeFunction Data is written to an open file with thewritefunction. #include <unistd.h ...
ptg10805159 Section 3.9 I/O Efficiency 73 •The program doesn’t close the input file or output file. Instead, the program uses th ...
ptg10805159 74 File I/O Chapter 3 We’ll return to this timing example later in the text. In Section 3.14, we show the effect of ...
ptg10805159 Section 3.10 File Sharing 75 v-node also contains the i-node for the file. This information is read from disk when t ...
ptg10805159 76 File I/O Chapter 3 The v-node was invented to provide support for multiple file system types on a single computer ...
ptg10805159 Section 3.11Atomic Operations 77 •After eachwriteis complete, the current file offset in the file table entry is inc ...
ptg10805159 78 File I/O Chapter 3 This works fine for a single process, but problems arise if multiple processes use this techni ...
ptg10805159 Section 3.12 dupanddup2Functions 79 Callingpwriteis equivalent to callinglseekfollowed by a call towrite,with simila ...
ptg10805159 80 File I/O Chapter 3 The new file descriptor that is returned as the value of the functions shares the same file ta ...
ptg10805159 Section 3.13 sync,fsync,andfdatasyncFunctions 81 dup2is an atomic operation, whereas the alternate form involves tw ...
ptg10805159 82 File I/O Chapter 3 3.14 fcntlFunction Thefcntlfunction can change the properties of a file that is already open. ...
ptg10805159 Section 3.14 fcntlFunction 83 Be awarethat some existing programs that deal with the file descriptor flags don’t use ...
ptg10805159 84 File I/O Chapter 3 Example The program in Figure3.11takes a single command-line argument that specifies a file de ...
ptg10805159 Section 3.14 fcntlFunction 85 operation of the program, when invoked frombash(the Bourne-again shell). Results will ...
ptg10805159 86 File I/O Chapter 3 If we add the line set_fl(STDOUT_FILENO, O_SYNC); to the beginning of the program shown in Fig ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf