Date post: | 08-Apr-2018 |
Category: |
Documents |
Upload: | dcrustamit |
View: | 218 times |
Download: | 0 times |
of 43
8/7/2019 Project Reprt virtual file system
1/43
PROJECT REPORT
ON
SIX WEEKS SUMMER TRAINING
AT
ALCATEL-LUCENT INDIA LIMITED.
GURGAON (HRY)
PREPARED BY:-PREPARED BY:-
PRADEEP KUMAR
ROLL NO : 9057
COMPUTER SCIENCE AND ENGINEERING
DRONACHARYA COLLEGE OF ENGINEERING
1
8/7/2019 Project Reprt virtual file system
2/43
PROJECT REPORT
ON
VIRTUAL FILE SYSTEM
SUBMITTED IN THE FULFILLMENT
FOR THE DEGREE
OF
B.E. IN COMPUTER SCIENCE AND ENGINEERING
TO
DRONACHARYA COLLEGE OF ENGINEERING
FOR THE SESSION
2008-2009
Submitted By:-
Name: PRADEEP KUMAR
Roll No: 9057
Branch: CSE-I(5th semester)
2
8/7/2019 Project Reprt virtual file system
3/43
Table of Contents
TABLE OF CONTENTS ..........................................................................................3
ACKNOWLEDGEMENT ......................................................................................... 4
ABOUT ALCATEL-LUCENT ................................................................................... 5
ALCATEL-LUCENT HISTORY .............................................................................................................7ALCATEL ...................................................................................................................................7MANAGEMENT COMMITTEE ...............................................................................................................9THE BUSINESSES .........................................................................................................................9
TECHNOLOGY USED .......................................................................................... 10
INTRODUCTION ................................................................................................ 11
FAT32 FILE SYSTEM SPECIFICATION ................................................................ 12
GENERAL OVERVIEW ...................................................................................................................12BOOT SECTORAND BPB .............................................................................................................13BOOT SECTORAND BPB STRUCTURE ...............................................................................................14FAT32 STRUCTURE STARTINGAT OFFSET 36 ....................................................................................17
FAT DATA STRUCTURE ..............................................................................................................19ROOTDIRSECTORS = ((BPB_ROOTENTCNT * 32) + (BPB_BYTSPERSEC 1)) / BPB_BYTSPERSEC; .............20FIRSTSECTOROFCLUSTER = ((N 2) * BPB_SECPERCLUS) + FIRSTDATASECTOR; .......................................20FAT TYPE DETERMINATION ...........................................................................................................20ROOTDIRSECTORS = ((BPB_ROOTENTCNT * 32) + (BPB_BYTSPERSEC 1)) / BPB_BYTSPERSEC; .............20IF(BPB_FATSZ16 != 0) .........................................................................................................21
FATSZ = BPB_FATSZ16; ...................................................................................................21ELSE .....................................................................................................................................21
FATSZ = BPB_FATSZ32; .................................................................................................21IF(BPB_TOTSEC16 != 0) .........................................................................................................21
TOTSEC = BPB_TOTSEC16; ..................................................................................................21ELSE .....................................................................................................................................21
TOTSEC = BPB_TOTSEC32; ..................................................................................................21
DATASEC = TOTSEC (BPB_RESVDSECCNT + (BPB_NUMFATS * FATSZ) + ROOTDIRSECTORS); ...............21COUNTOFCLUSTERS = DATASEC / BPB_SECPERCLUS; .........................................................................21IF(COUNTOFCLUSTERS < 4085) { ................................................................................................22/* VOLUMEIS FAT12 */ ............................................................................................................22} ELSEIF(COUNTOFCLUSTERS < 65525) { .....................................................................................22
/* VOLUMEIS FAT16 */ ........................................................................................................22} ELSE { ................................................................................................................................22
/* VOLUMEIS FAT32 */ ........................................................................................................22} .........................................................................................................................................22FAT32 FSINFO SECTOR STRUCTUREAND BACKUP BOOT SECTOR .............................................................22FAT DIRECTORY STRUCTURE .........................................................................................................24FAT 32 BYTE DIRECTORY ENTRY STRUCTURE .....................................................................................25. .............................................................................................................................28
.. .............................................................................................................................28DATEAND TIME FORMATS .............................................................................................................29NAME LIMITSAND CHARACTER SETS .................................................................................................29LIMITATIONOFFAT 32 .................................................................................................................30
VIRTUAL FILE SYSTEM ...................................................................................... 32
INTRODUCTION ..................................................................................................................32INITIALIZATION OF VIRTUAL FILE SYSTEM ...........................................................................32WORKING OF THE VIRTUAL FILE SYSTEM ............................................................................33
3
8/7/2019 Project Reprt virtual file system
4/43
FORMATTING A DRIVE .....................................................................................................33
WRITING ROOT DIRECTORY:- ..........................................................................................33
CREATING A DIRECTORY:- ...............................................................................................34
CHANGING CURRENT DIRECTORY:- ................................................................................37
READ LIST:- ....................................................................................................................37
COPYING A FILE AND READING A FILE:- ...........................................................................37
SNAPSHOT /OUTPUT SCREEN ............................................................................ 39
ACKNOWLEDGEMENT
I express gratitude and am thankful to all the people at Alcatel-Lucent India Limited
who helped me make my training a success. I have no doubt now that my choice of training
was right and the exposure and experience gained at Alcatel-Lucent has been unique .I feel
I have been part of the Alcatel-Lucent family if only for a short time and shared the work
culture which teaches strict self discipline and a goal oriented approach. I owe my success to
many people who guided me in time of need and shared with me their valuable time so that I
could develop. They guided me throughout my training period and constantly involved the
trainees in stimulating discussions and invoked our suggestions on important aspects such
as company service, company growth etc. and also allotted me very useful and productive
project on VIRTUAL FILE SYSTEM.
4
8/7/2019 Project Reprt virtual file system
5/43
ABOUT ALCATEL-LUCENT
Alcatel-Lucents vision is to enrich peoples lives by transforming the world communicates. Alcatel-Lucent provides solutions that enable service providers,
enterprises and governments worldwide, to deliver voice, data and
communication services to end-users. As a leader in fixed, mobile and converged
broadband access, carrier and enterprise IP technologies, applications, and services,
Alcatel-Lucent offers the end-to-end solutions that enable compelling communications
services for people at home, at work and on the move.
With 77,000 employees and operations in more than 130 countries, Alcatel-Lucent is a
local partner with global reach. The company has the most experienced global services
team in the industry, and Bell Labs, one of the largest research, technology and
innovation organizations focused on communications. Alcatel-Lucent achieved adjusted
revenues of Euro 17.8 billion in 2007, and is incorporated in France, with executive
offices located in Paris.
Organization
With a strong focus on complete solutions maximizing value for customers, Alcatel-Lucent is organized around three business groups and two geographic regions. The
Carrier Business Group serves fixed, wireless and convergent service providers - as
well as enterprises and governments for their business critical communications. The
Enterprise Business Group focuses on meeting the needs of business customers. The
Services Business Group designs, deploys, manages and maintains ne
5
8/7/2019 Project Reprt virtual file system
6/43
worldwide. The company's geographic regions are the Americas and Asia-Pacific,
Europe, Middle East, and Africa.
Innovation & Technology
Alcatel-Lucent today is one of the largest innovation powerhouses
communications industry, representing an R&D investment of Euro 2.7 billion, and a
portfolio of more than 25,000 active patents spanning virtually every technology area. At
the core of this innovation is Alcatel-Lucents Bell Labs, which brings together LucentTechnologies' Bell Labs and Alcatels Research & Innovation organizations, providing
Alcatel-Lucent with an innovation engine comprising researchers and scientists at the
forefront of research into areas such as multimedia and convergent services and
applications, new service delivery architectures and platforms, wireless and wireline,
broadband access, packet and optical networking and transport, network security,
enterprise networking and communication services and fundamental research in areas
such as nanotechnology, algorithmic, and computer sciences.
History
Formed from the merger of Alcatel and Lucent Technologies, Alcatel-Lucent combines
two entities that share a common lineage that can be traced back to 1986, when
Alcatels parent company, CGE (la Compagnie Gnrale dElectricit), acquired ITTs
European telecom business. Nearly 60 years earlier, ITT had purchased most of
AT&Ts manufacturing operations outside the United States. AT&T was Lucents former
parent company.By creating Alcatel-Lucent we are bringing our common lineages back together and
starting an exciting new chapter of our history -- creating the worlds first truly global
communications solutions provider, with the most complete end-to-end portfolio of
solutions and services in the industry.
6
8/7/2019 Project Reprt virtual file system
7/43
Alcatel-Lucent History
The combination of Alcatel and Lucent creates the worlds pre-eminent communications
solutions company. Alcatel-Lucent is a truly global enterprise that transcends national
borders, with an extensive, well-balanced global presence in terms of both resources
and revenues, a comprehensive portfolio of industry-leading products and services and
one of the largest and most innovative R&D capabilities.
Alcatel
Alcatels origins date back to 1898 when French engineer Pierre Azaria set up La
Compagnie Gnrale d'Electricit (CGE). CGE was a French-based ind
conglomerate involved in various activities such as electricity, transportation, electronics
and telecommunications.
The French powerhouse CGE would be a leader not only in digital communications but
would also be known for producing the high speed trains in France the TGV (train
grande vitesse).
CGE strengthened its leadership in digital communications in the mid 1980s when it
bought the telecommunications part of ITT Corporation and changed the groups nameto Alcatel Alsthom. In addition, in 1983, Alcatel, having a vision of the huge potential of
the Asia Pacific market was one of the first foreign companies to establish itself in
China, where it would later base its Asia-Pacific Headquarters.
In 1995 Serge Tchuruk was appointed Chairman and CEO of Alcatel and he refocused
the group solely on the telecommunications industry, spinning off the Alsthom activities
and changing the groups name to Alcatel. In the late 1990s, Alcatel made significant
acquisitions in North America such as DSC in 1998. In 2000, Alcatel also acquired
Newbridge, world leader in ATM technologies and Genesys, the world leader in contact
center technology.
In 2002 Alcatel took control of its flagship subsidiary Alcatel Shanghai Bell (ASB), with
the Chinese government owning the rest of this enterprise. This structure allowed
Alcatel to uniquely position itself in a Chinese market experiencing rapid growth.
7
8/7/2019 Project Reprt virtual file system
8/43
In 2006, facing an industry where operators were consolidating and ever-intense
competition, Alcatel announced plans to merge with Lucent Technologies. At the same
time Alcatel also announced a deal to increase its shareholding and transfer its satellite
subsidiaries, its railway signaling business and its critical security systems domains to
Thales, a key player in the French defense industry. In addition Alcatel also announced
its intention to acquire Nortel's UMTS radio access business to strengthen its leadership
position in this technology. These deals formed part of a long-term strategy to ensure
Alcatel Lucent would be the pacesetter of the ever-evolving communications market.
Lucent Technologies
Lucent Technologies was spun off by AT&T on Sept. 30, 1996, but its history dates
back to 1869 when Elisha Gray and Enos N. Barton formed a small manufacturing firm
based in Cleveland. Three years later the firm, which by then was located in Chicago,
was renamed the Western Electric Manufacturing Company.
By 1880, it was the largest electrical manufacturing company in the United States, noted
for its production of a variety of electrical equipment, including the world's first
commercial typewriters, telegraph equipment and Thomas A. Edison's electric pen. In
1881, American Bell, founded by Alexander Graham Bell, purchased a controlling
interest in Western Electric and made it the exclusive developer and manufacturer ofequipment for the Bell telephone companies.
In 1925, Bell Telephone Laboratories was created from the consolidation of the Western
Electric Research Laboratories, formed in 1907, and part of the En
Department of AT&T. Bell Labs would go on to generate some of the most significant
scientific and technological discoveries of the 20th century, including the transistor, the
laser, the solar cell battery, the digital signal processor chip and the cellular concept of
mobile telephone service. Bell Labs researchers also would garner 11 Nobel Prizes.
Also in 1925, Western Electric sold its International Western Electric Company
subsidiary to ITT.
Effective January 1, 1984, AT&T agreed to divest its local Bell telephone companies.
As part of this divestiture, a new unit, AT&T Technologies, assumed Western Electric's
8
8/7/2019 Project Reprt virtual file system
9/43
charter. In 1989, AT&T Technologies included several business units that later would
combine with Bell Labs to become Lucent Technologies.
AT&T launched Lucent in April 1996 with an initial public offering. The spinoff was
completed in September 1996 when AT&T distributed its shares of Lucent to AT&T
shareowners
Management Committee
Patricia Russo, Chief Executive Officer
Cindy Christy, head of the Americas
Etienne Fouques, who oversees Research, CTO, Strategy, Corporate Marketing
Andy Williams, head of Services business
Claire Pedini, head of Corporate Human Resources and Communications
Hubert de Pesquidoux, CFO and head of the Enterprise business
Michel Rahier, who leads the Carrier Business Group
Frederic Rose, head of Asia Pacific, Europe, Middle East and Africa.
The Businesses
Alcatel-Lucent has three Business Groups: Carrier, Enterprise and Services.
The Carrier Business Group is led by Michel Rahier and serves wireline, mobile
and cable service providers.
The Services Business Group is the telecom industry's most experienced and
knowledgeable services partner, supporting the top 30 service providers -- as
well as enterprises and governments -- in more than 130 countries. Led by Andy
Williams, it provides a comprehensive set of professional services that
encompass the entire network lifecycle.
The Enterprise Business Group, under the leadership of Hubert de Pesquidoux, is
leading the competitive transformation of our enterprise and government customers by
delivering secure, end-to-end, business-critical communications solutions that enable new
business generation. The business has two divisions: Enterprise Solutions and Genesys.
9
http://www.alcatel-lucent.com/wps/portal/!ut/p/kcxml/04_Sj9SPykssy0xPLMnMz0vM0Y_QjzKLd4w38vAGSYGZrqb6kShiBvGOCBFfj_zcVP0gfW_9AP2C3NCIckdHRQCIDusE/delta/base64xml/L3dJdyEvd0ZNQUFzQUMvNElVRS82X0FfNEoyhttp://www.alcatel-lucent.com/wps/portal/!ut/p/kcxml/04_Sj9SPykssy0xPLMnMz0vM0Y_QjzKLd4w38vAGSYGZrqb6kShiBvGOCBFfj_zcVP0gfW_9AP2C3NCIckdHRQCIDusE/delta/base64xml/L3dJdyEvd0ZNQUFzQUMvNElVRS82X0FfNEoy8/7/2019 Project Reprt virtual file system
10/43
Tom Burns leads the Enterprise Solutions Division and Paul Segre, the Genesys Division.
TECHNOLOGY USED
LANGUAGE USED
The language used in development of the VIRTUAL FILE SYSTEM is C.
COMPILER USED
Compiler used is the VISUAL BASIC C++ 6.0 IDE (INTEGRATED DEVELOPMENT
EDITOR).
10
8/7/2019 Project Reprt virtual file system
11/43
INTRODUCTION
The FAT (File Allocation Table) file system has its origins in the late 1970s and early
1980s and was the file system supported by the Microsoft MS-DOS operating
system. It was originally developed as a simple file system suitable for floppy disk drives
less than 500K in size. Over time it has been enhanced to support larger media.
Currently there are three FAT file systems FAT12, FAT16, FAT32. The VIRTUAL FILE
SYSTEM is a simple file system designed on the basis of FAT32 file system. It works on
a volume of desired size, in which root folder is stored at a fixed location so that the files
needed to start the system can be correctly located. A volume formatted with virtual file
system is allocated in clusters. The default number of clusters is determined by the size
of the volume.
11
8/7/2019 Project Reprt virtual file system
12/43
FAT32 File System Specification
General Overview
The FAT (File Allocation Table) file system has its origins in the late 1970s and
early1980s and was the file system supported by the Microsoft MS-DOS operating
system. It was originally developed as a simple file system suitable for floppy disk drives
less than 500K in size. Over time it has been enhanced to support larger and largermedia. Currently there are three FAT file system types: FAT12, FAT16 and FAT32. The
basic difference in these FAT sub types, and the reason for the names, is the size, in
bits, of the entries in the actual FAT structure on the disk. There are 12 bits in a FAT12
FAT entry, 16 bits in a FAT16 FAT entry and 32 bits in a FAT32 FAT entry.
12
8/7/2019 Project Reprt virtual file system
13/43
A FAT file system volume is composed of four basic regions, which are laid out in this
order on the volume:
0 Reserved Region
1 FAT Region
2 Root Directory Region (doesnt exist on FAT32 volumes)
3 File and Directory Data Region
The figure below illustrates how the FAT file system organizes a volume.
Boot Sector and BPB
The first important data structure on a FAT volume is called the BPB (BIOS Parameter
Block), which is located in the first sector of the volume in the Reserved Region. This
sector is sometimes called the boot sector or the reserved sector or the 0th sector,
but the important fact is simply that it is the first sector of the volume.
This is the first thing about the FAT file system that sometimes causes confusion. In
MS-DOS version 1.x, there was not a BPB in the boot sector. In this first version of the
FAT file system, there were only two different formats, the one for single-sided and the
one for double-sided 360K 5.25-inch floppy disks. The determination of which type was
on the disk was done by looking at the first byte of the FAT (the low 8 bits of FAT[0]).
This type of media determination was superseded in MS-DOS version 2.x by putting a
BPB in the boot sector, and the old style of media determination (done by looking at the
first byte of the FAT) was no longer supported. All FAT volumes must have a BPB in the
boot sector.
13
8/7/2019 Project Reprt virtual file system
14/43
This brings us to the second point of confusion relating to FAT volume determination:
What exactly does a BPB look like? The BPB in the boot sector defined for MS-DOS 2.x
only allowed for a FAT volume with strictly less than 65,536 sectors (32 MB worth of
512-byte sectors). This limitation was due to the fact that the total sectors field was
only a 16-bit field. This limitation was addressed by MS-DOS 3.x, where the BPB was
modified to include a new 32-bit field for the total sectors value.
The next BPB change occurred with the Microsoft Windows 95 operating system,
specifically OEM Service Release 2 (OSR2), where the FAT32 type was introduced.
FAT16 was limited by the maximum size of the FAT and the maximum valid cluster size
to no more than a 2 GB volume if the disk had 512-byte sectors. FAT32 addressed this
limitation on the amount of disk space that one FAT volume could occupy so that disks
larger than 2 GB only had to have one partition defined.
The FAT32 BPB exactly matches the FAT12/FAT16 BPB up to and including the
BPB_TotSec32 field. They differ starting at offset 36, depending on whether the media
type is FAT12/FAT16 or FAT32 (see discussion below for determining FAT type). The
relevant point here is that the BPB in the boot sector of a FAT volume should always be
one that has all of the new BPB fields for either the FAT12/FAT16 or FAT32 BPB type.
Doing it this way ensures the maximum compatibility of the FAT volume and ensures
that all FAT file system drivers will understand and support the volume properly,
because it always contains all of the currently defined fields.
Boot Sector and BPB Structure
Name Offset
(byte)
Size
(bytes)
Description
14
8/7/2019 Project Reprt virtual file system
15/43
BS_jmpBoot 0 3 Jump instruction to boot code. This field has two allowed forms:jmpBoot[0] = 0xEB, jmpBoot[1] = 0x??, jmpBoot[2] = 0x90andjmpBoot[0] = 0xE9, jmpBoot[1] = 0x??, jmpBoot[2] = 0x??
0x?? indicates that any 8-bit value is allowed in that byte. Whatthis forms is a three-byte Intel x86 unconditional branch (jump)instruction that jumps to the start of the operating systembootstrap code. This code typically occupies the rest of sector 0of the volume following the BPB and possibly other sectors.Either of these forms is acceptable. JmpBoot[0] = 0xEB is themore frequently used format.
BS_OEMName
3 8 MSWIN4.1 There are many misconceptions about this field. Itis only a name string. Microsoft operating systems dont payany attention to this field. Some FAT drivers do. This is thereason that the indicated string, MSWIN4.1, is therecommended setting, because it is the setting least likely tocause compatibility problems. If you want to put something elsein here, that is your option, but the result may be that someFAT drivers might not recognize the volume. Typically this is
some indication of what system formatted the volume.BPB_BytsPerSec
11 2 Count of bytes per sector. This value may take on only thefollowing values: 512, 1024, 2048 or 4096. If maximumcompatibility with old implementations is desired, only the value512 should be used. There is a lot of FAT code in the world thatis basically hard wired to 512 bytes per sector and doesntbother to check this field to make sure it is 512. Microsoftoperating systems will properly support 1024, 2048, and 4096.
Note: Do not misinterpret these statements about maximumcompatibility. If the media being recorded has a physical sectorsize N, you must use N and this must still be less than or equalto 4096. Maximum compatibility is achieved by only using
media with specific sector sizes.BPB_SecPerClus
13 1 Number of sectors per allocation unit. This value must be apower of 2 that is greater than 0. The legal values are 1, 2, 4, 8,16, 32, 64, and 128. Note however, that a value should neverbe used that results in a bytes per cluster value(BPB_BytsPerSec * BPB_SecPerClus) greater than 32K (32 *1024). There is a misconception that values greater than thisare OK. Values that cause a cluster size greater than 32Kbytes do not work properly; do not try to define one. Someversions of some systems allow 64K bytes per cluster value.Many application setup programs will not work correctly onsuch a FAT volume.
BPB_RsvdSec
Cnt
14 2 Number of reserved sectors in the Reserved region of the
volume starting at the first sector of the volume. This field mustnot be 0. For FAT12 and FAT16 volumes, this value shouldnever be anything other than 1. For FAT32 volumes, this valueis typically 32. There is a lot of FAT code in the world hardwired to 1 reserved sector for FAT12 and FAT16 volumes andthat doesnt bother to check this field to make sure it is 1.Microsoft operating systems will properly support any non-zerovalue in this field.
15
8/7/2019 Project Reprt virtual file system
16/43
BPB_NumFATs
16 1 The count of FAT data structures on the volume. This fieldshould always contain the value 2 for any FAT volume of anytype. Although any value greater than or equal to 1 is perfectlyvalid, many software programs and a few operating systemsFAT file system drivers may not function properly if the value issomething other than 2. All Microsoft file system drivers willsupport a value other than 2, but it is still highly recommendedthat no value other than 2 be used in this field.
The reason the standard value for this field is 2 is to provideredundancy for the FAT data structure so that if a sector goesbad in one of the FATs, that data is not lost because it isduplicated in the other FAT. On non-disk-based media, such asFLASH memory cards, where such redundancy is a uselessfeature, a value of 1 may be used to save the space that asecond copy of the FAT uses, but some FAT file system driversmight not recognize such a volume properly.
BPB_RootEntCnt
17 2 For FAT12 and FAT16 volumes, this field contains the count of32-byte directory entries in the root directory. For FAT32volumes, this field must be set to 0. For FAT12 and FAT16
volumes, this value should always specify a count that whenmultiplied by 32 results in an even multiple ofBPB_BytsPerSec. For maximum compatibility, FAT16 volumesshould use the value 512.
BPB_TotSec16
19 2 This field is the old 16-bit total count of sectors on the volume.This count includes the count of all sectors in all four regions ofthe volume. This field can be 0; if it is 0, then BPB_TotSec32must be non-zero. For FAT32 volumes, this field must be 0. ForFAT12 and FAT16 volumes, this field contains the sector count,and BPB_TotSec32 is 0 if the total sector count fits (is lessthan 0x10000).
BPB_Media 21 1 0xF8 is the standard value for fixed (non-removable) media.For removable media, 0xF0 is frequently used. The legal
values for this field are 0xF0, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC,0xFD, 0xFE, and 0xFF. The only other important point is thatwhatever value is put in here must also be put in the low byte ofthe FAT[0] entry. This dates back to the old MS-DOS 1.x mediadetermination noted earlier and is no longer usually used foranything.
BPB_FATSz16
22 2 This field is the FAT12/FAT16 16-bit count of sectors occupiedby ONE FAT. On FAT32 volumes this field must be 0, andBPB_FATSz32 contains the FAT size count.
BPB_SecPerTrk
24 2 Sectors per track for interrupt 0x13. This field is only relevantfor media that have a geometry (volume is broken down intotracks by multiple heads and cylinders) and are visible oninterrupt 0x13. This field contains the sectors per track
geometry value.BPB_NumHeads
26 2 Number of heads for interrupt 0x13. This field is relevant asdiscussed earlier for BPB_SecPerTrk. This field contains theone based count of heads. For example, on a 1.44 MB 3.5-inch floppy drive this value is 2.
BPB_HiddSec 28 4 Count of hidden sectors preceding the partition that containsthis FAT volume. This field is generally only relevant for mediavisible on interrupt 0x13. This field should always be zero onmedia that are not partitioned. Exactly what value isappropriate is operating system specific.
16
8/7/2019 Project Reprt virtual file system
17/43
BPB_TotSec32
32 4 This field is the new 32-bit total count of sectors on the volume.This count includes the count of all sectors in all four regions ofthe volume. This field can be 0; if it is 0, then BPB_TotSec16must be non-zero. For FAT32 volumes, this field must be non-zero. For FAT12/FAT16 volumes, this field contains the sectorcount if BPB_TotSec16 is 0 (count is greater than or equal to0x10000).
Here is the structure for FAT32 starting at offset 36 of the boot sector.
FAT32 Structure Starting at Offset 36
Name Offset(byte)
Size(bytes)
Description
BPB_FATSz32 36 4 This field is only defined for FAT32 media and does not exist onFAT12 and FAT16 media. This field is the FAT32 32-bit count ofsectors occupied by ONE FAT. BPB_FATSz16 must be 0.
BPB_ExtFlags 40 2 This field is only defined for FAT32 media and does not exist onFAT12 and FAT16 media.Bits 0-3 -- Zero-based number of active FAT. Only valid if
mirroring is disabled.Bits 4-6 -- Reserved.
Bit 7 -- 0 means the FAT is mirrored at runtime into all FATs.-- 1 means only one FAT is active; it is the one referenced
in bits 0-3.Bits 8-15 -- Reserved.
17
8/7/2019 Project Reprt virtual file system
18/43
BPB_FSVer 42 2 This field is only defined for FAT32 media and does not existon FAT12 and FAT16 media. High byte is major revisionnumber. Low byte is minor revision number. This is the versionnumber of the FAT32 volume. This supports the ability toextend the FAT32 media type in the future without worryingabout old FAT32 drivers mounting the volume. This documentdefines the version to 0:0. If this field is non-zero, back-levelWindows versions will not mount the volume.NOTE: Disk utilities should respect this field and not operateon volumes with a higher major or minor version number thanthat for which they were designed. FAT32 file system driversmust check this field and not mount the volume if it does notcontain a version number that was defined at the time thedriver was written.
BPB_RootClus 44 4 This field is only defined for FAT32 media and does not existon FAT12 and FAT16 media. This is set to the cluster numberof the first cluster of the root directory, usually 2 but notrequired to be 2.NOTE: Disk utilities that change the location of the rootdirectory should make every effort to place the first cluster of
the root directory in the first non-bad cluster on the drive (i.e., incluster 2, unless its marked bad). This is specified so that diskrepair utilities can easily find the root directory if this fieldaccidentally gets zeroed.
BPB_FSInfo 48 2 This field is only defined for FAT32 media and does not exist onFAT12 and FAT16 media. Sector number of FSINFO structure inthe reserved area of the FAT32 volume. Usually 1.NOTE: There will be a copy of the FSINFO structure inBackupBoot, but only the copy pointed to by this field will be keptup to date (i.e., both the primary and backup boot record will pointto the same FSINFO sector).
BPB_BkBootSec
50 2 This field is only defined for FAT32 media and does not existon FAT12 and FAT16 media. If non-zero, indicates the sector
number in the reserved area of the volume of a copy of theboot record. Usually 6. No value other than 6 is recommended.
BPB_Reserved 52 12 This field is only defined for FAT32 media and does not existon FAT12 and FAT16 media. Reserved for future expansion.Code that formats FAT32 volumes should always set all of thebytes of this field to 0.
BS_DrvNum 64 1 This field has the same definition as it does for FAT12 andFAT16 media. The only difference for FAT32 media is that thefield is at a different offset in the boot sector.
BS_Reserved1 65 1 This field has the same definition as it does for FAT12 andFAT16 media. The only difference for FAT32 media is that thefield is at a different offset in the boot sector.
BS_BootSig 66 1 This field has the same definition as it does for FAT12 and
FAT16 media. The only difference for FAT32 media is that thefield is at a different offset in the boot sector.BS_VolID 67 4 This field has the same definition as it does for FAT12 and
FAT16 media. The only difference for FAT32 media is that thefield is at a different offset in the boot sector.
BS_VolLab 71 11 This field has the same definition as it does for FAT12 andFAT16 media. The only difference for FAT32 media is that thefield is at a different offset in the boot sector.
18
8/7/2019 Project Reprt virtual file system
19/43
BS_FilSysType 82 8 Always set to the string FAT32 . Please see the note for thisfield in the FAT12/FAT16 section earlier. This field has nothingto do with FAT type determination.
FAT Data Structure
The next data structure that is important is the FAT itself. What this data structure doesis define a singly linked list of the extents (clusters) of a file. Note at this point that aFAT directory or file container is nothing but a regular file that has a special attributeindicating it is a directory. The only other special thing about a directory is that the dataor contents of the file is a series of 32=byte FAT directory entries (see discussion
below). In all other respects, a directory is just like a file. The FAT maps the data regionof the volume by cluster number. The first data cluster is cluster 2.
The first sector of cluster 2 (the data region of the disk) is computed using the BPBfields for the volume as follows. First, we determine the count of sectors occupied by theroot directory:
19
8/7/2019 Project Reprt virtual file system
20/43
RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec BPB_BytsPerSec;
Note that on a FAT32 volume the BPB_RootEntCnt value is always 0, so on a FAT32volume RootDirSectors is always 0. The 32 in the above is the size of one FAT directory
entry in bytes. Note also that this computation rounds up.
Given any valid data cluster numberN, the sector number of the first sector of thatcluster (again relative to sector 0 of the FAT volume) is computed as follows:
FirstSectorofCluster = ((N 2) * BPB_SecPerClus) + FirstDataSector;
FAT Type Determination
The FAT typeone of FAT12, FAT16, or FAT32is determined by the count of clusters
on the volume and nothingelse.
Please read everything in this section carefully, all of the words are important. For
example, note that the statement was count of clusters. This is not the same thing as
maximum valid cluster number, because the first data cluster is 2 and not 0 or 1.
To begin, lets discuss exactly how the count of clusters value is determined. This is all
done using the BPB fields for the volume. First, we determine the count of sectorsoccupied by the root directory as noted earlier.
RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec
BPB_BytsPerSec;
Note that on a FAT32 volume, the BPB_RootEntCnt value is always 0; so on a FAT32
volume, RootDirSectors is always 0.
20
8/7/2019 Project Reprt virtual file system
21/43
Next, we determine the count of sectors in the data region of the volume:
If(BPB_FATSz16 != 0)
FATSz = BPB_FATSz16;
Else
FATSz = BPB_FATSz32;
If(BPB_TotSec16 != 0)
TotSec = BPB_TotSec16;
Else
TotSec = BPB_TotSec32;
DataSec = TotSec (BPB_ResvdSecCnt + (BPB_NumFATs * FATS
RootDirSectors);
Now we determine the count of clusters:
CountofClusters = DataSec / BPB_SecPerClus;
Please note that this computation rounds down.
Now we can determine the FAT type. Please note carefully or you will commit an off-by-
one error!
In the following example, when it says
8/7/2019 Project Reprt virtual file system
22/43
If(CountofClusters < 4085) {
/* Volume is FAT12 */
} else if(CountofClusters < 65525) {
/* Volume is FAT16 */
} else {
/* Volume is FAT32 */
}
This is the one and only way that FAT type is determined. There is no such thing as a
FAT12 volume that has more than 4084 clusters. There is no such thing as a FAT16
volume that has less than 4085 clusters or more than 65,524 clusters. There is no such
thing as a FAT32 volume that has less than 65,525 clusters. If you try to make a FAT
volume that violates this rule, Microsoft operating systems will not handle them correctly
because they will think the volume has a different type of FAT than what you think it
does.
FAT32 FSInfo Sector Structure and Backup Boot Sector
On a FAT32 volume, the FAT can be a large data structure, unlike on FAT16 where it is
limited to a maximum of 128K worth of sectors and FAT12 where it is limited to amaximum of 6K worth of sectors. For this reason, a provision is made to store the last
known free cluster count on the FAT32 volume so that it does not have to be computed
as soon as an API call is made to ask how much free space there is on the volume (like
at the end of a directory listing). The FSInfo sector number is the value in the
BPB_FSInfo field; for Microsoft operating systems it is always set to 1. Here is the
structure of the FSInfo sector:
Name Offset(byte)
Size(bytes)
Description
22
8/7/2019 Project Reprt virtual file system
23/43
FSI_LeadSig 0 4 Value 0x41615252. This lead signature is used tovalidate that this is in fact an FSInfo sector.
FSI_Reserved1
4 480 This field is currently reserved for future expansion.FAT32 format code should always initialize allbytes of this field to 0. Bytes in this field must
currently never be used.FSI_StrucSig
484 4 Value 0x61417272. Another signature that is morelocalized in the sector to the location of the fieldsthat are used.
FSI_Free_Count
488 4 Contains the last known free cluster count on thevolume. If the value is 0xFFFFFFFF, then the freecount is unknown and must be computed. Anyother value can be used, but is not necessarilycorrect. It should be range checked at least tomake sure it is
8/7/2019 Project Reprt virtual file system
24/43
reduces the severity of this problem for FAT32 volumes, because starting at that sector
number on the volume6there is a backup copy of the boot sector information
including the volumes BPB.
In the case where the sector 0 information has been accidentally overwritten, all a disk
repair utility has to do is restore the boot sector(s) from the backup copy. In the case
where sector 0 goes bad, this allows the volume to be mounted so that the user can
access data before replacing the disk.
This second casesector 0 goes badis the reason why no value other than 6 should
ever be placed in the BPB_BkBootSec field. If sector 0 is unreadable, various operating
systems are hard wired to check for backup boot sector(s) starting at sector 6 of the
FAT32 volume. Note that starting at the BPB_BkBootSec sector is a complete boot
record. The Microsoft FAT32 boot sector is actually three 512-byte sectors long. There
is a copy of all three of these sectors starting at the BPB_BkBootSec sector. A copy of
the FSInfo sector is also there, even though the BPB_FSInfo field in this backup boot
sector is set to the same value as is stored in the sector 0 BPB.
FAT Directory Structure
A FAT directory is nothing but a file composed of a linear list of 32-byte structures. The
only special directory, which must always be present, is the root directory. For FAT12
and FAT16 media, the root directory is located in a fixed location on the disk
immediately following the last FAT and is of a fixed size in sectors computed from the
BPB_RootEntCnt value.
For FAT32, the root directory can be of variable size and is a cluster chain, just like any
other directory is. The first cluster of the root directory on a FAT32 volume is stored inBPB_RootClus. Unlike other directories, the root directory itself on any FAT type does
not have any date or time stamps, does not have a file name (other than the implied file
name \), and does not contain . and .. files as the first two directory entries in the
directory. The only other special aspect of the root directory is that it is the only directory
24
8/7/2019 Project Reprt virtual file system
25/43
on the FAT volume for which it is valid to have a file that
ATTR_VOLUME_ID attribute bit set (see below).
FAT 32 Byte Directory Entry StructureName Offset
(byte)Size(bytes)
Description
DIR_Name 0 11 Short name.DIR_Attr 11 1 File attributes:
ATTR_READ_ONLY 0x01ATTR_HIDDEN 0x02ATTR_SYSTEM 0x04ATTR_VOLUME_ID 0x08ATTR_DIRECTORY 0x10ATTR_ARCHIVE 0x20
ATTR_LONG_NAME ATTR_READ_ONLY |ATTR_HIDDEN |ATTR_SYSTEM |ATTR_VOLUME_ID
The upper two bits of the attribute byte are reserved andshould always be set to 0 when a file is created and nevermodified or looked at after that.
DIR_NTRes 12 1 Reserved for use by Windows NT. Set value to 0 when a fileis created and never modify or look at it after that.
DIR_CrtTimeTenth 13 1 Millisecond stamp at file creation time. This field actuallycontains a count of tenths of a second. The granularity ofthe seconds part of DIR_CrtTime is 2 seconds so this fieldis a count of tenths of a second and its valid value range is
0-199 inclusive.
DIR_FstClusHI 20 2 High word of this entrys first cluster number (always 0 for aFAT12 or FAT16 volume).
DIR_WrtTime 22 2 Time of last write. Note that file creation is considered awrite.
DIR_WrtDate 24 2 Date of last write. Note that file creation is considered awrite.
DIR_FstClusLO 26 2 Low word of this entrys first cluster number.DIR_FileSize 28 4 32-bit DWORD holding this files size in bytes.
25
DIR_CrtTime 14 2 Time file was created.DIR_CrtDate 16 2 Date file was created.DIR_LstAccDate 18 2 Last access date. Note that there is no last access time,
only a date. This is the date of last read or write. In the caseof a write, this should be set to the same datDIR_WrtDate.
8/7/2019 Project Reprt virtual file system
26/43
DIR_Name[0]Special notes about the first byte (DIR_Name[0]) of a FAT directory entry:
If DIR_Name[0] == 0xE5, then the directory entry is free (there is no file or directory
name in this entry).
If DIR_Name[0] == 0x00, then the directory entry is free (same as for 0xE5), and
there are no allocated directory entries after this one (all of the DIR_Name[0] bytes in
all of the entries after this one are also set to 0).
The special 0 value, rather than the 0xE5 value, indicates to FAT file system driver
code that the rest of the entries in this directory do not need to be examined because
they are all free.
If DIR_Name[0] == 0x05, then the actual file name character for this byte is 0xE5.
0xE5 is actually a valid KANJI lead byte value for the character set used in Japan.
The special 0x05 value is used so that this special file name case for Japan can be
handled properly and not cause FAT file system code to think that the entry is free.
The DIR_Name field is actually broken into two parts+ the 8-character main part of the
name, and the 3-character extension. These two parts are trailing space padded with
bytes of 0x20.
DIR_Name[0] may not equal 0x20. There is an implied . character between the main
part of the name and the extension part of the name that is not present in DIR_Name.
Here are some examples of how a user-entered name maps into DIR_Name:
foo.bar -> FOO BAR
FOO.BAR -> FOO BAR
Foo.Bar -> FOO BAR
foo -> FOO
PICKLE. -> PICKLE A
prettybg.bi -> PRETTYBGBIG
26
8/7/2019 Project Reprt virtual file system
27/43
.big -> illegal, DIR_Name[0] cannot be 0x20
In FAT directories all names are unique. Look at the first three examples earlier. Those
different names all refer to the same file, and there can only be one file with DIR_Name
set to FOO BAR in any directory.
DIR_Attr specifies attributes of the file:
ATTR_READ_ONLY Indicates that writes to the file should fail.
ATTR_HIDDEN Indicates that normal directory listings should not show this
file.
ATTR_SYSTEM Indicates that this is an operating system file.
ATTR_VOLUME_ID There should only be one file on the volume that has this
attribute set, and that file must be in the root directory. This
name of this file is actually the label for the
DIR_FstClusHI and DIR_FstClusLO must always be 0 for the
volume label (no data clusters are allocated to the volume
label file).
ATTR_DIRECTORY Indicates that this file is actually a container for other files.
ATTR_ARCHIVE This attribute supports backup utilities. This bit is set by the
FAT file system driver when a file is created, renamed, or
written to. Backup utilities may use this attribute to indicate
which files on the volume have been modified since the last
time that a backup was performed.
Note that the ATTR_LONG_NAME attribute bit combination indicates that the file is
actually part of the long name entry for some other file. See the next section for more
information on this attribute combination.
When a directory is created, a file with the ATTR_DIRECTORY bit set in its DIR_Attr
field, you set its DIR_FileSize to 0. DIR_FileSize is not used and is always 0 on a file
27
8/7/2019 Project Reprt virtual file system
28/43
with the ATTR_DIRECTORY attribute (directories are sized by simply following their
cluster chains to the EOC mark). One cluster is allocated to the directory (unless it is the
root directory on a FAT16/FAT12 volume), and you set DIR_FstClusL
DIR_FstClusHI to that cluster number and place an EOC mark in that clusters entry in
the FAT. Next, you initialize all bytes of that cluster to 0. If the directory is the root
directory, you are done (there are no dot ordotdotentries in the root directory). If the
directory is not the root directory, you need to create two special entries in the first two
32-byte directory entries of the directory (the first two 32 byte entries in the data region
of the cluster you just allocated).
The first directory entry has DIR_Name set to:
.
The second has DIR_Name set to:
..
These are called the dotand dotdotentries. The DIR_FileSize field on both entries is
set to 0, and all of the date and time fields in both of these entries are set to the same
values as they were in the directory entry for the directory that you just created. You
now set DIR_FstClusLO and DIR_FstClusHI for the dotentry (the first entry) to the
same values you put in those fields for the directories directory entry (the cluster
number of the cluster that contains the dotand dotdotentries).
Finally, you set DIR_FstClusLO and DIR_FstClusHI for the dotdotentry (the second
entry) to the first cluster number of the directory in which you just created the directory
(value is 0 if this directory is the root directory even for FAT32 volumes).
Here is the summary for the dotand dotdotentries:
The dotentry is a directory that points to itself.
The dotdotentry points to the starting cluster of the parent of this directory (which is
0 if this directories parent is the root directory).
28
8/7/2019 Project Reprt virtual file system
29/43
Date and Time Formats
Many FAT file systems do not support Date/Time other than DIR_WrtTime and
DIR_WrtDate. For this reason, DIR_CrtTimeMil, DIR_CrtTime, DIR_CrtDate, a
DIR_LstAccDate are actually optional fields. DIR_WrtTime and DIR_WrtDate mustbe
supported, however. If the other date and time fields are not supported, they should be
set to 0 on file create and ignored on other file operations.
Date Format. A FAT directory entry date stamp is a 16-bit field that is basically a date
relative to the MS-DOS epoch of 01/01/1980. Here is the format (bit 0 is the LSB of the
16-bit word, bit 15 is the MSB of the 16-bit word):
Bits 04: Day of month, valid value range 1-31 inclusive.
Bits 58: Month of year, 1 = January, valid value range 112 inclusive.
Bits 915: Count of years from 1980, valid value range 0127 inclusive (1980
2107).
Time Format. A FAT directory entry time stamp is a 16-bit field that has a granularity of2 seconds. Here is the format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of
the 16-bit word).
Bits 04: 2-second count, valid value range 029 inclusive (0 58 seconds).
Bits 510: Minutes, valid value range 059 inclusive.
Bits 1115: Hours, valid value range 023 inclusive.
The valid time range is from Midnight 00:00:00 to 23:59:58.
Name Limits and Character Sets
29
8/7/2019 Project Reprt virtual file system
30/43
Short names are limited to 8 characters followed by an optional period (.) and extension
of up to 3 characters. The total path length of a short name cannot exceed 80
characters (64 char path + 3 drive letter + 12 for 8.3 name + NUL) including the trailing
NUL. The characters may be any combination of letters, digits, or characters with code
point values greater than 127. The following special characters are also allowed:
$ % ' - _ @ ~ ` ! ( ) { } ^ # &
Names are stored in a short directory entry in the OEM code page that the system is
configured for at the time the directory entry is created. Short directory entries remain in
OEM for compatibility with previous versions of MS-DOS/Windows. OEM characters
are single 8-bit characters or can be DBCS character pairs for certain code pages.
Short names passed to the file system are always converted to upper case and their
original case value is lost. One problem that is generally true of most OEM code pages
is that they map lower to upper case extended characters in a non-unique fashion. That
is, they map multiple extended characters to a single upper case character. This
creates problems because it does not preserve the information that the extended
character provides. This mapping also prevents the creation of some file names that
would normally differ, but because of the mapping to upper case they become the same
file name.
Limitation of fat 32
The following limitations exist using the FAT32 file system with Windows operating
systems:
Clusters cannot be 64 kilobytes (KB) or larger. If clusters were 64 KB or larger,
some programs (such as Setup programs) might calculate disk space incorrectly.
A volume must contain at least 65,527 clusters to use the FAT32 file system. You
cannot increase the cluster size on a volume using the FAT32 file system so that it
30
8/7/2019 Project Reprt virtual file system
31/43
ends up with less than 65,527 clusters.
The maximum possible number of clusters on a volume using the FAT32 file
system is 268,435,445. With a maximum of 32 KB per cluster with space for the file
allocation table (FAT), this equates to a maximum disk size of approximately 8
terabytes (TB). The ScanDisk tool included with Microsoft Windows 95 and Microsoft Windows 98
is a 16-bit program. Such programs have a single memory block maximum
allocation size of 16 MB less 64 KB. Therefore, The Windows 95 or Windows 98
ScanDisk tool cannot process volumes using the FAT32 file system that have a
FAT larger than 16 MB less 64 KB in size. A FAT entry on a volume using the
FAT32 file system uses 4 bytes, so ScanDisk cannot process the FAT on a volume
using the FAT32 file system that defines more than 4,177,920 clusters (including
the two reserved clusters). Including the FATs themselves, this works out, at the
maximum of 32 KB per cluster, to a volume size of 127.53 gigabytes (GB).
You cannot decrease the cluster size on a volume using the FAT32 file system so
that the FAT ends up larger than 16 MB less 64 KB in size.
You cannot format a volume larger than 32 GB in size using the FAT32 file system
in Windows 2000. The Windows 2000 FastFAT driver can mount and support
volumes larger than 32 GB that use the FAT32 file system (subject to the other
limits), but you cannot create one using the Format tool. This behavior is by design.
If you need to create a volume larger than 32 GB, use the NTFS file system
instead.
31
8/7/2019 Project Reprt virtual file system
32/43
VIRTUAL FILE SYSTEM
INTRODUCTION
VIRTUAL FILE SYSTEM is based on the working of FAT32 file system, and has been
designed to show the implementation of FAT32 file system. It uses the concept of file
handling and link list. Virtual file system works on a volume that is created at time of
formatting. The volume formatted by using virtual file system is allocated in clusters,
which should not be less than 65525. Virtual file system allows various operations to the
user like creating directory, formatting a volume, changing a directory, copying a file,
displaying list of directory in a given directory etc.
INITIALIZATION OF VIRTUAL FILE SYSTEM
It is important to mention here how the file system initializes. When the file system is
executed ,it allocates a space for a file entry in the memory. Initially when the file
system starts, it loads the root directory in the memory from which all the files and
folders can be traversed.
So when the file system is executed initially by default it will have the root directory as
the current directory. User can change to any directory by using the change directoryoperation.
32
8/7/2019 Project Reprt virtual file system
33/43
WORKING OF THE VIRTUAL FILE SYSTEM
FORMATTING A DRIVE
To show the implementation of a file system, we create a file of desired size ,this file
serves as a volume which stores all the file entry, directory entry, file data and structure.
A volume which is formatted through a virtual file system, is allocated in clusters.
While formatting the volume, we write the boot partition, which consist of the three
structures FSIFO_STRUCT, SBP_STRUCT. After all these structures the remaining
size to be divided in clusters is calculated. Knowing the bytes per sector and sector per
cluster, we calculate cluster count using formula:-
Cluster count=(bytes/byte per sec/sec per cluster);
NOTE:- It is important to note here that here that the cluster count for implementing FAT
32 should be always greater than 65525. If it is less than 65525 it will be FAT 16
00FA12.
Finally writing all the clusters gives the volume of desired size.
WRITING ROOT DIRECTORY:-
After formatting the volume we write the root directory entry in the volume we write theroot directory entry in the volume. This is important to lead the file system with a specific
directory. For virtual file system, Virtual File System, the root directory is a luster chain,
just like any other directory. The first cluster of the root directory on NFS is always the
second and is specifies in BPB_ROOT cluster. Unlike other directories, the root
directory itself does not have any date or time stamps, does not have a file name(other
33
8/7/2019 Project Reprt virtual file system
34/43
than the implied file name \), and does not contain . and .. files as first two directory
whenever the file system is executed, the root directory is loaded as the current
directory in the memory.
CREATING A DIRECTORY:-
Creating a directory in virtual file system works as under
1. find if file exists if it exist then do nothing.
2. Get free cluster number.
3. Create new node for fat entry.
4. Fill new node with data.
Name.
Set directory bit.
Set file size.
5. Add new node at the end of parent directory.
The points above a self explanatory. Creating a directory is nothing but a file with the
ATTR_DIRECTORY bit set in DIR_ATTR field. We set its DIR_FileSize to zero.
DIR_FileSize is not used and is always 0 on a file with a ATTR_DIRECTORY. Onecluster is allocated to the directory and we set the DIR_FstClus 0. If the directory is root
directory you are done. If the directory is not root directory, you need to create two
special entries in the chain of directory. Entry starting at DIR_FstClus, these two special
directories are :
1. The first directory entry has DIR_Name set to:
.
2. The second has DIR_Name set to:
..
These are called the dot and the dot dot entries. The DIR_FileSize field on both entries
is set to 0.
It is important to note here the importance of creating the dot and dot dot entries.
34
8/7/2019 Project Reprt virtual file system
35/43
Here is the summary for the dot and dot dot entires.
The dot entry in a directory that points to itself.
The dotdot entry in a point to the starting cluster the parent of the directory
(which is 0 if this directory parent is the root directory)
Let us now explain the dot and dotdot directory using the linked list representation.
Let us consider a node which represent a directory entry as follows.
DOT DIRECTORY ENTRY:-
AS we have mentioned that the dot directory has FstClus pointing to itself. The
directory is important to create because in operating system like UNIX we haveto refer any file in current directory using the dot direction.
DOTDOT DIRECTORY:-
Another important directory created when a directory is created is the DotDot
directory entry point to the starting cluster of its parent directory. The directory
has its important when we want to change the current directory to its parent
directory. Since the DotDot directory point to the FstClus of the parent directory
of the current directory. Changing directory to DotDot directory serves the
purpose .
For eg :
There is a directory User which further has directories Rihan and Jenifer, we
will have the following linking:
35
FstClus NextEntryDIR_NAME
8/7/2019 Project Reprt virtual file system
36/43
Link List Representation Of Dot And Dotdot Directory
36
user
Rihan
jenifer
8/7/2019 Project Reprt virtual file system
37/43
CHANGING CURRENT DIRECTORY:-
As we have already explained when the file system is executed it by default
loads the root directory as the current directory. The user can change to any of
the directory in the current directory. The change directory operation takes input
from user to which directory he wants to change and starts traversing from the
current directory first cluster number till it gets 0 value. While traversing the file
entry clusters, the DIR_NAME is compared with the name entered by the user
and the ATTR_DIRECTORY is checked. If the DIR_Name and the name entered
by the user matches and the ATTR_DIRECTORY bit is set, the directory entry is
loaded as the current directory- In case the name entered by the user does not
matches with any of the directory entry in the list traversed, it displays a messageCould not find the Directory.
READ LIST:-
Read list operation provide user the list of all the directory and files that are
present in the current directory. It displays the name of the file or directory with its
size on the screen.
Read operation first of all reads the value of first cluster of the currentdirectory. Knowing the first cluster number of the current directory the file system
traverses the entire until is reached in the next entry field of any cluster. Traversing
the entire list it prints the DIR_Name of all the entries traversed, and checks if
ATTR_DIRECTORY is set it prints and otherwise prints . In addition it
also displays the sizeof each entry.
COPYING A FILE AND READING A FILE:-
Copying a file operation checks for the free space available. If the free space available
is greater than the size of file to be copied, then the file system first create a entry for
the file. The entry, the DIR. FILESIZE is not set to 0 and the ATTR_DIRECTORY bit is
37
8/7/2019 Project Reprt virtual file system
38/43
not set. Writing the file entry, the file system copies the data of source file in small file -2
packets or data cluster. There data cluster have structures as follows
Next region Next cluster ptr
The file system writes all the data of sources file to search data cluster which are written
in the volume and are linked to each other.
For e.g.
we have created a file with name code, then the diagram for its link list representation
is as follows:-
Data cluster Data cluster Data cluster
Reading a file operation the first cluster number of the file entry, and then traverse the
whole link list of the data clusters and simply print the contents of the data field of each
node. The display the entire file in front of the user.
38
user
code
Data PTR28 bytes 4 bytes
8/7/2019 Project Reprt virtual file system
39/43
Snapshot /Output Screen
Various operations provided by the virtual file system:
39
8/7/2019 Project Reprt virtual file system
40/43
Output of list files/folder operation :
40
8/7/2019 Project Reprt virtual file system
41/43
Output of creating a directory and listing the files
41
8/7/2019 Project Reprt virtual file system
42/43
Output of the change directory operation:
42
8/7/2019 Project Reprt virtual file system
43/43
Output of copy file operation