Files and Directories Flashcards
Secondary Storage Systems include _______ disks, ____, and tapes
magnetic, SSDs
Storing bits on ______ is different from storing them on flash
disk
The OS provides a ______ view of storage to users
uniform
The OS creates file _______ on storage media
systems
File systems ________ store and retrieve data
efficiently
File systems enable ______ view of data via files and __________
logical, directories
A file is a linear array of _____
bytes
Files persistently record user-defined information on ________
storage
What is the inode number?
The low-level name that internally identifies a file
What are example of operation on files?
- Open
- Close
- Read
- Write
- Reposition
- Delete
- Truncate
More complex operations on files can be made using ________ operations
primitive
In the POSIX file interface, what function do you use to create/open a file?
open(name, arg)
In the POSIX file interface, what does open() return?
A file descriptor used for accessing files
In the POSIX file interface, what do the arguments O_CREAT, O_WRONLY. and O_TRUNC do in open()?
O_CREAT - create new file
O_WRONLY - only write to the file
O_TRUNC - remove any existing content in the file
In the POSIX file interface, how do you close a file?
close(file descriptor)
In the POSIX file interface, how do you rename a file?
rename(char *old, char *new)
In the POSIX file interface, how do you delete a file?
unlink(char *name)
In the POSIX file interface, how do you read files?
read(file descriptor, buffer pointer, the size of the buffer)
In the POSIX file interface, how do you write to files?
write(file descriptor, buffer pointer, the size of the buffer)
In the POSIX file interface, what does read() return?
Number of bytes read
In the POSIX file interface, what does write() return?
Number of bytes written
In the POSIX file interface, you should repeat multiple _______ calls for larger files
write()
In the POSIX file interface, each open file has a _______ offset
current
In the POSIX file interface, the current offset determines _____ the next read or write will begin from the file
where
Current offset is also known as the ____ offset into the file
byte
In the POSIX file interface, read()/write() advances the current offset by the number of bytes _______/______
read/written
In the POSIX file interface, we can explicitly update the current offset using ______
lseek()
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?
off_t: returns the resulting current offset
fd: file descriptor
offset: target position
whence: how the seek is performed
In the POSIX file interface, for the function lseed(). what are the 3 valid whence values and what do they do?
- SEEK_SET: current offset = [offset]
- SEEK_CUR: current offset += [offset]
- SEEK_END: current offset = size of the file plus [offset] bytes
Storage and file systems ______ data
buffer
File system buffer data to improve __________
performance
In file systems, data written and read are __________ in memory
buffered
In file systems, data only _______ gets written from buffer to storage. We can ______ written data.
periodically, lose
The solution to losing data in the buffer is _______
fsync(int fd)
fsync() forces all ______ data to disk for the referred file
dirty
What is dirty data?
Data not yet written to disk
What does stat()/fstat() do?
Show the file metadata
Metadata refers to ___________ about data
information
Directories are logical _________ of files/directories
groupings
Directories also have an _____ number
inode
Directories list pairs of {user-readable ____, _____ number}
name, inode
What are some operations of directories?
- search for file
- create file
- delete file
- rename file
- list directory
- traverse the file system
In the POSIX directory interface, how do you make a directory?
mkdir()
What 2 entries to empty directories have?
- .(itself)
- ..(parent)
In the POSIX directory interface, what does struct_dirent store?
Information about the directory
In the POSIX directory interface, we use _______ to delete a directory
rmdir()
When using rmdir(), we have to make sure that the directory is ______
empty
In the POSIX directory interface, what is the function for linking a new file name to an old one?
link(old pathname, new)
link() allows us to create another way to ______ to the same file
refer
In the POSIX directory interface, how is link implemented internally? (2 steps)
- Create another name in the directory
2. Refer it to the same inode number of the original file
In a ____ link, there is no difference between the new and old file
hard
A _______ _____ tracks how many different names have been linked to an inode
reference count
When unlink() is called, the reference count _________
decrements
A file is _____ deleted when the reference count reaches zero
truly
How can you find the reference count of a file?
stat()
Symlinks are more _______ than hard links
useful
Hard links cannot create to a _________ or to a file to another ___________
directory, partition
Inode numbers are only unique within a file ______
system
Symlinks are a _______ type the file system knows about
third
The symlink is a _____ by itself
file
The symlink holds the ____________ of the linked-to file as the data of the link file
pathname
In a symlink, a longer pathname makes a bigger ________ file
symlink
What is a dangling reference?
When the original file is removed and the symlink points to an invalid file
How do you create a file system?
mkfs()
mkfs() initializes an ______ file system, starting with a ______ __________ onto a disk partition
empty, root directory
mkfs() has two inputs: ________ and _____ ______- type
device, file system
_______ takes an existing directory as a target mount point
mount()
mount() _____ a new file system onto the directory tree at the mount point. The original files are ________ until ________
pastes, invisible, unmounted
A mount ______ shows what is mounted on a system
program
For mounting, ext4 refers to a ______ disk-based file system
standard
For mounting, ______ is a file system for accessing information about the current processes
proc
For mounting, ______ is a file system for temporary files
tmpfs
For mounting, AFS is a _________ file system
distributed