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