How an Operating System's File System Works

File systems are an integral part of any operatingopen the same file simultaneously and have to decide
systems with the capacity for long term storage.whether users have permission to write a file back to
There are two distinct parts of a file system, thethe disk if other users currently have it open. If two
mechanism for storing files and the directoryusers have read and write permission to file should
structure into which they are organised. In modernone be allowed to overwrite it while the other still
operating systems where it is possible for severalhas it open? Or if one user has read-write permission
user to access the same files simultaneously it hasand another only has read permission on a file should
also become necessary for such features as accessthe user with write permission be allowed to
control and different forms of file protection to beoverwrite it if theres no chance of the other user
implemented.also trying to do so?
A file is a collection of binary data. A file couldDifferent file systems also support different access
represent a program, a document or in some casesmethods. The simplest method of accessing
part of the file system itself. In modern computing itinformation in a file is sequential access. This is where
is quite common for their to be several differentthe information in a file is accessed from the
storage devices attached to the same computer. Abeginning one record at a time. To change the
common data structure such as a file system allowsposition in a file it can be rewound or forwarded a
the computer to access many different storagenumber of records or reset to the beginning of the
devices in the same way, for example, when youfile. This access method is based on file storage
look at the contents of a hard drive or a cd yousystems for tape drive but works as well on
view it through the same interface even though theysequential access devices (like mordern DAT tape
are completely different mediums with data mappeddrives) as it does on random-access ones (like hard
on them in completely different ways. Files can havedrives). Although this method is very simple in its
very different data structures within them but can alloperation and ideally suited for certain tasks such as
be accessed by the same methods built into the fileplaying media it is very inefficient for more complex
system. The arrangement of data within the file istasks such as database management. A more
then decided by the program creating it. The filemodern approach that better facilitates reading tasks
systems also stores a number of attributes for thethat aren't likely to be sequential is direct access.
files within it.direct access allows records to be read or written
All files have a name by which they can be accessedover in any order the application requires. This
by the user. In most modern file systems the namemethod of allowing any part of the file to be read in
consists of of three parts, its unique name, a periodany order is better suited to modern hard drives as
and an extension. For example the file 'bob.jpg' isthey too allow any part of the drive to be read in
uniquely identified by the first word 'bob', theany order with little reduction in transfer rate. Direct
extension jpg indicates that it is a jpeg image file.access is better suited to to most applications than
The file extension allows the operating system tosequential access as it is designed around the most
decide what to do with the file if someone tries tocommon storage medium in use today as opposed
open it. The operating system maintains a list of fileto one that isn't used very much anymore except
extension associations. Should a user try to accessfor large offline back-ups. Given the way direct
'bob.jpg' then it would most likely be opened inaccess works it is also possible to build other access
whatever the systems default image viewer is.methods on top of direct access such as sequential
The system also stores the location of a file. In someaccess or creating an index of all the records of the
file systems files can only be stored as onefile speeding to speed up finding data in a file.
contiguous block. This has simplifies storage andOn top of storing and managing files on a drive the
access to the file as the system then only needs tofile system also maintains a system of directories in
know where the file begins on the disk and howwhich the files are referenced. Modern hard drives
large it is. It does however lead to complications ifstore hundreds of gigabytes. The file system helps
the file is to be extended or removed as there mayorganise this data by dividing it up into directories. A
not be enough space available to fit the largerdirectory can contain files or more directories. Like
version of the file. Most modern file systemsfiles there are several basic operation that a file
overcome this problem by using linked file allocation.system needs to a be able to perform on its
This allows the file to be stored in any number ofdirectory structure to function properly.
segments. The file system then has to store whereIt needs to be able to create a file. This is also
every block of the file is and how large they are.covered by the overview of peration on a file but as
This greatly simplifies file space allocation but iswell as creating the file it needs to be added to the
slower than contiguous allocation as it is possible fordirectory structure.
the file to be spread out all over the disk. ModernWhen a file is deleted the space taken up by the file
operating systems overome this flaw by providing aneeds to be marked as free space. The file itself also
disk defragmenter. This is a utility that rearranges allneeds to be removed from the directory structure.
the files on the disk so that they are all in contiguousFiles may need to be renamed. This requires an
blocks.alteration to the directory structure but the file itself
Information about the files protection is alsoremains un-changed.
integrated into the file system. Protection can rangeList a directory. In order to use the disk properly the
from the simple systems implemented in the FATuser will require to know whats in all the directories
system of early windows where files could bestored on it. On top of this the user needs to be able
marked as read-only or hidden to the more secureto browse through the directories on the hard drive.
systems implemented in NTFS where the file systemSince the first directory structures were designed
administrator can set up separate read and writethey have gone through several large evolutions.
access rights for different users or user groups.Before directory structures were applied to file
Although file protection adds a great deal ofsystems all files were stored on the same level. This
complexity and potential difficulties it is essential in anis basically a system with one directory in which all
enviroment where many different computers or userthe files are kept. The next advancement on this
can have access to the same drives via a networkwhich would be considered the first directory
or time shared system such as raptor.structure is the two level directory. In this There is a
Some file systems also store data about which usersinge list of directories which are all on the same level.
created a file and at what time they created it.The files are then stored in these directories. This
Although this is not essential to the running of the fileallows different users and applications to store there
system it is useful to the users of the system.files separately. After this came the first directory
In order for a file system to function properly theystructures as we know them today, directory trees.
need a number of defined operations for creating,Tree structure directories improves on two level
opening and editing a file. Almost all file systemsdirectories by allowing directories as well as files to
provide the same basic set of methods forbe stored in directories. All modern file systems use
manipulating files.tree structure directories, but many have additional
A file system must be able to create a file. To dofeatures such as security built on top of them.
this there must be enough space left on the drive toProtection can be implemented in many ways. Some
fit the file. There must also be no other file in thefile systems allow you to have password protected
directory it is to be placed with the same name.directories. In this system. The file system wont
Once the file is created the system will make aallow you to access a directory before it is given a
record of all the attributes noted above.username and password for it. Others extend this
Once a file has been created we may need to edit it.system by given different users or groups access
This may be simply appending some data to the endpermissions. The operating system requires the user
of it or removing or replacing data already storedto log in before using the computer and then restrict
within it. When doing this the system keeps a writetheir access to areas they dont have permission for.
pointer marking where the next write operation toThe system used by the computer science
the file should take place.department for storage space and coursework
In order for a file to be useful it must of course besubmission on raptor is a good example of this. In a
readable. To do this all you need to know the namefile system like NTFS all type of storage space,
and path of the file. From this the file system cannetwork access and use of device such as printers
ascertain where on the drive the file is stored. Whilecan be controlled in this way. Other types of access
reading a file the system keeps a read pointer. Thiscontrol can also be implemented outside of the file
stores which part of the drive is to be read next.system. For example applications such as win zip
In some cases it is not possible to simply read all ofallow you to password protect files.
the file into memory. File systems also allow you toThere are many different file systems currently
reposition the read pointer within a file. To performavailable to us on many different platforms and
this operation the system needs to know how fardepending on the type of application and size of
into the file you want the read pointer to jump. Andrive different situations suit different file system. If
example of where this would be useful is a databaseyou were to design a file system for a tape backup
system. When a query is made on the database it issystem then a sequential access method would be
obviously inefficient to read the whole file up to thebetter suited than a direct access method given the
point where the required data is, instead theconstraints of the hardware. Also if you had a small
application managing the database would determinehard drive on a home computer then there would be
where in the file the required bit of data is and jumpno real advantage of using a more complex file
to it. This operation is often known as a file seek.system with features such as protection as it isn't
File systems also allow you to delete files. To do thislikely to be needed. If i were to design a file system
it needs to know the name and path of the file. Tofor a 10 gigabyte drive i would use linked allocation
delete a file the systems simply removes its entryover contiguous to make the most efficient use the
from the directory structure and adds all the space itdrive space and limit the time needed to maintain the
previously occupied to the free space list (ordrive. I would also design a direct access method
whatever other free space management system itover a sequential access one to make the most use
uses).of the strengths of the hardware. The directory
These are the most basic operations required by astructure would be tree based to allow better
file system to function properly. They are present inorganisation of information on the drive and would
all modern computer file systems but the way theyallow for acyclic directories to make it easier for
function may vary. For example, to perform theseveral users to work on the same project. It would
delete file operation in a modern file system likealso have a file protection system that allowed for
NTFS that has file protection built into it would bedifferent access rights for different groups of users
more complicated than the same operation in anand password protection on directories and individual
older file system like FAT. Both systems would firstfiles.Several file systems that already implement the
check to see whether the file was in use beforefeatures I've described above as ideal for a 10gig
continuing, NTFS would then have to check whetherhard drive are currently available, these include NTFS
the user currently deleting the file has permission tofor the Windows NT and XP operating systems and
do so. Some file systems also allow multiple people toext2 which is used in linux.