Lecture 02 Flashcards
(41 cards)
Give some properties of files and directories
- Owner
- Group
- Size
- Permissions (User, Group, Other)
- Times (Accessed, Modified, Changed (metadata))
What functions are used to access the meta-data of files and directories.
stat, fstat, and lstat
How is the file/directory metadata returned from the ‘stat’ function?
In a C structure called ‘stat’
In a ‘stat’ structure, what is the name of the protection variable?
st_mode
This is a mode_t variable.
Which macro function checks if a file is a regular file or not from a mode_t variable?
S_ISREG(m)
Which macro function checks if a file is a directory or not from a mode_t variable?
S_ISDIR(m)
Which macro function checks if a file is a block special file or not from a mode_t variable?
S_ISBLK(m)
Which macro function checks if a file is a character special file or not from a mode_t variable?
S_ISCHR(m)
Which macro function checks if a file is First In First Out or not from a mode_t variable?
S_ISFIFO(m)
Which macro function checks if a file is a socket or not from a mode_t variable?
S_ISSOCK(m)
Which macro function checks if a file is a symbolic link or not from a mode_t variable?
S_ISLNK(m)
Do you need read permission on a file to call ‘stat’ on it?
No
What permissions do you need to open a file?
Permissions on the file itself, along with ‘execute’ permission on every directory in the path.
How many bits are used to represent permissions?
9.
What are the three permission groups: User,..,..
User, Group, Other
What do Unix systems use to store file and directory metadata?
inodes
Do inodes contain filenames and contents?
No
How are inodes addressed?
Via an index in the inode table. inode n is the nth inode in the table.
Directories map _s to _s
names to inode numbers
Where is the root directory ‘/’ stored?
In some known inode.
Can you explicitly make a hard link to a directory?
No
Can you explicitly make a hard link to a file?
Yes
What are directory entries known as?
Hard Links
What are symbolic links stored as instead of an inode?
A text string