View Single Post
Old Thursday, March 27, 2008
Janeeta's Avatar
Janeeta Janeeta is offline
Join Date: Dec 2006
Location: Karachi
Posts: 96
Thanks: 26
Thanked 121 Times in 39 Posts
Janeeta is on a distinguished road
Default File management

File management system

What is a file?

A file of a collection of data that normally is stored on a secondary storage device such as a hard disk or floppy diskette.

What are the typical operations performed on files?
An operating system must provide a number of operations associated with files so that users can safely store and retrieve data.

Typical operations are
  • Open
  • Close
  • Create
  • Copy
  • Rename
  • List
In addition, operations on single data elements within a file are supported by
  • Read
  • Write
  • Seek

What are File Control Blocks?

File control blocks (FCB), sometimes referred to as file descriptors, are data structures that hold information about a file. When an operating system needs to access a file, it creates an associated file control block to manage the file.

The structure of the file control block differs between operating systems, but most file control blocks include the following parts
  • Filename
  • Location of file on secondary storage
  • Length of file
  • Date and time or creation or last access

What about how we name files?
Each operating system uses a specific convention or practice for naming files.

MS-DOS Uses eight character file names, a dot, then a three-character extension that denotes the type of file. Filenames are not case-sensitive.

UNIX Filenames can be up to 254 characters long and are case-sensitive.

Windows Filenames can be up to 255 characters long and are not case-sensitive

What are file types?
File types refer to classifying the content of the file, such as a program, text file, executable program or data file.

In Windows operating systems, the file type is derived from the filename extension. Typical file types and their extensions are

File Extension File Type
.bas basic source program
.c c source program
.dll system library
.doc Word document
.exe executable program
.txt text file

Windows associates applications (programs) with specific file types. For example, the default application that opens to process a file of type .txt is the Notepad editor.

How does an operating system keep track of files?
The hard disk is comprised of a large number of sequentially numbered sectors. As files are created, free sectors are allocated to hold the file contents and marked as allocated.

To keep track of the sectors and whether they are allocated or free, and to which file they belong, the operating system maintains a number of tables.

What is a root file system?
When the operating system is first installed, it creates a root file system on the disk that specifies how many sectors are available and how they will be allocated.

The root file system is a table of entries like a directory. In general, this is a fixed size, and once full, no more entries can be added.

Each entry can be either a file or another directory table

What does a root file system entry look like?
This is highly operating system specific, but an entry might look like,
  • Name of file
  • Beginning cluster number
  • Length of file in bytes
  • Type of file
  • Creation date and last modified right
  • File permissions (an access control

What is a cluster?
To make things a little simpler than managing a large number of sectors, the operating system groups sectors together into a minimum allocation unit called a cluster. When a request to create a file occurs, the operating system allocates a cluster at a time until the all the data is stored. This raises a question.

How are all the clusters of a file linked together?
The previous diagram also illustrates the linking of the file clusters in a chain, with the last cluster signifying that there are no more clusters allocated to the file.

One of the problems of using clusters as a minimum storage allocation unit is the wastage of space. Consider a cluster allocate of two sectors, each sector storing 1024 bytes (or characters). This means a minimum storage allocation of 2048 bytes. If you stored a file containing the phrase “Hello”, then this would result in 2043 unused bytes in the cluster (most operating systems store the length of the file, so there is no need to use an end of file marker, which would occupy an additional byte).

You might consider that a smaller allocation size based on the size of a sector would be more efficient. However, it becomes more complex to manage smaller cluster sizes and they take up more space (the table becomes larger and it takes more time to go through all the entries

How is free space managed?
The operating system can maintain a table of cluster entries, and mark each cluster as either free or allocated. This was a technique used in the MS-DOS operating system.

Other operating systems maintain a linked list of free clusters, each free cluster pointing to the next free cluster. As clusters are allocated, they are removed from the free cluster list. When a file is deleted, the clusters that were allocated to it are added back to the free cluster list.

What file systems are supported by Windows operating systems?
The Windows operating system supports the following file systems

The MS-DOS operating system introduced the File Allocation Table system of keeping track of file entries and free clusters. Filenames where restricted to eight characters with an addition three characters signifying the file type. The FAT tables were stored at the beginning of the storage space.

A file allocation table (FAT) is a table that an operating system maintains on a hard disk that provides a map of the clusters (the basic units of logical storage on a hard disk) that a file has been stored in. When you write a new file to a hard disk, the file is stored in one or more clusters that are not necessarily next to each other; they may be rather widely scattered over the disk. A typical cluster size is 2,048 bytes, 4,096 bytes, or 8,192 bytes. The operating system creates a FAT entry for the new file that records where each cluster is located and their sequential order. When you read a file, the operating system reassembles the file from clusters and places it as an entire file where you want to read it. For example, if this is a long Web page, it may very well be stored on more than one cluster on your hard disk.

An updated version of the FAT system designed for Windows 98. It supports file compression and long filenames.

Windows NT introduced the NT File System, designed to be more efficient at handling files than the FAT system. It spreads file tables throughout the disk, beginning at the center of the storage space. It supports file compression and long filenames

What are access-control lists and file permissions?
In multi-user operating systems, files may be accessed by multiple users. Permission rights associated with folders (directories) and files are used to protect or restrict access to files. In UNIX these rights are known as Read, Write and Execute. In Windows NT and Windows 2000 (using the NTFS file-system), additional file permissions are available.

What is a symbolic link or shortcut?
A symbol link is a filename that links to another file. Consider the case on a UNIX box where three different mail packages are available. The administrator only wants to reference the mail using the command “mail”, so the filename is made to point to (or reference) the desired mail package.

When the administrator runs the command “mail”, the appropriate mail package that is referenced by the symbolic link runs.

In Windows, a similar capability is known as a shortcut.

What is file-system integrity?
File-system integrity refers to whether the file-system contains errors. Sometimes this is caused by a user turning off the computer system without first shutting the computer down properly.

During the shutdown process, a flag can be written to the file-system. At startup, this flag can be detected, and if not present, means the computer system was not shut down correctly.

UNIX provides the fsck program to check the file-system. The Windows operating systems provide Scandisk or Chkdsk (checkdisk).

What is fragmentation and what does defragging a drive do?
When files are created and data written to the file, the operating system allocates space for the file from the free cluster list. Over a period of time, the clusters that are allocated to a file may no longer be sequential (contiguous or one after the after) but scattered over the disk.
Reply With Quote
The Following 3 Users Say Thank You to Janeeta For This Useful Post:
kashifilyas (Friday, March 19, 2010), sweety03 (Friday, November 30, 2012), wajid582 (Sunday, February 07, 2010)