File System

A file can be "free formed", indexed or structured collection of related bytes having meaning only to the one who created it. Or in other words an entry in a directory is the file. The file may have attributes like name, creator, date, type, permissions etc.


File Structure

A file has various kinds of structure. Some of them can be :

  • Simple Record Structure with lines of fixed or variable lengths.
  • Complex Structures like formatted document or reloadable load files.
  • No Definite Structure like sequence of words and bytes etc.

Attributes of a File

Following are some of the attributes of a file :

  • Name . It is the only information which is in human-readable form.
  • Identifier. The file is identified by a unique tag(number) within file system.
  • Type. It is needed for systems that support different types of files.
  • Location. Pointer to file location on device.
  • Size. The current size of the file.
  • Protection. This controls and assigns the power of reading, writing, executing.
  • Time, date, and user identification. This is the data for protection, security, and usage monitoring.

File Access Methods

The way that files are accessed and read into memory is determined by Access methods. Usually a single access method is supported by systems while there are OS's that support multiple access methods.

Sequential Access

  • Data is accessed one record right after another is an order.
  • Read command cause a pointer to be moved ahead by one.
  • Write command allocate space for the record and move the pointer to the new End Of File.
  • Such a method is reasonable for tape.

Direct Access

  • This method is useful for disks.
  • The file is viewed as a numbered sequence of blocks or records.
  • There are no restrictions on which blocks are read/written, it can be dobe in any order.
  • User now says "read n" rather than "read next".
  • "n" is a number relative to the beginning of file, not relative to an absolute physical disk location.

Indexed Sequential Access

  • It is built on top of Sequential access.
  • It uses an Index to control the pointer while accessing files.

What is a Directory?

Information about files is maintained by Directories. A directory can contain multiple files. It can even have directories inside of them. In Windows we also call these directories as folders.

Following is the information maintained in a directory :

  • Name : The name visible to user.
  • Type : Type of the directory.
  • Location : Device and location on the device where the file header is located.
  • Size : Number of bytes/words/blocks in the file.
  • Position : Current next-read/next-write pointers.
  • Protection : Access control on read/write/execute/delete.
  • Usage : Time of creation, access, modification etc.
  • Mounting : When the root of one file system is "grafted" into the existing tree of another file system its called Mounting.

Quantitative Aptitude
Reasoning
Programming
Interview