Chapter 5, Further File I/0 Details
    -  Look at the picture on page 95.
    
 -  The File Descriptor table contains 
    
         -  A few flags (Close On Exec)
	 
 -  A pointer into the Open File Table.
    
 
     -  The Open File Table contains
    
         -  The current offset
	 
	      -  Note, this is not per process 
	      
 -  Or per file descriptor.
	 
 
	  -  Most of the flags set by open
	 
 -  The file mode
	 
 -  A reference to the i-node table
    
 
     -  The i-node table connects to the real file
    
         -  Includes the file type (regular, directory, fifo, ...)
	 
 -  Any "locks" on the file
	 
 -  Properties, including file size, time stamps, permissions, ...
    
 
     -  Truncate
    
         -  man 2 truncate
	 
 -  Will set the length of a file to a given length.
	 
 -  Note two forms, truncate and ftruncate
    
 
     -  mkstemp
    
         -  Because of race conditions, making temporary files is challenging
	 
	     -  Search the directory for a unused temporary name.
	     
 -  Open the file.
	 
 
	  -  mkstemp solves this problem
	 
 -  int mkstemp(char *template);
	 
	     -  The last 6 characters of the template should be XXXXXX
	     
 -  These will be replaced with a unique random pattern.
	 
 
	  -  The file is opened
	 
	     -  O_EXCL, O_RDONLY, 
	     
 -  READ/Write user, no other permissions
	 
 
	  -  Typically the call is followed by unlink
	 
 -  When the file descriptor is closed, the file will go away.
	 
 -  Look at tmpMaker.C
    
 
     -  There are other topics in this chapter, large files, non-blocking i/o, gather/scatter but we will skip these.