written 2.6 years ago by |
Solution
File operations
File exists to store information and allow it to be retrieved later.
Different system provides different operations to allow storage and retrieval.
The most common system calls are shown below.
Create :
The purpose of the call is to announce that the file is coming and to set some attributes.
Delete:
When the file is no longer needed, it has to be deleted to free up disk space.
Open:
The purpose of the open call is to allow the system to fetch the attributes.
Close:
When all accesses are finished, the attributes and disk addresses are no longer needed, so the file should be closed to free up table space.
Read:
Data are read from file. Usually the bytes come from the current position.
Write:
Data are written to the file, usually at the current position.
Append:
This call is restricted form of write. It can only add data to the end of file.
Seek:
For a random access files, a method is needed to specify from where to take the data. Seek repositions the file pointer to a specific place in the file.
Get attributes:
Processes often need to read the file attributes to do their work.
Set attributes:
Some of the attributes are user settable and can be changed after the file has been created. This system call makes that possible.
Rename:
It frequently happens that a user needs to change the name of an existing file. This system call makes it possible.