KEMBAR78
Advanced Operating Systems - 3 | PDF | File System | Computer File
0% found this document useful (0 votes)
32 views50 pages

Advanced Operating Systems - 3

Chapter 3 of the Advanced Operating Systems discusses files and file systems, covering key concepts such as file metadata, naming systems, and typical file system operations. It explains the structure and implementation of file systems, including physical and logical aspects, as well as optimization techniques. Additionally, it outlines various file operations, directory management, and the booting process of an operating system.

Uploaded by

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

Advanced Operating Systems - 3

Chapter 3 of the Advanced Operating Systems discusses files and file systems, covering key concepts such as file metadata, naming systems, and typical file system operations. It explains the structure and implementation of file systems, including physical and logical aspects, as well as optimization techniques. Additionally, it outlines various file operations, directory management, and the booting process of an operating system.

Uploaded by

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

ADVANCED OPERATING SYSTEMS

CHAPTER -3 FILES AND FILE SYSTEMS


MASTERS IN COMPUTER SCIENCE
KEY CONCEPTS

• File
• File and I/O system levels
• File meta-data
• File naming systems
• Typical file system operations
• File system implementation
• physical and logical file system
• directory implementation
• File system structures on disk
• free blocks
• file descriptors
• mounting file systems
• location of file blocks
• variations
• Booting an OS
• File system optimization
• log-structured file systems
FILE

• A file is a sequence of bytes of arbitrary length. ( from 0 to very large


upper limit.)
• Files are implemented by operating systems to provide persistent
storage
FILE SYSTEM CONTEXT
LEVELS IN A FILE SYSTEM
TWO MAJOR PARTS OF A FILE SYSTEM

The file naming system takes a user oriented file name ( a string) an returns
a internal name for the file ( a binary number) called a file identifier.
LOGICAL STRUCTURES IN A FILE

Most operating systems implement flat files, which are essentially arrays of stored on the disk.

And the record structuring is handled by database management systems.


LEVELS OF DATA ABSTRACTION
FILE META-DATA

• File contain data and have associated meta-data


describing the file data.
• Meta-Data [ Contents of a File Descriptor/ iNode)
• name
• type of file
• size
• owner, group, and access permissions
• time of creation, last modification, last read
• where the file data is stored on disk
FILE NAMING

• Files in all modern operating systems are generally named using a hierarchical naming
system based on directories.
• A path name consists of a series of component names separated with a separator
character. Provides unique name for files. Each component is the directory named by the
path that precedes it.
• An absolute path name is the name that gives the path of the file from the root directory.
• A relative path name is the name that gives the path of the file from the current working
directory.
• Separator Character: “/” ( Slash) – Unix ; “\” ( Back-Slash) – MS DOS
• What characters are allowed to be in the name?
• How long can the name be?
Unix – upto 255 characters
Mac OS – 31 Characters
MS DOS – 11 characters
FILE NAMES

• Directory: maps component names into objects


(files or directories)
• Path name: a sequence of component names
specifying a path of directories
• absolute path: starts at the root directory
• relative path: starts at the working directory
• File name extension: suffix of a component names
that indicate the type of the file
• Alias: alternate path names for a file
- different path name, but lead to the same file
descriptors ( inode).
SOME COMMON FILE EXTENSIONS

• file.c -- a C program file


• file.txt -- a text file
• file.s -- an assembly language file
• file.obj -- an object file (in MS/DOS)
• file.o -- an object file (in UNIX)
• file.exe -- an executable file (in MS/DOS)
• file.wk1 -- spreadsheet worksheet
• file.tex -- tex or latex (a text formatter) file
• file.mif -- Framemaker interchange file
• file.scm -- Scheme program file
• file.tmp -- a temporary file
PATH NAME EXAMPLES

• /nfs/chaco/u1/Anand/os/book/ch03 -- UNIX
• book/ch03 --UNIX relative path name
• E:\u1\Anand\os\book\ch03 -- MS/DOS
• Users:u1:Anand:os:book:ch03 -- Macintosh
• chaco:[Anand/os/book]ch03 -- VMS
FILE NAME SPACE TOPOLOGIES
FILE SYSTEM OBJECTS

File system implements 3 objects:

Files : that hold persistent data


Open Files: that allow access to files
Directories: that name the files
FILE OPERATIONS IN UNIX

• openFile = open(file name)


• openFile = create(file name)
• deleteFile =delete(file name)
• fileMetaData = status(file name)
• okay = access(file name, access type)
• okay = change mode(file name, new mode)
• changes protection information
• okay = change owner(file name,new owner)
OPEN FILE OPERATIONS IN UNIX

• bytesRead = read(open file)


• bytesWritten = write(open file)
• newFilePos = seek(open file, how much, how) --
move file position
• close(open file)
• Seek ( open file, file pointer)
• openFile = duplicate(open file)
• fileLock(open file)
• fileControl(open file)
• twoOpenFiles = pipe()
DIRECTORY OPERATIONS IN UNIX

• link(file name, alias name)


• unlink(file name): delete file
• rename(old name, new name)
• makeDirectory(directory name)
• removeDirectory(directory name)
FILE SYSTEM IMPLEMENTATION

FILE SYSTEM DATA STRUCTURES


FLOW OF CONTROL FOR AN OPEN
FLOW OF CONTROL FOR A READ
CONNECTING FILES AND DEVICES THROUGH DEVICE SWITCH
SPECIAL FILES

• Special files are not ordinary files


• e.g. directories, devices, pipes, message queues,
remote files, mounted directories, etc.
• They are marked by flags in the file descriptor
• The read and write operations are directed to code
for that type of special file
• a case statement determines how to handle a read or
write operation
FORK DATA STRUCTURE CHANGES
PATH NAME
LOOKUP
ALGORITHM
FILE SYSTEMS

• File system: a data structure on a disk that holds


files
• actually a file system is in a disk partition
• a technical term different from a “file system” as the
part of the OS that implements files
• File systems in different OSs have different internal
structures
A FILE SYSTEM LAYOUT

Boot block – Boot sector/ program used to boot the OS


File System Descriptor – Also called as Super Block
File descriptors – List of all iNodes
File Data Blocks – Actual Data of Files
FILE SYSTEM DESCRIPTOR

• The data structure that defines the file system


• Typical fields
• size of the file system (in blocks)
• size of the file descriptor area
• first block in the free block list
• location of the file descriptor of the root directory of
the file system
• times the file system was created, last modified, and
last used
FREE LIST ORGANIZATION
FILE SYSTEM LAYOUT VARIATIONS

• MS/DOS uses a FAT (file allocation table) file system


• so does the Macintosh OS (although the MacOS layout is different)
• New UNIX file systems use cylinder groups (mini-file systems) to
achieve better locality of file data
MOUNTING FILE SYSTEMS

• Each file system has a root directory


• We can combine file systems by mounting
• that is, link a directory in one file system to the root
directory of another file system
• This allows us to build a single tree out of several
file systems
• This can also be done across a network, mounting
file systems on other machines
MOUNTING A FILE SYSTEM
LOCATING FILE DATA

• The logical file is divided into logical blocks


• Each logical block is mapped to a physical disk
block
• The file descriptor contains data on how to
perform this mapping
• there are many methods for performing this mapping
• we will look at several of them
DIVIDING A FILE INTO BLOCKS
A CONTIGUOUS FILE
EXTENDING CONTIGUOUS FILES
KEEPING A FILE IN PIECES

• We need a block pointer for each logical block, an array of block


pointers
• block mapping indexes into this array
• But where do we keep this array?
• usually it is not kept as contiguous array
• the array of disk pointers is like a second related file (that is 1/1024 as big)
BLOCK POINTERS IN THE FILE DESCRIPTOR
BLOCK POINTERS IN CONTIGUOUS DISK BLOCKS
BLOCK POINTERS IN THE BLOCKS
BLOCK POINTERS IN AN INDEX BLOCK
CHAINED INDEX BLOCKS
TWO-LEVEL INDEX BLOCKS
THE UNIX HYBRID METHOD
INVERTED DISK BLOCK INDEX (FAT)
DISK COMPACTION
BOOTING AN OS

1. Read in the boot block with the ROM monitor


2. Transfer control to the boot block loader
3. The book block loader finds and loads the operating system
4. Transfer control to the operating system
OPTIMIZING FILE SYSTEM PERFORMANCE

• Compact files to make them physically contiguous


on the disk
• Compress file data so it takes fewer blocks
• Use larger block sizes
• but this causes more internal fragmentation
• Log-structured file systems
• all writes at the end of the log
MULTIPLE FILE SYSTEMS

• Most OSs now have loadable file systems and


support any number of file system organizations
• File system drivers are like device drivers but
implement abstract file system operations
• Some file systems support special needs
• the file system driver can do whatever it wants (like
device drivers) and simulate various effects
MAJOR FILE SYSTEM ORGANIZATIONS

• System 5 UNIX
• Berkeley UNIX
• MS/DOS: FAT file system
• NT file system
• CD/ROM (a.k.a. high sierra)
• NFS: network file system
• Macintosh file system

You might also like