Coupon Accepted Successfully!


File system

File system provides the mechanism for on-line storage of and access to both data and programs of the operating system and all the users of the computer system. The file system consists of two distinct parts: a collection of files, each storing related data, and a directory structure, which organizes and provides information about all the files in the system.
Computers store information on several different storage media, such as magnetic disks, magnetic tapes, and optical disks. The operating system provides a uniform logical view of information storage by abstracting the physical properties of the storage devices to define a logical storage unit, the file. A file is a named collection of related information that is recorded on secondary storage.
Data cannot be written to secondary storage unless they are within a file. Commonly, files represent programs and data. Data files may be numeric, alphabetic, alphanumeric, or binary. In general, a file is a sequence of bits, bytes, lines, or records whose meaning is defined by the file's creator and user. The information in a file is defined by its creator. Many different types of information may be stored in a file: source programs, object programs, executable programs, numeric data, text, payroll records, graphic images, sound recordings, and so on. A file has a certain defined structure according to its type.

File Attributes

  • Name - Every file has a name which helps users differentiate between files.
  • Identifier - This unique tag (number) identifies the file within the file system.
  •  Location - This information is a pointer to a device and to the location of the file on that device.
  • Size - The current size of the file (in bytes, words or blocks), and possibly the maximum allowed size are included in this attribute.
  • Protection - Access-control information controls, who can do reading, writing, executing, and so on.
  • Time, date, and user identification - This information is kept for creation, last modification, and last use. These data can be useful for protection, security, and usage monitoring.

File Operations

A file is an abstract data type. To define a file properly, we need to consider the operations that can be performed on files. The operating system provides system calls to create, write, read, reposition, delete, and truncate files.
  • Creating a file - To create a file, space in the file system must be found for the file and an entry for the new file must be made in the directory. The directory entry records the name of the file and the location in the file system.
  • Writing a file - To write a file, we make a system call specifying both the name of the file and the information to be written to the file. The system must keep a write pointer to the location in the file where the next write is to take place.
  • Reading a file - To read from a file, we use a system call that specifies the name of the file and where (in memory) the next block of the file should be put.
  • Repositioning within a file - The directory is searched for the appropriate entry, and the current-file-position is set to a given value. This file operation is also known as file seek.
  • Deleting a file - To delete a file, we search the directory for the named file. Having found the associated directory entry, we release all file space and erase the directory entry.
  • Truncating a file - This function allows all attributes to remain unchanged (except for file length) but for the file to be reset to length zero.

File Types

Files have various types; most common are text and binary. Depending on the type of file certain operations are limited to types. Example - a common mistake occurs when a user tries to print the binary-object form of a program. This attempt normally produces garbage, but can be prevented if the operating system has been told that the file is a binary-object program.
A common technique for implementing file types is to include the type as part of the file name. The name is split into two parts — a name and an extension, usually separated by a period character. The system uses the extension to indicate the type of the file and the type of operations that can be done on that file. For instance, only a file with a ".com", ".exe", or ".bat" extension can be executed. Some of the common file types are:
File types Usual extension Function:
  • executable exe, com, bin Run machine language program
  • object obj, o Compiled, machine language, not linked
  • Source code c, cc, java, asm Source code in various languages
  • Batch bat, sh Commands to the command interpreter
  •  text txt, doc Textual data, documents
  • Word processor wp, tex, doc Various word processor formats
  • archive arc, zip, tar, rar Related files group into one file,
  • sometimes after compressing
  • Multimedia mpeg, mov, rm Binary file containg audio or a/v information.

Access Methods

Files store information. When it is used, this information must be accessed and read into computer memory. The information in the file can be accessed in several ways.
Sequential Access - Information in the file is processed in order, one record after the other. A read operation reads the next portion of the file and automatically advances a file pointer, which tracks the I/O location. Similarly, a write appends to the end of the file and advances to the end of the newly written material.
Direct Access – This method is based on disk model and allows random access to any file block. Direct-access files are of great use for immediate access to large amounts of information. Databases are often of this type. When a query concerning a particular subject arrives, we compute which block contains the answer, and then read that block directly to provide the desired information.
Other Methods – The additional methods generally involve the construction of an index for the file. The index, like an index in the back of a book, contains pointers to the various blocks. To find a record in the file, we first search the index, and then use the pointer to access the file directly and to find the desired record.

Test Your Skills Now!
Take a Quiz now
Reviewer Name