Question-1 Explain file attributes and file operations in brief
A file is a unit of storing data on a secondary storage device such as a hard disk or other external media.
- Every file has a name and its data. Operating system associates various information with files. For example the date and time of the last modified file and the size of file etc….
- This information is called the file’s attributes or metadata.
- The attributes varies considerably from system to system. Some of the possibilities of attributes are shown below.
These attributes relates to the files attributes and tell who may access it and who may not.
|Protection||Who can access the file and in what way.|
|Password||Password needed to access the file.|
|Creator||ID of the person who created the file.|
Flags are bits or short fields that control or enable some specific property.
|Read only flag||0 for read/write, 1 for read only.|
|Hidden flag||0 for normal, 1 for do not display the listings.|
|System flag||0 for normal, 1 for system file.|
|Archive flag||0 for has been backed up, 1 for needs to be backed up.|
|Random access flag||0 for sequential access only, 1 for random access.|
|Temporary flag||0 for normal, 1 for delete file on process exit.|
|Lock flag||0 for unlocked, 1 for locked.|
The record length, key position and key length are only present in files whose record can be looked up using the key. They provide the information required to find the keys.
|Record length||Number of bytes in a record.|
|Key position||Offset of the key within each record.|
|Key length||Number of bytes in key field.|
The various times keep track of when the file was created, most recently accessed and most recently modified.
|Creation time||Date and time the file was created.|
|Time of last access||Date and time of file was last accessed.|
|time of last change||Date and time of file was last changed.|
The current size tells how big the file is at present. And some old mainframe operating system requires the maximum size to be specified.
|Current size||Number of bytes in the file.|
|Maximum size||Number of bytes the file may grow to.|
- 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.
You may be interested in:
Operating System Short Descriptive Questions and Answers