Files and Directories Flashcards

1
Q

Secondary Storage Systems include _______ disks, ____, and tapes

A

magnetic, SSDs

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

Storing bits on ______ is different from storing them on flash

A

disk

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

The OS provides a ______ view of storage to users

A

uniform

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

The OS creates file _______ on storage media

A

systems

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

File systems ________ store and retrieve data

A

efficiently

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

File systems enable ______ view of data via files and __________

A

logical, directories

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

A file is a linear array of _____

A

bytes

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

Files persistently record user-defined information on ________

A

storage

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

What is the inode number?

A

The low-level name that internally identifies a file

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

What are example of operation on files?

A
  • Open
  • Close
  • Read
  • Write
  • Reposition
  • Delete
  • Truncate
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

More complex operations on files can be made using ________ operations

A

primitive

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

In the POSIX file interface, what function do you use to create/open a file?

A

open(name, arg)

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

In the POSIX file interface, what does open() return?

A

A file descriptor used for accessing files

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

In the POSIX file interface, what do the arguments O_CREAT, O_WRONLY. and O_TRUNC do in open()?

A

O_CREAT - create new file
O_WRONLY - only write to the file
O_TRUNC - remove any existing content in the file

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

In the POSIX file interface, how do you close a file?

A

close(file descriptor)

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

In the POSIX file interface, how do you rename a file?

A

rename(char *old, char *new)

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

In the POSIX file interface, how do you delete a file?

A

unlink(char *name)

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

In the POSIX file interface, how do you read files?

A

read(file descriptor, buffer pointer, the size of the buffer)

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

In the POSIX file interface, how do you write to files?

A

write(file descriptor, buffer pointer, the size of the buffer)

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

In the POSIX file interface, what does read() return?

A

Number of bytes read

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

In the POSIX file interface, what does write() return?

A

Number of bytes written

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

In the POSIX file interface, you should repeat multiple _______ calls for larger files

A

write()

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

In the POSIX file interface, each open file has a _______ offset

A

current

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

In the POSIX file interface, the current offset determines _____ the next read or write will begin from the file

A

where

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

Current offset is also known as the ____ offset into the file

A

byte

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

In the POSIX file interface, read()/write() advances the current offset by the number of bytes _______/______

A

read/written

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

In the POSIX file interface, we can explicitly update the current offset using ______

A

lseek()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
In the POSIX file interface, for the function 
off_t lseek(int fd, off_t offset, int whence);
what do the 4 parts of the function do?
A

off_t: returns the resulting current offset

fd: file descriptor
offset: target position
whence: how the seek is performed

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

In the POSIX file interface, for the function lseed(). what are the 3 valid whence values and what do they do?

A
  • SEEK_SET: current offset = [offset]
  • SEEK_CUR: current offset += [offset]
  • SEEK_END: current offset = size of the file plus [offset] bytes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Storage and file systems ______ data

A

buffer

31
Q

File system buffer data to improve __________

A

performance

32
Q

In file systems, data written and read are __________ in memory

A

buffered

33
Q

In file systems, data only _______ gets written from buffer to storage. We can ______ written data.

A

periodically, lose

34
Q

The solution to losing data in the buffer is _______

A

fsync(int fd)

35
Q

fsync() forces all ______ data to disk for the referred file

A

dirty

36
Q

What is dirty data?

A

Data not yet written to disk

37
Q

What does stat()/fstat() do?

A

Show the file metadata

38
Q

Metadata refers to ___________ about data

A

information

39
Q

Directories are logical _________ of files/directories

A

groupings

40
Q

Directories also have an _____ number

A

inode

41
Q

Directories list pairs of {user-readable ____, _____ number}

A

name, inode

42
Q

What are some operations of directories?

A
  • search for file
  • create file
  • delete file
  • rename file
  • list directory
  • traverse the file system
43
Q

In the POSIX directory interface, how do you make a directory?

A

mkdir()

44
Q

What 2 entries to empty directories have?

A
  • .(itself)

- ..(parent)

45
Q

In the POSIX directory interface, what does struct_dirent store?

A

Information about the directory

46
Q

In the POSIX directory interface, we use _______ to delete a directory

A

rmdir()

47
Q

When using rmdir(), we have to make sure that the directory is ______

A

empty

48
Q

In the POSIX directory interface, what is the function for linking a new file name to an old one?

A

link(old pathname, new)

49
Q

link() allows us to create another way to ______ to the same file

A

refer

50
Q

In the POSIX directory interface, how is link implemented internally? (2 steps)

A
  1. Create another name in the directory

2. Refer it to the same inode number of the original file

51
Q

In a ____ link, there is no difference between the new and old file

A

hard

52
Q

A _______ _____ tracks how many different names have been linked to an inode

A

reference count

53
Q

When unlink() is called, the reference count _________

A

decrements

54
Q

A file is _____ deleted when the reference count reaches zero

A

truly

55
Q

How can you find the reference count of a file?

A

stat()

56
Q

Symlinks are more _______ than hard links

A

useful

57
Q

Hard links cannot create to a _________ or to a file to another ___________

A

directory, partition

58
Q

Inode numbers are only unique within a file ______

A

system

59
Q

Symlinks are a _______ type the file system knows about

A

third

60
Q

The symlink is a _____ by itself

A

file

61
Q

The symlink holds the ____________ of the linked-to file as the data of the link file

A

pathname

62
Q

In a symlink, a longer pathname makes a bigger ________ file

A

symlink

63
Q

What is a dangling reference?

A

When the original file is removed and the symlink points to an invalid file

64
Q

How do you create a file system?

A

mkfs()

65
Q

mkfs() initializes an ______ file system, starting with a ______ __________ onto a disk partition

A

empty, root directory

66
Q

mkfs() has two inputs: ________ and _____ ______- type

A

device, file system

67
Q

_______ takes an existing directory as a target mount point

A

mount()

68
Q

mount() _____ a new file system onto the directory tree at the mount point. The original files are ________ until ________

A

pastes, invisible, unmounted

69
Q

A mount ______ shows what is mounted on a system

A

program

70
Q

For mounting, ext4 refers to a ______ disk-based file system

A

standard

71
Q

For mounting, ______ is a file system for accessing information about the current processes

A

proc

72
Q

For mounting, ______ is a file system for temporary files

A

tmpfs

73
Q

For mounting, AFS is a _________ file system

A

distributed