File System.pptx

File System
Prof. shabbir
File system
• A file system is a method for storing and organizing computer files and the
data they contain to make it easy to find and access them.
• File systems may use a data storage device such as a hard disk or CD-
ROM and involve maintaining the physical location of the files,
• they might provide access to data on a fi le server by acting as clients for a
network protocol or
• they may be virtual and exist only as an access method for virtual data
File Concept
• Computers can store information on various storage media such as,
magnetic disks, magnetic tapes, optical disks.
• The physical storage is converted into a logical storage unit by operating
system.
• The logical storage unit is called FILE.
• A file is a collection of similar records.
• A record is a collection of related fields that can be treated as a unit by
some application program.
• A field is some basic element of data.
• Any individual field contains a single value. A data base is collection of
related data.
File Concept
• Contiguous logical address space
• Types:
• Data
• numeric
• character
• binary
• Program
• Contents defined by file’s creator
• Many types
• Consider text file, source file, executable file
File Attributes
• Name – only information kept in human-readable form
• Identifier – unique tag (number) identifies file within file system
• Type – needed for systems that support different types
• Location – pointer to file location on device
• Size – current file size
• Protection – controls who can do reading, writing, executing
• Time, date, and user identification – data for protection, security,
and usage monitoring
• Information about files are kept in the directory structure, which is
maintained on the disk
• Many variations, including extended file attributes such as file
checksum
• Information kept in the directory structure
File operations: File is an abstract data type
• 1. Creating a file : Two steps are needed to create a file.
• They are:
• 1. Check whether the space is available or not.
• 2. If the space is available then made an entry for the new file in the directory. The entry includes name of the file, path of the file, etc…
• 2. Writing a file : To write a file, we have to know 2 things.
• One is name of the file and
• second is the information or data to be written on the file,
• the system searches the entered given location for the file.
• If the file is found, the system must keep a write pointer to the location in the file where the next write is to take place.
• 3. Reading a file : To read a file, first of all we search the directories for the file,
• if the file is found, the system needs to keep a read pointer to the location in the file where the next read is to take place.
• Once the read has taken place, the read pointer is updated.
• 4. Repositioning within a file : The directory is searched for the appropriate entry and the current file position pointer is
repositioned to a given value.
• This operation is also called file seek.
• 5. Deleting a file : To delete a file, first of all search the directory for named file, then released the file space and erase the
directory entry.
• 6. Truncating a file : To truncate a file, remove the file contents only but, the attributes are as it is.
File Types – Name, Extension
FILE ACCESS METHODS
• Files stores information, this information must be accessed and read
into computer memory.
• There are so many ways that the information in the file can be
accessed.
• 1. Sequential file access: Information in the file is processed in order
i.e. one record after the other.
• Magnetic tapes are supporting this type of file accessing.
• Eg : A file consisting of 100 records, the current position of read/write head is
45th record, suppose we want to read the 75th record then, it access
sequentially from 45, 46, 47 …….. 74, 75.
• So the read/write head traverse all the records between 45 to 75.
Direct access:
• 2. Direct access: Direct access is also called relative access.
• Here records can read/write randomly without any order.
• The direct access method is based on a disk model of a file,
because disks allow random access to any file block.
• Eg : A disk containing of 256 blocks, the position of
read/write head is at 95th block.
• The block is to be read or write is 250th block.
• Then we can access the 250th block directly without any
restrictions.
• Eg : CD consists of 10 songs, at present we are listening song
3, If we want to listen song 10, we can shift to 10.
File System.pptx
3. Indexed Sequential File access
• The main disadvantage in the sequential file is, it takes more time to
access a Record .
• Records are organized in sequence based on a key field.
• Eg : A file consisting of 60000 records, the master index divide the
total records into 6 blocks, each block consisting of a pointer to
secondary index.
• The secondary index divide the 10,000 records into 10 indexes.
• Each index consisting of a pointer to its original location.
• Each record in the index file consisting of 2 field, A key field and a
pointer field.
Indexed Sequential File access
DIRECTORY STRUCTURE
• The directories themselves are simply files
indexing other files, which may in turn be
directories
• if a hierarchical indexing scheme is used.
• Sometimes the file system consisting of millions
of files, at that situation it is very hard to manage
the files.
• To manage these files, grouped these files and load
one group into one partition.
• Each partition is called a directory .
• a directory structure provides a mechanism for
organizing many files in the file system.
Directory structure…
• The typical contents of a directory are:
• 1. file name (string uniquely identifying the fi le), type (e.g. text, binary data, executable,
• library), organization (for systems that support different organizations);
• 2. device (where the file is physically stored), size (in blocks), starting address on device
(to
• be used by the device I/O subsystem to physically locate the file);
• 3. creator, owner, access information (who is allowed to access the file, and what they
may do with it);
• 4. date of creation/of last modification;
• 5. locking information (for the system that provide fi le/record locking).
OPERATION ON THE DIRECTORIES :
• 1. Searchfor a file:Searcha directorystructureforrequiredfile.
• 2. createafile: Newfilesneedtobe created,addedtothe directory.
• 3. Delete a file:Whena fileis nolongerneeded,wewantto removeitfromthe directory.
• 4. Lista directory:We canknow thelistoffilesinthe directory.
• 5. Rename afile: Wheneverwe needtochangethe nameofthe file,wecanchangethe name.
• 6. Traversethe filesystem: We needtoaccesseverydirectoryandeveryfilewithina directorystructurewecan
traversethe filesystem
File System.pptx
various directory structures
• In single level directory all files are contained in the same directory. It is easy to support and
• understand. It has some limitations like:
• 1. Large number of files (naming).
• 2. Ability to support different users/topics (grouping).
The problem here is different users may accidentally use the same names for their files.
E.g : If user 1 creates a files called sample and then later user 2 to creates a file called sample, then user2’s file
will overwrite user 1 file. That's why it is not used in the multi user system.
Two Level Directory
• In two level directory structure one is master file directory and the other is user file directory.
• Here each user has their own user file directory.
• Each entry in the master file directory points to a user fi le directory.
• Each user has rights to access their own directory but can’t access other user’s directory, if
permission is not given by the owner of the second one.
• To avoid this problem each user need a private directory,
• Names chosen by one user don't interfere with names chosen by a different user.
Tree Level Directory
• In Tree level directory the directory structure is a tree
with arbitrary height.
• Here users may create their own subdirectories.
• Two level directory eliminates name conflicts among
users but it is not satisfactory for users with a large
number of files.
• To avoid this create the sub-directory and load the
same type of files into the sub-directory.
• so, here each can have as many directories are
needed.
There are 2 types of path
• 1. Absoulte path
• 2. Relative path
• Absoulte path : Begging with root and follows a path
down to specified files giving directory, directory
name on the path.
• Relative path : A path from current directory.
• Absolute or relative path name
• Creating a new file is done in current directory
• Delete a file
rm <file-name>
• Creating a new subdirectory is done in current
directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
Deleting “mail”  deleting the entire subtree rooted
by “mail”
Acyclic graphdirectory
• Multiple users are working on a project, the project files can be
stored in a common sub-directory of the multiple users.
• This type of directory is called acyclic graph directory .
• The common directory will be declared a shared directory.
• The graph contain no cycles with shared files, changes made by
one user are made visible to other users.
• A file may now have multiple absolute paths.
• when shared directory/file is deleted, all pointers to the
directory/ files also to be removed.
General graph directory:
• When we add links to an existing tree structured
directory, the tree structure is destroyed, resulting is a
simple graph structure.
• How do we guarantee no cycles?
• Allow only links to file not subdirectories
• Garbage collection
• Every time a new link is added use a cycle
detection algorithm to determine
whether it is OK
•
File allocation methods
• An allocation method refers to how disk blocks are allocated for files.
• One main problem in file management is how to allocate space for files so that disk space is utilized
effectively and files can be accessed quickly.
• Three major methods of allocating disk space are contiguous, linked, and indexed. Each method
has its advantages and disadvantages.
• Accordingly, some systems support all three (e.g. Data General’s RDOS). More commonly, a
• system will use one particular method for all files.
Contiguous allocation
• The contiguous allocation method
requires each file to occupy a set of
contiguous address on the disk.
• Disk addresses define a linear
ordering on the disk.
• each file occupies set of contiguous
blocks
• Best performance in most cases
• Simple – only starting location (block
#) and length (number of blocks) are
required
• Problems include finding space for file,
knowing file size, external
fragmentation, need for compaction
off-line (downtime) or on-line
Linked.
Linked allocation
• Linked allocation – each file a linked list of blocks o File
ends at nil pointer
• No external fragmentation
• Each block contains pointer to next block
• No compaction, external fragmentation
• Free space management system called when new block
needed
• Improve efficiency by clustering blocks into groups but
increases internal fragmentation
• Reliability can be a problem
• Locating a block can take many I/O s and disk seeks FAT
(File Allocation Table) variation
• Beginning of volume has table, indexed by block number
• Much like a linked list, but faster on disk and cacheable
File allocation table
Indexed allocation
• Each file has its own index block(s) of pointers to its data blocks
• The indexed allocation method is the solution to the problem of both contiguous and linked
allocation.
• This is done by bringing all the pointers together into one location called the index block.
• Of course, the index block will occupy some space and thus could be considered as an overhead of
the method.
• In indexed allocation, each fi le has its own index block, which is an array of disk sector of
addresses.
• The ith entry in the index block points to the ith sector of the file.
• The directory contains the address of the index block of a file.
• To read the ith sector of the fi le, the pointer in the ith index block entry is read to find the desired
sector.
• Indexed allocation supports direct access, without suffering from external fragmentation.
• Any free block anywhere on the disk may satisfy a request for more space.
Indexed allocation
Thank
you
1 sur 30

Recommandé

File system in operating system e learning par
File system in operating system e learningFile system in operating system e learning
File system in operating system e learningLavanya Sharma
416 vues40 diapositives
File system par
File systemFile system
File systemNavin Royal Achakkagari
109 vues87 diapositives
UNIT7-FileMgmt.pptx par
UNIT7-FileMgmt.pptxUNIT7-FileMgmt.pptx
UNIT7-FileMgmt.pptxNavyaKumar22
5 vues75 diapositives
Ch10 file system interface par
Ch10   file system interfaceCh10   file system interface
Ch10 file system interfaceWelly Dian Astika
204 vues42 diapositives
File Management & Access Control par
File Management & Access Control File Management & Access Control
File Management & Access Control YuvrajWadavale
38 vues81 diapositives
Os6 par
Os6Os6
Os6gopal10scs185
586 vues99 diapositives

Contenu connexe

Similaire à File System.pptx

10 File System par
10 File System10 File System
10 File SystemDr. Loganathan R
3K vues23 diapositives
File Management par
File ManagementFile Management
File ManagementRamasubbu .P
3.3K vues64 diapositives
File Systems par
File SystemsFile Systems
File SystemsShipra Swati
1.3K vues11 diapositives
File Management par
File ManagementFile Management
File Managementramya marichamy
1.4K vues27 diapositives
file management par
file managementfile management
file managementSalisu Nura
1.4K vues78 diapositives
UNIT III.pptx par
UNIT III.pptxUNIT III.pptx
UNIT III.pptxYogapriyaJ1
2 vues22 diapositives

Similaire à File System.pptx(20)

File system and Deadlocks par Rohit Jain
File system and DeadlocksFile system and Deadlocks
File system and Deadlocks
Rohit Jain447 vues
CNIT 121: 13 Investigating Mac OS X Systems par Sam Bowne
CNIT 121: 13 Investigating Mac OS X SystemsCNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X Systems
Sam Bowne700 vues
Report blocking ,management of files in secondry memory , static vs dynamic a... par NoorMustafaSoomro
Report blocking ,management of files in secondry memory , static vs dynamic a...Report blocking ,management of files in secondry memory , static vs dynamic a...
Report blocking ,management of files in secondry memory , static vs dynamic a...
Operations on a directory 54(3 par myrajendra
Operations on a directory 54(3Operations on a directory 54(3
Operations on a directory 54(3
myrajendra425 vues
File and directory par Sunil Kafle
File and directoryFile and directory
File and directory
Sunil Kafle1.2K vues
3. distributed file system requirements par AbDul ThaYyal
3. distributed file system requirements3. distributed file system requirements
3. distributed file system requirements
AbDul ThaYyal13.9K vues

Plus de bcanawakadalcollege

Intro to Javascript.pptx par
Intro to Javascript.pptxIntro to Javascript.pptx
Intro to Javascript.pptxbcanawakadalcollege
4 vues9 diapositives
computer and software are changing.pptx par
computer and software are changing.pptxcomputer and software are changing.pptx
computer and software are changing.pptxbcanawakadalcollege
2 vues9 diapositives
tIME LINE.pptx par
tIME LINE.pptxtIME LINE.pptx
tIME LINE.pptxbcanawakadalcollege
6 vues1 diapositive
Basic HTML Tags.PPT par
Basic HTML Tags.PPTBasic HTML Tags.PPT
Basic HTML Tags.PPTbcanawakadalcollege
17 vues17 diapositives
Cryptography.ppt par
Cryptography.pptCryptography.ppt
Cryptography.pptbcanawakadalcollege
31 vues42 diapositives
Confusion and Diffusion.pptx par
Confusion and Diffusion.pptxConfusion and Diffusion.pptx
Confusion and Diffusion.pptxbcanawakadalcollege
624 vues9 diapositives

Plus de bcanawakadalcollege(20)

Dernier

ACTIVITY BOOK key water sports.pptx par
ACTIVITY BOOK key water sports.pptxACTIVITY BOOK key water sports.pptx
ACTIVITY BOOK key water sports.pptxMar Caston Palacio
511 vues4 diapositives
Solar System and Galaxies.pptx par
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptxDrHafizKosar
89 vues26 diapositives
Create a Structure in VBNet.pptx par
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptxBreach_P
72 vues8 diapositives
discussion post.pdf par
discussion post.pdfdiscussion post.pdf
discussion post.pdfjessemercerail
130 vues1 diapositive
Psychology KS4 par
Psychology KS4Psychology KS4
Psychology KS4WestHatch
76 vues4 diapositives
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively par
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyPECB
574 vues18 diapositives

Dernier(20)

Solar System and Galaxies.pptx par DrHafizKosar
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptx
DrHafizKosar89 vues
Create a Structure in VBNet.pptx par Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P72 vues
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively par PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 574 vues
11.30.23 Poverty and Inequality in America.pptx par mary850239
11.30.23 Poverty and Inequality in America.pptx11.30.23 Poverty and Inequality in America.pptx
11.30.23 Poverty and Inequality in America.pptx
mary850239149 vues
Ch. 7 Political Participation and Elections.pptx par Rommel Regala
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptx
Rommel Regala90 vues
Narration lesson plan.docx par TARIQ KHAN
Narration lesson plan.docxNarration lesson plan.docx
Narration lesson plan.docx
TARIQ KHAN108 vues
UWP OA Week Presentation (1).pptx par Jisc
UWP OA Week Presentation (1).pptxUWP OA Week Presentation (1).pptx
UWP OA Week Presentation (1).pptx
Jisc87 vues
Drama KS5 Breakdown par WestHatch
Drama KS5 BreakdownDrama KS5 Breakdown
Drama KS5 Breakdown
WestHatch73 vues
Class 10 English notes 23-24.pptx par TARIQ KHAN
Class 10 English notes 23-24.pptxClass 10 English notes 23-24.pptx
Class 10 English notes 23-24.pptx
TARIQ KHAN125 vues
The Open Access Community Framework (OACF) 2023 (1).pptx par Jisc
The Open Access Community Framework (OACF) 2023 (1).pptxThe Open Access Community Framework (OACF) 2023 (1).pptx
The Open Access Community Framework (OACF) 2023 (1).pptx
Jisc107 vues
Education and Diversity.pptx par DrHafizKosar
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptx
DrHafizKosar135 vues
Community-led Open Access Publishing webinar.pptx par Jisc
Community-led Open Access Publishing webinar.pptxCommunity-led Open Access Publishing webinar.pptx
Community-led Open Access Publishing webinar.pptx
Jisc91 vues
JiscOAWeek_LAIR_slides_October2023.pptx par Jisc
JiscOAWeek_LAIR_slides_October2023.pptxJiscOAWeek_LAIR_slides_October2023.pptx
JiscOAWeek_LAIR_slides_October2023.pptx
Jisc93 vues

File System.pptx

  • 2. File system • A file system is a method for storing and organizing computer files and the data they contain to make it easy to find and access them. • File systems may use a data storage device such as a hard disk or CD- ROM and involve maintaining the physical location of the files, • they might provide access to data on a fi le server by acting as clients for a network protocol or • they may be virtual and exist only as an access method for virtual data
  • 3. File Concept • Computers can store information on various storage media such as, magnetic disks, magnetic tapes, optical disks. • The physical storage is converted into a logical storage unit by operating system. • The logical storage unit is called FILE. • A file is a collection of similar records. • A record is a collection of related fields that can be treated as a unit by some application program. • A field is some basic element of data. • Any individual field contains a single value. A data base is collection of related data.
  • 4. File Concept • Contiguous logical address space • Types: • Data • numeric • character • binary • Program • Contents defined by file’s creator • Many types • Consider text file, source file, executable file
  • 5. File Attributes • Name – only information kept in human-readable form • Identifier – unique tag (number) identifies file within file system • Type – needed for systems that support different types • Location – pointer to file location on device • Size – current file size • Protection – controls who can do reading, writing, executing • Time, date, and user identification – data for protection, security, and usage monitoring • Information about files are kept in the directory structure, which is maintained on the disk • Many variations, including extended file attributes such as file checksum • Information kept in the directory structure
  • 6. File operations: File is an abstract data type • 1. Creating a file : Two steps are needed to create a file. • They are: • 1. Check whether the space is available or not. • 2. If the space is available then made an entry for the new file in the directory. The entry includes name of the file, path of the file, etc… • 2. Writing a file : To write a file, we have to know 2 things. • One is name of the file and • second is the information or data to be written on the file, • the system searches the entered given location for the file. • If the file is found, the system must keep a write pointer to the location in the file where the next write is to take place. • 3. Reading a file : To read a file, first of all we search the directories for the file, • if the file is found, the system needs to keep a read pointer to the location in the file where the next read is to take place. • Once the read has taken place, the read pointer is updated. • 4. Repositioning within a file : The directory is searched for the appropriate entry and the current file position pointer is repositioned to a given value. • This operation is also called file seek. • 5. Deleting a file : To delete a file, first of all search the directory for named file, then released the file space and erase the directory entry. • 6. Truncating a file : To truncate a file, remove the file contents only but, the attributes are as it is.
  • 7. File Types – Name, Extension
  • 8. FILE ACCESS METHODS • Files stores information, this information must be accessed and read into computer memory. • There are so many ways that the information in the file can be accessed. • 1. Sequential file access: Information in the file is processed in order i.e. one record after the other. • Magnetic tapes are supporting this type of file accessing. • Eg : A file consisting of 100 records, the current position of read/write head is 45th record, suppose we want to read the 75th record then, it access sequentially from 45, 46, 47 …….. 74, 75. • So the read/write head traverse all the records between 45 to 75.
  • 9. Direct access: • 2. Direct access: Direct access is also called relative access. • Here records can read/write randomly without any order. • The direct access method is based on a disk model of a file, because disks allow random access to any file block. • Eg : A disk containing of 256 blocks, the position of read/write head is at 95th block. • The block is to be read or write is 250th block. • Then we can access the 250th block directly without any restrictions. • Eg : CD consists of 10 songs, at present we are listening song 3, If we want to listen song 10, we can shift to 10.
  • 11. 3. Indexed Sequential File access • The main disadvantage in the sequential file is, it takes more time to access a Record . • Records are organized in sequence based on a key field. • Eg : A file consisting of 60000 records, the master index divide the total records into 6 blocks, each block consisting of a pointer to secondary index. • The secondary index divide the 10,000 records into 10 indexes. • Each index consisting of a pointer to its original location. • Each record in the index file consisting of 2 field, A key field and a pointer field.
  • 13. DIRECTORY STRUCTURE • The directories themselves are simply files indexing other files, which may in turn be directories • if a hierarchical indexing scheme is used. • Sometimes the file system consisting of millions of files, at that situation it is very hard to manage the files. • To manage these files, grouped these files and load one group into one partition. • Each partition is called a directory . • a directory structure provides a mechanism for organizing many files in the file system.
  • 14. Directory structure… • The typical contents of a directory are: • 1. file name (string uniquely identifying the fi le), type (e.g. text, binary data, executable, • library), organization (for systems that support different organizations); • 2. device (where the file is physically stored), size (in blocks), starting address on device (to • be used by the device I/O subsystem to physically locate the file); • 3. creator, owner, access information (who is allowed to access the file, and what they may do with it); • 4. date of creation/of last modification; • 5. locking information (for the system that provide fi le/record locking).
  • 15. OPERATION ON THE DIRECTORIES : • 1. Searchfor a file:Searcha directorystructureforrequiredfile. • 2. createafile: Newfilesneedtobe created,addedtothe directory. • 3. Delete a file:Whena fileis nolongerneeded,wewantto removeitfromthe directory. • 4. Lista directory:We canknow thelistoffilesinthe directory. • 5. Rename afile: Wheneverwe needtochangethe nameofthe file,wecanchangethe name. • 6. Traversethe filesystem: We needtoaccesseverydirectoryandeveryfilewithina directorystructurewecan traversethe filesystem
  • 17. various directory structures • In single level directory all files are contained in the same directory. It is easy to support and • understand. It has some limitations like: • 1. Large number of files (naming). • 2. Ability to support different users/topics (grouping). The problem here is different users may accidentally use the same names for their files. E.g : If user 1 creates a files called sample and then later user 2 to creates a file called sample, then user2’s file will overwrite user 1 file. That's why it is not used in the multi user system.
  • 18. Two Level Directory • In two level directory structure one is master file directory and the other is user file directory. • Here each user has their own user file directory. • Each entry in the master file directory points to a user fi le directory. • Each user has rights to access their own directory but can’t access other user’s directory, if permission is not given by the owner of the second one.
  • 19. • To avoid this problem each user need a private directory, • Names chosen by one user don't interfere with names chosen by a different user.
  • 20. Tree Level Directory • In Tree level directory the directory structure is a tree with arbitrary height. • Here users may create their own subdirectories. • Two level directory eliminates name conflicts among users but it is not satisfactory for users with a large number of files. • To avoid this create the sub-directory and load the same type of files into the sub-directory. • so, here each can have as many directories are needed. There are 2 types of path • 1. Absoulte path • 2. Relative path • Absoulte path : Begging with root and follows a path down to specified files giving directory, directory name on the path. • Relative path : A path from current directory.
  • 21. • Absolute or relative path name • Creating a new file is done in current directory • Delete a file rm <file-name> • Creating a new subdirectory is done in current directory mkdir <dir-name> Example: if in current directory /mail mkdir count Deleting “mail”  deleting the entire subtree rooted by “mail”
  • 22. Acyclic graphdirectory • Multiple users are working on a project, the project files can be stored in a common sub-directory of the multiple users. • This type of directory is called acyclic graph directory . • The common directory will be declared a shared directory. • The graph contain no cycles with shared files, changes made by one user are made visible to other users. • A file may now have multiple absolute paths. • when shared directory/file is deleted, all pointers to the directory/ files also to be removed.
  • 23. General graph directory: • When we add links to an existing tree structured directory, the tree structure is destroyed, resulting is a simple graph structure. • How do we guarantee no cycles? • Allow only links to file not subdirectories • Garbage collection • Every time a new link is added use a cycle detection algorithm to determine whether it is OK •
  • 24. File allocation methods • An allocation method refers to how disk blocks are allocated for files. • One main problem in file management is how to allocate space for files so that disk space is utilized effectively and files can be accessed quickly. • Three major methods of allocating disk space are contiguous, linked, and indexed. Each method has its advantages and disadvantages. • Accordingly, some systems support all three (e.g. Data General’s RDOS). More commonly, a • system will use one particular method for all files.
  • 25. Contiguous allocation • The contiguous allocation method requires each file to occupy a set of contiguous address on the disk. • Disk addresses define a linear ordering on the disk. • each file occupies set of contiguous blocks • Best performance in most cases • Simple – only starting location (block #) and length (number of blocks) are required • Problems include finding space for file, knowing file size, external fragmentation, need for compaction off-line (downtime) or on-line Linked.
  • 26. Linked allocation • Linked allocation – each file a linked list of blocks o File ends at nil pointer • No external fragmentation • Each block contains pointer to next block • No compaction, external fragmentation • Free space management system called when new block needed • Improve efficiency by clustering blocks into groups but increases internal fragmentation • Reliability can be a problem • Locating a block can take many I/O s and disk seeks FAT (File Allocation Table) variation • Beginning of volume has table, indexed by block number • Much like a linked list, but faster on disk and cacheable
  • 28. Indexed allocation • Each file has its own index block(s) of pointers to its data blocks • The indexed allocation method is the solution to the problem of both contiguous and linked allocation. • This is done by bringing all the pointers together into one location called the index block. • Of course, the index block will occupy some space and thus could be considered as an overhead of the method. • In indexed allocation, each fi le has its own index block, which is an array of disk sector of addresses. • The ith entry in the index block points to the ith sector of the file. • The directory contains the address of the index block of a file. • To read the ith sector of the fi le, the pointer in the ith index block entry is read to find the desired sector. • Indexed allocation supports direct access, without suffering from external fragmentation. • Any free block anywhere on the disk may satisfy a request for more space.