Types of Files in OS

Types of Files in the  operating system 

Introduction:

We know that different files store different information. A file may be an executable file, object file, program file, word processing documents, image file, and so on.

The execution of different file types is different.

 For example:

 The execution for an executable file is ''exe" or "com",for text file is 'txt', for document file is 'doc' and so on. 

Web-page

Explanation:

The type of file can also be recognized by magic numbers. Each file stored on the disk is divided into different sections. The first section is headed. It contains information about the file. The start of the header is called the magic number, which indicates the type of files
 (such as an executable file). For example, the string "GIF8" at the beginning of the file identifies that the file contains the image data and the file extension is GIF. The operating systems rarely use the magic number to recognize the file type. However, the magic number is used by some application programs.
Many operating systems support several types of files, but the common file types used by MS-DOS and UNIX are as follows:

Regular Files:

These files contain user information. These files are usually in ASCII format. ASCII files consist of general text. The text files can be created and edited in any text editor such as Notepad of Windows.

Binary Files:

These files contain a sequence of bytes. The executable files are examples of binary files. The extension of executable files is always exe or com. The operating system will only execute a binary file if it has a proper format.

Types of File Objects:

In many operating systems, a file system may refer to an object that is neither files nor directories. Different types of file objects are as follows:

Shortcut: It is also known as a soft link. It is a pointer to another name in a file system. If the file or folder pointed to by the shortcut is deleted then the shortcut is not deleted. However, the operating system cannot access the files or folder.
Device: It represents a hardware device such as a parallel port.
Pipe: It represents a communication channel between two processes. One process sends data into pipes; the other process reads the data from the pipe. Actually, the buffer is used as a pipe of a limited size. Pipes can be named or unnamed. The unnamed pipes can be accessed only by the processes that create them.
Shared Memory: It is an allocation of the memory location for use by one or more processes to share the data.
Semaphore: It is used to control the synchronization of processes. Semaphore and synchronization have already been discussed.

File Operations:

File systems provide the facility to users and applications programs to perform various operations on a file. For this purpose, the operating system provides system calls. The most common operations that can be performed on files are as discussed below.

  • Creating a File:
Creating-a-File


Through this operation, a new empty file is created and an entry for the new file is made in the directory. A system call is used to create a new empty file.

  •  Writing a File:

Through this operation, data is written into a file. A system call is used to write new data into a file. In the system call, both the file name and the data to be written into the file are specified. Usually, data is written in a file at the current write pointer position. If the current position of the pointer is at the end of the file, then the data is written at the end, and the size of the file is increased. If the current position of the pointer is in the middle, then existing data is overwritten and lost forever.

  • Reading a File:

Through this operation, data is read from the file. A system call is used to read data from files. In the system call, the file name and the location of the file are specified where the data from the file is to be read. Usually, the data of any type is read from the current read pointer position. The operating system needs to keep a read pointer to the location in the file where the next read is to take place. The position of the read pointer automatically moves to the next position after reading the data, so that the next data can be read.

  • Appending a file:

This operation is used to add data at the end of a file. A system call is used to append data into the file. When the system call is applied, the file pointer automatically moves to the end of the file, so that data can always be written at the end of the file.

  • Seeking a file:

This operation is used to reposition the read/write pointer from the current position to a specific location in the file. This operation is also known as repositioning within a file. Usually, this operation is used for random access files, to specify where the data in a file is to write or read. This operation does not involve any I/O operation. The actual read or write or update operation is performed after moving the pointer to a specific location. A system call is used for repositioning the pointer in the file.

  • Opening a file:

A file must be opened into the main memory before performing different data operations on it, such as read, write, update, and seek, etc. A system call is used to perform the open file operation.

  • Deleting a file:

This operation is used to delete a file on the disk or other permanent storage devices. When a file is deleted, an entry of that file must be removed from the directory. A system call is used to delete a file. Some operating systems automatically delete old files, to make free space on the disk. Sometimes deleted files are kept in a special folder so that they can be recovered after accidental deletion.

  • Truncating a file:

This operation is used to delete the contents of a file, but the entry of the file in the directory is not deleted. A system call (such as truncate())is used for this purpose.

  • Closing a File:

After using the opened file, it must be closed properly from memory; otherwise, data of the file may be corrupted or lost. A system call is used to perform the close operation on a data file.




Comments

  1. Types Of Files In Os >>>>> Download Now

    >>>>> Download Full

    Types Of Files In Os >>>>> Download LINK

    >>>>> Download Now

    Types Of Files In Os >>>>> Download Full

    >>>>> Download LINK K6

    ReplyDelete

Post a Comment

Popular posts from this blog

Modern scenario of information technology:

Deadlock Questions and Answers pdf

What is the bus interconnection?