Enlist and describe file operations.

Enlist and describe file operations.

Ans.  Files exist to store information and allow it to be retrieved later. Each operating system has system calls to make basic operations on files like creation of file, reading from file, writing to file, etc. following are some basic operations on file –

  1. Creating a File – This operation is used to create a file. It requires two basic steps. First is to find space for file in file system and next is to make entry in the directory for this file. This entry includes name, size, location of file.
  2. Reading From File – The system call that performs read operation requires two attributes – one is file name and other is block, where information is kept after reading.
  3. Writing to File – The system call that performs write operation into file, requires two attributes – one is file name in which data is to be written and other is information that is to be written.
  4. Repositioning within a File – A file is repositioned from one location to new location by just reading file entry in directory and modifying location attribute with new value. This operation does not require actual I/O.
  5. Deleting a File – In this operation, file entry is erased from directory and all the space allocated to file is also released.
  6. Truncating a File – In this operation, only the contents of files are erased and all other attributes of file remain unchanged except file size.
  7. Open a File – Before performing operation on file, a process must open it. The purpose to open a file is a permit the system to read the attributes and list of disk addresses into main memory for rapid access on later calls.
  8. Close a File – To free the internal table space, when all the accesses have finished, the file should be closed.
  9. Append a File – This operation is used to add data to the end of the file. Some systems that provide a minimal set of system call do not generally have append, but some other systems provide multiple ways of doing the same thing, and these systems sometimes have append.
  10. Seek – Seek file operation is used to locate a location where to take the data. One common approach is a system call, is used to seek the file pointer from a specific place in the file.
  11. Rename – Rename operation is used to change the name of existing file.
  12. Set Attributes – Some attributes of files are used to settable and can be change, after the file has been created. This system call makes that possible.
  13. Get Attributes – Get attributes operations are used to return the current value of attributes to caller program or user.

Share this post