0% found this document useful (0 votes)
24 views47 pages

ch10

ss

Uploaded by

REVOLVER
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views47 pages

ch10

ss

Uploaded by

REVOLVER
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 47

Chapter 10-11: File-System

Interface

Operating System Concepts – 10th Edition, Silberschatz, Galvin and Gagne ©2018
Chapter 10: File-System Interface

 File Concept
 Access Methods
 Directory Structure
 File-System Mounting
 File Sharing
 Protection

Operating System Concepts – 10th Edition 10-11.2 Silberschatz, Galvin and Gagne ©2018
Objectives
 To explain the function of file systems
 To describe the interfaces to file systems
 To discuss file-system design tradeoffs, including access
methods, file sharing, file locking, and directory structures
 To explore file-system protection

Operating System Concepts – 10th Edition 10-11.3 Silberschatz, Galvin and Gagne ©2018
Operating Systems – Abstraction
 Make the system easier to use.
 Abstract many of the details of the physical hardware away
 Scheduling – illusion of exclusive execution
 Virtual Memory – illusion of exclusive memory access
 Need abstractions/interfaces for
 Interacting with devices (disks, terminals, keyboards)
 Interacting with other processes
 Abstraction of Disk
 Disk, like memory is a large array of bits
 Partitioned into sectors (usually 512 bytes)

Unit of transfer to and from disk
 Non-volatile – data persists across reboots/power downs
 How do we share the disk between processes?
 Protection/Security
 How do we make the disk easy to use? While maintaining
Operating System Concepts – 10th Edition 10-11.4 Silberschatz, Galvin and Gagne ©2018
Magnetic Media (Disk)
• Disks have multiple platters

•Each platter has a head

•The different heads are


attached to a single arm

•Thedifferent heads can


access data in parallel

• Each platter has multiple


concentric tracks

•A cylinder is same track


across different platters

• Each track has multiple sectors

•Asector typically has


preamble, data and ECC
Operating System Concepts – 10th Edition 10-11.5 Silberschatz, Galvin and Gagne ©2018
Magnetic Disk (Cont.)
 Disks are accessed at the granularity of sectors Typically, 512 bytes
 A file system allocates data in chunks called blocks
 A block contains 2n contiguous sectors
 Reduces overhead of managing individual bytes
 Large blocks improve throughput but increase internal fragmentation
 File systems view the disk as an array of blocks
 Disks can process I/O requests in parallel
 Many I/O requests for blocks can be pending at a given time
 Disks are slow!
 ~10 ms latency to access a block1
 Versus 0.0002 ms to access to memory
 Versus 0.000001ms to access to register
 Minimize frequency of slow disk access! So cache file data in memory
 Paging (page cache) treats disk as extension of the storage hierarchy.
When we didn't have enough memory, write out to disk. Buffer cache
holds file's data, treats memory as a cache for disk data
Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 10-11.6
Track
Magnetic Disk (Cont.)
 Cylinder: all the tracks under the Sector
heads at a given point on all surface
Head
 Read/write data is a three-stage
Cylinder
process:
Platter
 Seek time: position the head/arm over the proper track (into proper
cylinder) =>arm motion (say forth and back motion)
 Rotational latency: wait for the desired sector to rotate under the
read/write head ( rotation motion)
 Transfer time: transfer a block of bits (sector)
under the read-write head

 Disk Latency = Queuing Time + Controller time +


Seek Time + Rotation Time + Xfer Time
Controller
Hardware
Request

Result
Software
Media Time
Queue
(Seek+Rot+Xfer)
(Device Driver)

 Highest Bandwidth:
 transfer large group of blocks sequentially from one track
Operating System Concepts – 10th Edition 10-11.7 Silberschatz, Galvin and Gagne ©2018
 Disks: Not just slow, Complex
Magnetic Disk (Cont.)
 Bad sectors
 Seeks between cylinders are  Allocate spare sectors per track
expensive  Block can be mapped to spare in
 Random vs. sequential factory, by device controller, by
access OS
 Sequential access – platter  OS can hide bad sectors by
rotation allocating them to a special
 80 MB/s bandwidth hidden file
  Physical backup programs have
0.16 ms latency
 Random access – head seeks
to be careful
 Disk can be subdivided into
 0.5 MB/s bandwidth
partitions which can be used ad raw
 10 ms latency – without a file system, or formatted
 All sorts of fail (having structure) with a file system.
  Entity containing file system known
Lots of errors possible
as a volume. Each volume
 E.g., latent sector errors, containing file system also tracks
mis-directed writes, etc. that file system’s info in device
System Concepts – 10th Edition
Operating Transient vs. hard errors 10-11.8 directory or volume tableGalvin
Silberschatz, of contents
and Gagne ©2018
File Systems
 3 criteria for long-term information storage:
 Should be able to store very large amount of information
 Information must survive the processes using it
 Should provide concurrent access to multiple processes
 Solution:
 Store information on disks in units called files
 Files are persistent, and only owner can explicitly delete it
 Files are managed by the OS
 File Systems: How the OS manages files!
 File systems have different types
 File system partitions have types
 e.g., swap space, EXT3, FAT32, NTFS

Operating System Concepts – 10th Edition 10-11.9 Silberschatz, Galvin and Gagne ©2018
File System (Cont.)
 File System: Layer of OS that transforms block interface of disks (or
other block devices) into Files, Directories, etc.
 File System Components
 Disk Management: collecting disk blocks into files
 Naming: Interface to find files by name, not by blocks
 Protection: Layers to keep data secure
 Reliability/Durability: Keeping of files durable despite crashes,
media failures, attacks, etc
 User vs. System View of a File
 User’s view:
 Durable Data Structures: directories and files.

 System’s view (system call interface):


 Collection of Bytes (UNIX)
 Doesn’t matter to system what kind of data structures you want
to store on disk!
 System’s view (inside OS):
 Collection of blocks (a block is a logical transfer unit, while a
sector is the physical transfer unit)
 Block size  sector size; in UNIX, block size is 4KB

Operating System Concepts – 10th Edition 10-11.10 Silberschatz, Galvin and Gagne ©2018
File Systems (Cont.)
 A file system provides an abstraction for storing, organizing and
accessing persistent data. It is a Layer of OS that transforms block
interface of disks (or other block devices) into Files, Directories, etc.
 File-system data is organized as logical files
 Accessed via system calls
 Files have names and are organized as directories
 Directory structure maintains info of all files in the volume
 Name, location, size, type, …
 The list of blocks containing the data
 Other information such as access control list or permissions,
owner, time of access, etc?

11
Operating System Concepts – 10th Edition 10-11.11 Silberschatz, Galvin and Gagne ©2018
Translating from User to System View

File
System

 What happens if user says: give me bytes 2—12?



Fetch block corresponding to those bytes
 Return just the correct portion of the block
 What about: write bytes 2—12?
 Fetch block
 Modify portion
 Write out Block
 Everything inside File System is in whole size blocks
 For example, getc(), putc()  buffers something like 4096
bytes, even if interface is one byte at a time
 From now on, file is a collection of blocks (i.e. systems view inside
OS)
Operating System Concepts – 10th Edition 10-11.12 Silberschatz, Galvin and Gagne ©2018
What is a File?
 A file is a sequence of bytes contained in multiple, ordered, sectors
(blocks) on non-volatile devices such as disks
 Disk space is always allocated in blocks
 A sector is a fixed size block of data
 E.g., 512 bytes

 Example
 With a 512 byte sector size, a 64 MB file (MB = 1024* 1024 bytes) would
have how many sectors?

 Remember Block size  sector size


64 1024 1024 bytes
131,072 sectors
512 bytes/sector
13
Operating System Concepts – 10th Edition 10-11.13 Silberschatz, Galvin and Gagne ©2018
Directories
 A Directory Store a list of directory entries
that point to files or subdirectory. Method for
naming and locating a file
 Efficiently locate and identify files
 Allow intuitive grouping of objects
like files together
 Useful for both OS and users
 Modern systems use hierarchical directories

A directory contains files or sub-directories Operations Performed
 E.g., B contains entries for D, j and E on Directory
 Files are accessed with pathnames 1- Search for a file
 Absolute pathname. path of file from the 2- Create a file
root directory e.g. cat /B/D/n 3- Delete a file
 Relative pathname path from the current 4- Truncate a file
working directory e.g. cd B/D; cat n
5- List a directory
 two special entries in each directory:
6- Rename a file
“.” for current directory and “..” for parent
Operating System Concepts – 10th Edition 10-11.14 7- Traverse file
Silberschatz, system
Galvin and Gagne ©2018
File Structure and Attributes
 The OS typically treats files as an unstructured sequence of bytes
 Programs create files and they can impose any format on files
 E.g., application programs may look for specific file extension to indicate
the file’s type
 However, OS needs to understand the format of executable files to execute
programs(text, data, heap, stack sections)
 Files have various attributes associated with them. These attributes are
called file metadata or File Control Block (FCB) or I-node and is
maintained in file system data structures for each file. They vary a lot across
different operating systems. Examples:
 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
Operating System Concepts – 10 Edition
th 10-11.15 Silberschatz, Galvin and Gagne ©2018
File Operations
 1- Create a file: create new file in a directory

Find space in the file system, add directory entry. Create() can open()!
 2- Open file: fetch existing file attributes and disk addresses in memory
 System call specifying name of file.
 system searches directory structure to find file.
 System keeps current file position pointer to the location where next
write/read occurs

System call returns file descriptor (a handle) to user process
 3- Write in file: write content of buffer in memory into disk blocks- Increase size
 System call specifying file descriptor and information to be written
 Writes information at location pointed by the files current pointer
 4- Read from a file: read disk blocks into buffer in memory
 System call specifying file descriptor and number of bytes to read
(and possibly where in memory to stick contents).
 5- Repositioning within a file: move to specific block
 System call specifying file descriptor and new location of current
pointer. Also called a file seek even though does not interact with disk
Operating System Concepts – 10th Edition 10-11.16 Silberschatz, Galvin and Gagne ©2018
File Operations (Cont.)
 6- Sharing a file:
 Sharing may be done through a protection scheme
 Some systems provide file sharing by maintaining a single copy
of a file; other systems maintain several copies, one for each of
the users
 With a single copy, several concurrent updates to a file
may result in user obtaining incorrect information, and the
file being left in an incorrect state.
 With multiple copies, there is storage waste and the various
copies may not be consistent with respect to each other.
 7- Delete (unlink) a file: remove directory entry, free up space
 8- Truncate a file: free up space, set file length to zero
 9- Closing a file: entry removed from open file table
 System call specifying file descriptor
 Call removes current file position pointer and file descriptor
associated with process and file
Operating System Concepts – 10th Edition 10-11.17 Silberschatz, Galvin and Gagne ©2018
File Protection
 File owner/creator  Categories of Users
should  Individual user
be able to control:
 Log in establishes a user-id
 what can be done
 Might be just local on the
 by whom computer or could be through
interaction with a network
 Types of access service
 Read  Groups to which the user
 Write belongs
 For example, “it” is in “IT-
 Execute
department”
 Append
 Again could just be automatic
 Delete or could involve talking to a
 List service that might assign,
say, a temporary
18
Operating System Concepts – 10th Edition 10-11.18 cryptographic key Galvin and Gagne ©2018
Silberschatz,
File Protection(Cont.)
• Linux Access Rights (chmod, uid, grpid….)
• Mode of access: read, write, execute
• Three classes of users RWX
a) owner access 7  111
RWX
b) group access 6  110
RWX
c) other access 1  001

• For a particular file (say game) or subdirectory, define an


appropriate access.
owner group public

chmod 761 game


$ ls -l game
-rwxrw--- 4 user group 6 Mar 11 12:50 game
• Windows XP Access-control List Management
Operating System Concepts – 10th Edition 10-11.19 Silberschatz, Galvin and Gagne ©2018
Multiple users of a file
 Several pieces of data are needed to manage open files:
 File pointer: pointer to last read/write location, per process that has the
file open
 File-open count: counter of number of times a file is open – to allow
removal of data from open-file table (in memory) when last processes
closes it
 Disk location of the file: cache of data access information
 Access rights: per-process access mode information
 OS typically keeps the above information in two levels of internal tables:
 Per-process table
 Information about the use of the file by the user (e.g. current file position
pointer).
 System wide table
 Gets created by first process which opens the file
 Location of file on disk
 Access dates
 File size
 Count of how many processes have the file open (used for deletion)
Operating System Concepts – 10th Edition 10-11.20 Silberschatz, Galvin and Gagne ©2018
Files Open and Read (OS structure)

21
Operating System Concepts – 10th Edition 10-11.21 Silberschatz, Galvin and Gagne ©2018
Structures That Implement a File System
On-disk structures See figure in In-memory structures
 Boot control block Slide 24/33  Partition table
 Info to boot the OS from the  Current mounted partitions
disk  Directory structure
 Typically, the first block of the  Information on recently
boot partition (boot block) access directories
 Partition control block  System-wide, open file table
 Info about a file system  All the currently open files
(number of blocks -- fixed size)
 Per-process, open file table
 Includes free block information
 All this process’s open files
(superblock)
 Directory Structure
 File Control Blocks
 Logical file system’s
representation of a file --
stored on disk
 In UNIX, called an inode 10-11.22
Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018
File System Design
 A file system performs four main tasks
 Block allocation and placement
 Maps (potentially non-contiguous) blocks to the file
 Issues similar to virtual memory, placement unique to disks

 Free block management


 Allocates blocks to a file, manages free blocks
– Uses bitmaps or linked list
– Issues similar to memory, swap management

 Directory management
 Maps file names to location of starting block of file

 Buffer cache management


 Caches disk blocks in memory to minimize I/O
Operating System Concepts – 10th Edition 10-11.23 Silberschatz, Galvin and Gagne ©2018
File Allocation
 Direct access of disks gives us flexibility in implementing files
 Relate to memory management problem
 Choices
 – Contiguous allocation
 – Non-contiguous allocation
 Linked
 Indexed
UNIX File SYSTEM

Operating System Concepts – 10th Edition 10-11.24 Silberschatz, Galvin and Gagne ©2018
Common methods of allocation
 Directories and Files needs to be allocated on disk. Directories and files
may occupy multiple data blocks on the disk.
 Not only directories/Files but also their FCB may actually be multiple
blocks on disk ( E.g., if information about data blocks require more
space than can fit in a single disk block)
 Linked:
 Use space in each disk block for a pointer to next block; indicate
end block with special value pointer (e.g., ‐1 or 0)
 FCB has pointer to first block in linked list
 Contiguous:
 Blocks for a specific file allocated together in a sequence on the
physical device
 FCB records number of blocks in file and a pointer to first block
 Indexed:
 Use separate (index) blocks of disk space for pointers to data
blocks of the file
 FCB contains pointer(s) to index block(s)
Operating System Concepts – 10th Edition 10-11.25 Silberschatz, Galvin and Gagne ©2018
Contiguous Allocation
 All blocks in a file are contiguous on the disk
 Advantages
 Easy to find file’s block. Need starting disk address and number
of blocks (length of file). Efficient for direct access.
 Performance is good for sequential reading ( need one seek only)
 Disadvantages
 File size has to be known a priori.
 File growth requires copying
 Disk becomes fragmented after deletion (external fragmentation)
 Will need periodic compaction (No special HW like MMU!!!!)
 Good for CD-ROMs where Files are never deleted
 All file sizes are known in advance

Operating System Concepts – 10th Edition 10-11.26 Silberschatz, Galvin and Gagne ©2018
Assume that disk block=1024
bytes.
What is the physical location
of logical byte 1045 in file
mail?:
you need one disk access
(reference) assuming that the
directory FCB is stored in
memory. It is located in the
21th byte within Block number
20 that is relative to the known
Operating System Concepts – 10th Edition 10-11.27 starting physical block
Silberschatz, 19.
Galvin and Gagne ©2018
Non-contiguous: 1- Linked Allocation
 Each file is a linked list of
blocks. Keep a pointer to first
block of a file in the directory.
 The first few bytes of each block
point to the next block of this Directory
file.
 Advantages: No external File A 4
fragmentation but internal in
File B 6
the last block.
Disadvantages: 1- Random access
is slow!. 2- Reliability: If one File A: blocks 4, 7, 2, 10, 12
block pointer is corrupted, we File B: Blocks 6 , 3, 11, 14
loose file after that point

Operating System Concepts – 10th Edition 10-11.28 Silberschatz, Galvin and Gagne ©2018
Assume that disk block=1K bytes &
block address is 4 bytes. Each block
can store 1024-4=1020 bytes
What is the physical location of
logical byte 4079 in file jeep:
you need i disk access (reference)
where i = 4 assuming that the
directory FCB is stored in memory. It is
located in the last (1023th) byte within
Block number 10 that is relative to the
known starting block 9.
Operating System Concepts – 10th Edition 10-11.29 Silberschatz, Galvin and Gagne ©2018
Indexed Allocation
 In the prev. scheme, we needed to go to disk to chase pointers since
memory cannot hold all the blocks.
 Store separate blocks, per file, containing pointers to disk blocks
contained in the file
 Two types of blocks per file
 Index blocks
 Data blocks
 Positive aspects
 More efficient method for direct access (than linked)
 Also good for sequential access
 Issues
 – Overhead for pointers increases; Why?
 – Fragmentation
 What if a large file requires more space than a single index block?
 Linked index blocks
 Mulilevel indexing
Operating System Concepts – 10th Edition 10-11.30 Silberschatz, Galvin and Gagne ©2018
Same example as in list allocation but needs
2 disk accesses to locate byte 4079. one for
block 19 (that contains all the links for file
jeep) and then block 10. Direct access
What if we keep index 19 in memory?
Operating System Concepts – 10th Edition
Yields10-11.31
one disk access Silberschatz, Galvin and Gagne ©2018
Fragmentation Allocation Methods
 Internal: Areas within a file that are unused
 External: Blocks outside of files that are unused

Fragmentation Contiguous Linked Indexed


Internal May have to On average ½ of On average ½ •
specify the last block goes of last index
maximum unused block
extent to which goes unused
the file will grow
On average ½ •
of last data block
goes unused
External May have None None
sufficient number
of disk
blocks to create a
new file, but they
may not be in a
contiguous
sequence

Operating System Concepts – 10th Edition 10-11.32 Silberschatz, Galvin and Gagne ©2018
File Allocation Table (FAT) File system
 File allocation table resides at the beginning of the volume.
 Root folder must be stored in a fixed location so that the files needed to
start the system can be correctly located.
 A volume formatted with the FAT file system is allocated in clusters.
 A partition is divided up into identically sized clusters, small blocks of
contiguous space.

 Cluster sizes vary depending on the type of FAT file system being
used and the size of the partition, typically cluster sizes lie
somewhere between 2 KB and 32 KB.
 Each file may occupy one or more of these clusters depending on its
size; thus, a file is represented by a chain of these clusters (referred
to as a singly linked list). However these clusters are not
necessarily stored adjacent to one another on the disk's surface
but are often instead fragmented throughout the Data Region
Operating System Concepts – 10th Edition 10-11.33 Silberschatz, Galvin and Gagne ©2018
File Allocation Table (FAT) File system
System Bytes Per Cluster Within Cluster limit
File Allocation Table

FAT12 only 12 of 16 bits are( 1.5 .Fewer than 4087 clusters


)used

FAT16 )Bits 16( 2 Between 4087 and 65526


.clusters, inclusive

FAT32 only 28 of 32 bits are( 4 Between 65526 and


)used 268,435,456 clusters,
.inclusive

 Disk allocation on the basis of a cluster instead of the actual block


represents more disk space for the same number of bits of pointers
 Examples: Assume all the blocks are data blocks
 A) 32 bit pointers with 512 byte blocks can represent max 2,097,152 MB
 B) 32 bit pointers with 2 K (K=1024 bytes) clusters can represent
8,388,608 MB
Operating System Concepts – 10th Edition 10-11.34 Silberschatz, Galvin and Gagne ©2018
FAT
Consists of entries. Each entry contains
the address of the next block/cluster. It
is cached in memory

File A: blocks 4, 7, 2, 10, 12


File B: Blocks 6, 3, 11, 14
Disadvantages
Entire FAT table stored in memory! 4 bytes block number
Does not scale well for large files . 200 GB yields FAT table of 800
disk with 1 KB/block needs 200 million MB Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition 10-11.35
FAT Example

Operating System Concepts – 10th Edition 10-11.36 Silberschatz, Galvin and Gagne ©2018
UNIX I-node Structure
 List allocation spreads index information on disk, slowing random access
 FAT keeps
linked-list index
information in
memory but that
limits size of file
system

 I-node Idea
 inode is the UNIX FCB (file control block)
i-node contains:
 Variable level indexed allocation method File attributes + 10
direct pointers+ 3
 Direct levels of indirect
 Pointers contained in FCB pointers
 These disk block addresses refer directly to data blocks stored on
disk
 Variable level indirect index blocks
 These refer to index blocks, which store blocks Silberschatz,
of disk Galvin
addresses
Operating System Concepts – 10th Edition 10-11.37 and Gagne ©2018
The UNIX File-System Data Structures

Operating System Concepts – 10th Edition 10-11.38 Silberschatz, Galvin and Gagne ©2018
The UNIX File-System Data Structures(Cont.)
 Suppose that a file is 1MB and a block is 8KB. Then the file will have 128
blocks. The question is: how do we keep track of these 128 data blocks of
the file. We can do this by using index blocks (also called indirect blocks)
that contain pointers to other index and data blocks.
 In Unix each file or directory has inode that is 64 or 128 bytes and contains
 Attributes +
 13 pointers
 The first 10 pointers are to store the addresses of first 10 data blocks.
 The 11th pointer points to a single indirection index block, i.e. an index
block with pointers to data blocks(points to 2^10 Data blocks)
 The 12th pointer points to a double indirection index block, i.e. an
index block that points to index blocks that point to data blocks (2^20)
 The 13th pointer points to a triple indirection index block. (2^30)
 If we assume that a block is 8KB and a pointer is 8Bytes, then an index
block will contain 1K pointers. Then, it can point to 1024 data blocks. The
maximum size of a file will be
8KB*(10 + 2**10 + 2**20 + 2**30), that is more than 8TByte file size.
Operating System Concepts – 10th Edition 10-11.39 Silberschatz, Galvin and Gagne ©2018
The UNIX File-System Data Structures(Cont.)
 Access time is different at different locations in a file. Again assume
that a block is 8KB and a pointer is 8Bytes, then an index block will
contain 1K pointers
 The first 10 data blocks are accessed with a single read (the
pointers are in main memory where the inode is brought when the
file is opened). From 0 till (8*10KB - 1)
 Logical byte o or 100 or 5000 or 50239 needs single disk access.
 The next data blocks require up to two reads, one for the index
block and one for the data block. (byte addresses from 80KB till
8*1024KB -1 )
 The next data blocks require up to three reads (8MB– 8GB -1)
 The next data blocks require up to four reads (8GB-8TB)
 Clearly access time is good at the beginning of the file and gets
worse and worse as we move towards its end.
 At which index block can you find a pointer to the data record that contains
byte 100,000,000 in a file (look at the note)
Operating System Concepts – 10th Edition 10-11.40 Silberschatz, Galvin and Gagne ©2018
Block Sizes
 Larger block sizes => higher internal fragmentation.
 Not good for small files because they waste Disk space
 Smaller block sizes => Files span multiple blocks and this need multiple seeks and
rotations to read data => reduce performance.
 Thus if the allocation unit of block is too large we waste space and if it is small we waste
time
 Larger block sizes => higher disk transfer rates
 Median file size in UNIX environments ~ 1K
 Typical block sizes are of the order of 512, 1K or 2K.

Operating System Concepts – 10th Edition 10-11.41 Silberschatz, Galvin and Gagne ©2018
Directory Structure
 A directory contains zero or more entries
 One entry per file or sub-directory that resides in the directory
 Entry maps file names to location of starting block
 Each entry has file name and attributes
 In windows, each entry has
– Fname , Extension , Attributes , Time , Date , Size , First Block #
 In UNIX, each entry has
– Fname, i-node #
 Block number of first block of the file
Data Block

Operating System Concepts – 10th Edition 10-11.42 Silberschatz, Galvin and Gagne ©2018
Unix Directories

i-node contains:
File attributes + 10
direct pointers+ 3
levels of indirect
pointers
Operating System Concepts – 10th Edition 10-11.43 Silberschatz, Galvin and Gagne ©2018
Accessing a file block for \a\b
DOS(windows) UNIX
 Go to “\” FAT entry (in memory) Get “/” i-node from disk (usually
fixed, e.g. #2)
 Go to corresponding data Get block after block of “/” using
block(s) of “\” to find entry for its i-node till entry for “a” is found
“a” (gives its i-node #).
 Read 1st data block of “a” to Get i-node of “a” from disk
check if “b” present. Get block after block of “a” till
 Else, use the FAT entry to find entry for “b” is found (gives its i-
the next block of “a” and search node #)
Get i-node of “b” from disk
again for “b”, and so on.
Find out whether block you
Eventually you will find entry for
are searching for is in 1st 10
“b”.
ptrs, or 1-level or 2-level or 3-
 Read the relevant block of “b”, level indirect.
by chasing the FAT entries in Based on this you can
memory. either directly get the block,
or retrieve it after going
through the levels of
indirection.
Operating System Concepts – 10th Edition 10-11.44 Silberschatz, Galvin and Gagne ©2018
Unix Directories

Operating System Concepts – 10th Edition 10-11.45 Silberschatz, Galvin and Gagne ©2018
File Deletion

Operating System Concepts – 10th Edition 10-11.46 Silberschatz, Galvin and Gagne ©2018
End of Chapter 10
Promise is promise. What is this?
Dinosaur becomes so small!!!

Operating System Concepts – 10th Edition, Silberschatz, Galvin and Gagne ©2018

You might also like