Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4.6. Creating Files

As described earlier, open() apparently opens existing files only. This section describes how brand-new files are created. There are two choices: creat() and open() with additional flags. Initially, creat() was the only way to create a file, but open() was later enhanced with this functionality as well. Both mechanisms require specification of the initial file permissions.

4.6.1. Specifying Initial File Permissions

As a GNU/Linux user, you are familiar with file permissions as printed by ’ls -l’: read, write, and execute for each of user (the file’s owner), group, and other. The various combinations are often expressed in octal, particularly for the chmod and umask commands. For example, file permissions -rw-r--r-- is equivalent to octal 0644 and -rwxr-xr-x is equivalent to octal 0755. (The leading 0 is C’s notation for octal values.)


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint