Permission-Check Algorithms

Here is a quick overview of how permissions interact with the file operations discussed earlier:

  • You must have read permission to open a file for reading with O_RDONLY or O_RDWR.

  • You must have write permission to open a file for writing with O_WRONLY and O_RDWR.

  • You must have write permission to O_TRUNC a file.

  • You must have write and execute permission on a directory to create a new file. You need write permission so you can modify the directory entry, and you need execute permission so the directory can be searched.

  • You must have write and execute permission on a directory to delete a file. You do not actually need read/write permissions on the file itself because the operation just manipulates the directory’s ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.