[prev] 39 [next]

File System Operations (cont)

int mkdir(char *PathName, mode_t Mode)
  • create a new directory called PathName with mode Mode
  • if PathName is e.g. a/b/c/d
    • all of the directories a, b and c must exist
    • directory c must be writeable to the caller
    • directory d must not already exist
  • the new directory contains two initial entries
    • . is a reference to itself
    • .. is a reference to its parent directory
  • returns 0 if successful, returns -1 and sets errno otherwise

Example:  mkdir("newDir", 0755);