Lecture 02 Flashcards

(41 cards)

1
Q

Give some properties of files and directories

A
  • Owner
  • Group
  • Size
  • Permissions (User, Group, Other)
  • Times (Accessed, Modified, Changed (metadata))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What functions are used to access the meta-data of files and directories.

A

stat, fstat, and lstat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is the file/directory metadata returned from the ‘stat’ function?

A

In a C structure called ‘stat’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In a ‘stat’ structure, what is the name of the protection variable?

A

st_mode

This is a mode_t variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which macro function checks if a file is a regular file or not from a mode_t variable?

A

S_ISREG(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which macro function checks if a file is a directory or not from a mode_t variable?

A

S_ISDIR(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which macro function checks if a file is a block special file or not from a mode_t variable?

A

S_ISBLK(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which macro function checks if a file is a character special file or not from a mode_t variable?

A

S_ISCHR(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which macro function checks if a file is First In First Out or not from a mode_t variable?

A

S_ISFIFO(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which macro function checks if a file is a socket or not from a mode_t variable?

A

S_ISSOCK(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which macro function checks if a file is a symbolic link or not from a mode_t variable?

A

S_ISLNK(m)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Do you need read permission on a file to call ‘stat’ on it?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What permissions do you need to open a file?

A

Permissions on the file itself, along with ‘execute’ permission on every directory in the path.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How many bits are used to represent permissions?

A

9.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the three permission groups: User,..,..

A

User, Group, Other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What do Unix systems use to store file and directory metadata?

A

inodes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Do inodes contain filenames and contents?

18
Q

How are inodes addressed?

A

Via an index in the inode table. inode n is the nth inode in the table.

19
Q

Directories map _s to _s

A

names to inode numbers

20
Q

Where is the root directory ‘/’ stored?

A

In some known inode.

21
Q

Can you explicitly make a hard link to a directory?

22
Q

Can you explicitly make a hard link to a file?

23
Q

What are directory entries known as?

24
Q

What are symbolic links stored as instead of an inode?

A

A text string

25
What is a symbolic link?
A special file that points to another file or directory
26
What function is used to open a directory for reading? | What does it return?
opendir. | It returns a DIR*
27
What is the function prototype for opendir?
DIR* opendir(const char *name);
28
What function is used to read from a directory? | What does it return.
readdir. | It returns a struct dirent
29
What is the function prototype for readdir?
struct dirent* readdir(DIR *dir);
30
What two fields will every struct dirent have?
The inode number and the filename.
31
What function gets the current working directory?
getcwd()
32
What function changes the current working directory?
chdir()
33
What directory is used as the root for relative file paths?
The current working directory
34
Which function is used to change the owner of a file?
chown()
35
Which function is used to change the permissions of a file?
chmod()
36
Which function is used to change the group of a file?
chgrp()
37
Which function is used to change the size of a file?
trucate()
38
Which function is used to remove a directory?
rmdir()
39
Which function is used to make a directory?
mkdir()
40
Which function is used to create a link?
link
41
Which function is used to delete a link?
unlink