What are the types of system calls used in file management?

Operating SystemHardwareSoftware & Coding

The System calls for File management are as follows −

A file is open using a system call open. The mode in which the file is supposed to be open is specified using the parameter.

Parameters also consist of the names of the file to open or a new one to be created. The files are closed using the close systems.

Associated with each file is a pointer that indicates the current position in the file. When reading or writing sequentially, points to the next byte to be read or written.

The Lseek call changes the value of the position pointer so that subsequent calls to read or write can begin anywhere in the file.

Lseek has three parameters which are as follows −

  • File descriptor for the file

  • File position

  • File position is relative to the beginning of the file, the current position, or the end of the file.


The systems calls for file management include the following −

  • open − for opening the file for reading, writing.

  • close − to close the opened file.

  • read − for reading the data from the file into the buffer.

  • write − for writing the data from the buffer into file.

Now let us see about each system call in detail. We know a file is used to store a large volume of data. A file is treated as a single entity.

The main functions are as follows −

Create a file

Whenever you want to work on a file, the very first step is to create a file. A file is a space in memory where data is stored.

You can follow the steps to create a file −

  • Right click anywhere in the folder where you want to create a file.

  • Select new file.

  • Name the file and a file will be created.

Open a file

After creating a file, you can work on it whenever you want to and open it from the memory of the file system by accessing the path of the file.

For example − cd ./user/file1 -------file1 being the name of the file that you created. Also you can double click on the file to open it wherever you have created it.

Close a file

You can close a file by clicking on the close button in the toolbar of a file.

Delete a file

Delete a file by following these steps −

  • Right click on the file.

  • Click on delete.

  • Click yes/confirm on the confirmation block.

Updated on 29-Nov-2021 10:51:18