SlideShare a Scribd company logo
1
CPU-Scheduling (Galvin)
Outline
 FILE CONCEPT
o File Attributes (Name, Identifier, Type, Location, Size, Protection, Time & Date, UserID)
o File Operations
o File Types
o File Structure
o Internal File Structure
 ACCESS METHODS
o Sequential Access
o Direct Access
o Other Access Methods
 DIRECTORY STRUCTURE
o Storage Structure
o Directory Overview
o Single-Level Directory
o Two-Level Directory
o Tree-Structured Directories
o Acyclic-Graph Directories
o General Graph Directory
 FILE-SYSTEMMOUNTING
 FILE SHARING
o Multiple Users
o Remote File Systems (The Client-Server Model, Distributed Information Systems, Failure Modes)
o Consistency Semantics (UNIX Semantics, Session Semantics, Immutable-Shared-Files Semantics)
 PROTECTION
o Types of Access
o Access Control
o Other Protection Approaches and Issues
Contents
FILE CONCEPT
File Attributes
Different OSes keeptrack ofdifferent file attributes, includingName, Identifier (e.g. inode number), Type (Text, executable, other binary, etc.),
Location (E.g., Hard drive), Size, Protection, Time & Date, User ID. Some systems give special significance to names, and particularlyextensions (.exe,
.txt, etc.), and some donot. Some extensions maybe of significance to the OS (.exe), andothers onlyto certain applications (.jpg).
File Operations
 The file ADT supports manycommonoperations:Creating a file, Writing a file, Readinga file, Repositioning withina file, Deletinga file,
Truncatinga file.
 Informationabout currentlyopenfiles is storedinan openfile table, containing for example:
2
CPU-Scheduling (Galvin)
o File pointer - records the current position inthe file, for the next reador write access.
o File-open count - How manytimes has the current file beenopened(simultaneouslybydifferent processes)andnot yet closed?
When this counter reacheszerothe file canbe removed from the table.
o Disk location of the file.
o Access rights
 Some systems provide support for file locking.
o A shared lock is for readingonly.
o An exclusive lock is for writing as well as reading.
o An advisory lock is informationalonly, andnot enforced. (A "KeepOut"
sign, whichmaybe ignored.)
o A mandatory lock is enforced. (A trulylockeddoor.) UNIXusedadvisory
locks, andWindows uses mandatorylocks.
File Types
 Windows (andsome other systems) use specialfile extensions to indicate the type
of each file. Macintoshstores a creator attribute for eachfile, according to the
program that first createdit with the create() system call. Macintoshstores a
creator attribute for eachfile, accordingto the program that first createdit withthe
create()systemcall.
File Structure
 Some files containaninternal structure, whichmayor maynot be knownto the OS. For the OS to support particular file formats increasesthe
size andcomplexityof the OS.
 UNIXtreats all files as sequences of bytes, withnofurther considerationof the internal structure. (Withthe exceptionof executable binary
programs, whichit must know how to load and findthe first executable statement, etc.)
 Macintosh files have two forks - a resource fork, and a datafork. The resource forkcontains informationrelatingto the UI, such as icons and
button images, and canbe modified independentlyof the data fork, which contains the code or data as appropriate.
Internal File Structure
 Diskfiles are accessed in units of physical blocks, typically512 bytes or some power-of-twomultiple thereof. (Larger physical disks use larger
block sizes, to keepthe range ofblock numbers withinthe range of a 32-bit integer.)
 Internallyfiles are organizedinunits oflogical units, which maybe as small as a single byte, or maybe a larger size corresponding to some
data record or structure size. The number of logical units which fit into one physical block determines its packing, and has animpact on the
amount of internal fragmentation(wasted space) that occurs. As a general rule, half a physicalblockis wastedfor eachfile, andthe larger the
block sizes the more space is lost to internalfragmentation.
ACCESS METHODS
 Sequential Access: A sequentialaccessfile emulates magnetic tape
operation, andgenerallysupports a few operations: a)readnext - read a
record andadvance the tape to the next position. b)write next - write a
record andadvance the tape to the next position. c) rewind d) skipn
records - Mayor maynot be supported. N maybe limitedto positive
numbers, or maybe limitedto +/- 1.
 Direct Access: Jump to anyrecord andread that record. Operations
supportedinclude: read n - readrecord number n. (Note an argument is
now required.) write n - write recordnumber n. (Note anargument is
now required.) jumpto recordn - couldbe 0 or the endof file. Query
current record - usedto return backto this record later. Sequential
access canbe easilyemulated using direct access. The inverse is
complicatedandinefficient.
 Other Access Methods: An indexed access scheme canbe easilybuilt ontop ofa direct access system. Verylarge files mayrequire a multi-
tieredindexingscheme, i.e. indexes of indexes. (Lot of cool and relevant content is there in the book for all chapters)
DIRECTORY STRUCTURE
 Storage Structure: A diskcanbe usedinits entiretyfor a file system. Alternativelya physical diskcanbe brokenup into multiple partitions,
slices, or mini-disks, each of which becomes a virtual diskand canhave its own filesystem. (or be usedfor raw storage, swapspace, etc.)Or,
multiple physicaldisks can be combinedintoone volume, i.e. a larger virtual disk, withits own filesystem spanning the physicaldisks.
3
CPU-Scheduling (Galvin)
 Directory Overview: Directoryoperations to be supported include: a) Search
for a file, b)Create a file (addto the directory) C) Delete a file (erase fromthe
directory) d) List a directory(possiblyorderedin different ways) e)Rename a file
(maychange sorting order) f) Traverse the file system.
 Single-Level Directory: Simple to implement, but each file must have a unique
name.
 Two-Level Directory: Each user gets their own directoryspace. File names only
need to be unique within a givenuser's directory. A master file directoryis used
to keep track of each users directory, andmust be maintained when users are
added to or removedfrom the system. A separate directoryis generallyneeded
for system(executable) files.
Systems mayor maynot allowusers to access other directoriesbesides their
own If access to other directories is allowed, thenprovision must be made to
specifythe directorybeing accessed. Ifaccessis denied, thenspecial
consideration must be made for users to run programs locatedin system
directories. A searchpath is the list of directories in whichto searchfor
executable programs, andcan be set uniquelyfor each user.
 Tree-Structured Directories: This is an obvious extensionto
the two-tiereddirectorystructure. Eachuser / processhas
the concept of a current directoryfrom whichall (relative)
searches take place. Files maybe accessedusing either
absolute pathnames (relative to the root of the tree) or
relative pathnames(relative to the current directory.)
Directories are storedthe same as anyother file in the
system, except there is a bit that identifies them as
directories, andtheyhave some specialstructure that the
OS understands.
 Acyclic-Graph Directories: When the same files needto be accessed in more thanone place inthe directorystructure (e.g. because theyare
being sharedbymore thanone user / process), it can be useful to provide anacyclic-graph structure.
UNIXprovidestwo types of links for implementing the acyclic-graph structure. A hardlink (usuallyjust called a link) involves multiple
directoryentries that bothrefer to the same file. Hardlinks are onlyvalid for ordinaryfilesinthe same filesystem. A symbolic link, that
involves a special file, containing information about where to find the linkedfile. Symbolic links maybe used to link directories and/or filesin
other filesystems, as well as ordinaryfilesinthe current filesystem. Windows onlysupports symbolic links, termedshortcuts.
Hard links require a reference count, or linkcount for each file, keeping track of howmanydirectoryentries are currently referring to this
file. Whenever one of the referencesis removedthe linkcount is reduced, andwhenit reaches zero, the diskspace canbe reclaimed.
 General-Graph Directory: If cycles are allowedinthe graphs, thenseveralproblems canarise: Search algorithms cango intoinfinite loops. One
solution is to not followlinks in searchalgorithms. (Or not to followsymbolic links, and to onlyallowsymbolic links to refer to directories.) Sub-
trees can become disconnected from the rest ofthe tree andstill not have their reference counts reducedto zero. Periodic garbage collection
is requiredto detect andresolve this problem. (chkdsk inDOS and fsck in UNIXsearch for these problems, amongothers, eventhough cycles
are not supposedto be allowedineither system. Disconnecteddisk blocks that are not markedas free are added back to the file systems with
made-upfile names, andcan usuallybe safelydeleted.).ReferFigure11.3
4
CPU-Scheduling (Galvin)
FILE SYSTEM MOUNTING
The basic idea behind mounting file systems is to combine multiple file
systems intoone large tree structure. The mount command is given a
filesystem to mount anda mount point (directory) on which to attachit.
Once a file system is mountedontoa mount point, anyfurther references
to that directoryactuallyrefer to the root of the mountedfile system. Any
files (or sub-directories)that hadbeenstored inthe mount point directory
prior to mounting the newfilesystem are nowhiddenbythe mounted
filesystem, and are no longer available. For this reason some systems only
allowmountingontoemptydirectories.
Filesystems canonlybe mountedbyroot, unless root has previously
configured certainfilesystems to be mountable ontocertainpre-
determined mount points. (E.g. root mayallow users to mount floppy
filesystems to /mnt or somethinglike it.) Anyone canrunthe mount
commandto see what filesystems are currentlymounted. Filesystems
maybe mountedread-only, or have other restrictions imposed.
The traditional Windows OS runs anextendedtwo-tier directorystructure, where the first tier of the structure separatesvolumesbydrive letters, and
a tree structure is implemented belowthat level. Macintoshruns a similar system, where eachnew volume that is found is automaticallymountedand
added to the desktop whenit is found. More recent Windows systems allow filesystems to be mountedto anydirectoryinthe filesystem, muchlike
UNIX.
FILE SHARING
 Multiple Users: On a multi-user system, more informationneeds to be stored for eachfile: The owner (user)whoowns the file, andwhocan
control its access. The group ofother user IDs that mayhave some specialaccessto the file. What access rights are afforded to the owner
(User), the Group, and to the rest of the world (the universe, a.k.a. Others.) Some systems have more complicatedaccesscontrol, allowing or
denying specific accessesto specificallynamedusers or groups.
 Remote File Systems: The advent ofthe Internet introduces issuesfor accessing files storedonremote computers The original methodwas
ftp, allowing individual filesto be transportedacross systems as needed. Ftp can be either account andpassword controlled, or anonymous,
not requiring anyuser name or password. Various forms of distributedfile systems allowremote file systems to be mountedontoa local
directorystructure, andaccessedusing normal file access commands. (The actualfiles are still transportedacrossth e network as needed,
possiblyusing ftpas the underlyingtransport mechanism.)The WWW hasmade it easyonce againto access files onremote systems without
mountingtheir filesystems, generallyusing (anonymous)ftp as the underlying file transport mechanism.
 The Client-Server Model: When one computer system remotelymounts a filesystem that is physicallylocated onanother system, the system
which physicallyowns the filesacts as a server, andthe systemwhichmounts them is the client. User IDs and gro upIDs must be consistent
across bothsystems for the systemto work properly. (I.e. this is most applicable across multiple computers managed bythe same
organization, sharedbya common groupof users.) The same computer canbe both a client anda server. (E.g. cross-linkedfile systems.). The
NFS (NetworkFile System) is a classic example of sucha system.
 Distributed Information Systems: The DomainName System, DNS, provides for a unique naming system acrossall of the Internet. Domain
names are maintainedbythe Network Information System, NIS. Microsoft's CommonInternet File System, CIFS, establishes a network login
for each user ona networked system withsharedfile access. Older Windows systems useddomains, andnewer systems (XP, 2000), use active
directories. User names must match acrossthe network for thissystemto be valid. A newer approachis the Lightweight Directory-Access
Protocol, LDAP, which providesa secure single sign-onfor all users to accessallresources ona network. Thisis a secure system which is
gaininginpopularity, andwhich has the maintenance advantage of combining authorizationinformationin one central location .
 Consistency Semantics: Consistency Semantics dealswith the consistencybetweenthe views of sharedfileson a networkedsystem. When
one user changes the file, when doother users see the changes?
PROTECTION
Files must be kept safe for reliability(against accidental damage), and protection (against deliberate malicious access.) The former is usuallymanaged
with backup copies. This section discusses the latter.
 Types of Access: The following low-level operations are oftencontrolled:
o Read - View the contents of the file
o Write - Change the contents ofthe file.
o Execute - Loadthe file onto the CPU and follow the instructions contained therein.
o Append - Add to the endof an existing file.
o Delete - Remove a file from the system.
o List -View the name andother attributes offiles onthe system.
Higher-level operations, suchas copy, cangenerallybe performedthrough combinations ofthe above.
5
CPU-Scheduling (Galvin)
 Access Control: One approach is to have complicated Access Control Lists, ACL, which specifyexactlywhat access is allowedor denied for
specific users or groups. The AFS usesthis system for distributedaccess. Control is veryfinelyadjustable, but maybe complicated, particularly
when the specific users involved are unknown. (AFSallows some wildcards, so for example all users on a certainremote system maybe
trusted, or a givenusername maybe trustedwhenaccessing fromanyremote system.)
UNIXuses a set of 9 access control bits, in three groups of three. These correspondto R, W, and Xpermissions for eachof the Owner,
Group, and Others. (See"manchmod" for full details.) The RWXbits control the following privileges for ordinaryfilesanddirectories:
bit Files Directories
R
Read (view) file
contents.
Read directory contents. Required to get a listing of the directory.
W
Write (change)
file contents.
Change directory contents. Required to create or delete files.
X
Execute file
contents as a
program.
Access detailed directory information. Required to get a long listing, or to access any specific
file in the directory. Note that if a user has X but not R permissions on a directory, they can still
access specific files, but only if they already know the name of the file they are trying to access.
In addition there are some special bits that canalsobe
applied:The set user ID (SUID)bit and/or the set group
ID (SGID) bits appliedto executable files temporarily
change the identityof whoever runs the program to
match that ofthe owner / groupof the executable
program. Thisallows users running specific programs
to have access to files (whilerunning that program) to
which theywouldnormallybe unable to access. Setting
of these twobits is usuallyrestricted to root, andmust
be done withcaution, as it introduces a potential
securityleak.
Windows adjusts files access througha simple GUI.
 Other Protection Approaches and Issues:
o Older systems which didnot originallyhave multi-user file access permissions (DOS andolder versions of Mac)must now be
retrofittedif theyare to share files ona network.
o Access to a file requires access to all the files along its pathas well. Ina cyclic directorystructure, users mayhave different access to
the same file accessedthroughdifferent paths.
o Sometimesjust the knowledge of the existence ofa file ofa certain name is a security(or privacy) concern. Hence the distinction
betweenthe R andXbits onUNIXdirectories.
AssortedContent
 XXX
To be cleared
 I
Glossary
ReadLater
Further Reading
 S
6
CPU-Scheduling (Galvin)

Grey Areas
 XXX

More Related Content

DOCX
File system interfacefinal
PDF
File system
PPT
Files concepts.53
PPT
Chapter 10 - File System Interface
PDF
ITFT_File system interface in Operating System
PPTX
directory structure and file system mounting
DOCX
Filesystemimplementationpre final-160919095849
PDF
File systems linux class 8
File system interfacefinal
File system
Files concepts.53
Chapter 10 - File System Interface
ITFT_File system interface in Operating System
directory structure and file system mounting
Filesystemimplementationpre final-160919095849
File systems linux class 8

What's hot (19)

PPT
PDF
10 File System
PPTX
File Protection
PPTX
File system Os
PPTX
File Directory Structure-R.D.Sivakumar
PPTX
File system structure
PPTX
File System Interface
PPT
PDF
Operating Systems - Implementing File Systems
PPTX
Ch11 file system implementation
PPT
Ch11 file system interface
PPT
PPTX
File System Implementation
PPTX
File management
PPT
PPTX
File System in Operating System
DOCX
File systemimplementationfinal
PPTX
FILE SYSTEMS IN WINDOWS OPERATING SYSTEMS
PDF
File management
10 File System
File Protection
File system Os
File Directory Structure-R.D.Sivakumar
File system structure
File System Interface
Operating Systems - Implementing File Systems
Ch11 file system implementation
Ch11 file system interface
File System Implementation
File management
File System in Operating System
File systemimplementationfinal
FILE SYSTEMS IN WINDOWS OPERATING SYSTEMS
File management
Ad

Viewers also liked (13)

DOCX
Processscheduling 161001112521
DOCX
Process scheduling
PDF
337 история россии. к. xvii-xixв. 10кл. проф. ур п.р. сахарова а.н-2012 -336с
DOCX
SANDEEP SK _ CV
PDF
337 поурочные разработки по русскому языку. 11кл егорова н.в. и др-2008 -400с
PDF
349 химия. 10кл. раб. тетрадь габриелян-2014 -160с
PDF
350 химия. 11кл. раб. тетрадь габриелян-2014 -192с
PDF
343 химия. 11кл. раб. тетрадь к уч. габриеляна 2014 -176с
PDF
339 химия. 10кл. раб. тетрадь к уч. габриеляна 2014 -144с
PDF
340 химия. 10кл. проф. уровень карцова, лёвкин-2011 -432с
PDF
[Azure Council Experts (ACE) 第19回定例会] Microsoft Azureアップデート情報 (2016/08/19-201...
PPTX
Carte di credito contactless: quali i rischi per la privacy e per il portaf...
DOCX
Deadlocks prefinal
Processscheduling 161001112521
Process scheduling
337 история россии. к. xvii-xixв. 10кл. проф. ур п.р. сахарова а.н-2012 -336с
SANDEEP SK _ CV
337 поурочные разработки по русскому языку. 11кл егорова н.в. и др-2008 -400с
349 химия. 10кл. раб. тетрадь габриелян-2014 -160с
350 химия. 11кл. раб. тетрадь габриелян-2014 -192с
343 химия. 11кл. раб. тетрадь к уч. габриеляна 2014 -176с
339 химия. 10кл. раб. тетрадь к уч. габриеляна 2014 -144с
340 химия. 10кл. проф. уровень карцова, лёвкин-2011 -432с
[Azure Council Experts (ACE) 第19回定例会] Microsoft Azureアップデート情報 (2016/08/19-201...
Carte di credito contactless: quali i rischi per la privacy e per il portaf...
Deadlocks prefinal
Ad

Similar to File system interface Pre Final (20)

PPTX
File System operating system operating system
PDF
File Systems
PPT
file management_osnotes.ppt
PPT
managing-the-linux-file-system_suse_.ppt
PPT
managing-the-linux-file-system________________________
PPT
Ch11 OS
 
PPT
Unit 3 chapter 1-file management
PPT
Unit 3 file management
PPT
Operating Systems - File Space Allocation
PPTX
Filesth file handling in language dile
DOCX
file management
PPTX
File Input/output, Database Access, Data Analysis with Pandas
PPT
Ch12 OS
 
PPT
Operating System - File Management concepts
PPT
various commands in linux operating systems
PPT
various commands in linux operating systems
PPTX
Chapter 12.pptx
File System operating system operating system
File Systems
file management_osnotes.ppt
managing-the-linux-file-system_suse_.ppt
managing-the-linux-file-system________________________
Ch11 OS
 
Unit 3 chapter 1-file management
Unit 3 file management
Operating Systems - File Space Allocation
Filesth file handling in language dile
file management
File Input/output, Database Access, Data Analysis with Pandas
Ch12 OS
 
Operating System - File Management concepts
various commands in linux operating systems
various commands in linux operating systems
Chapter 12.pptx

More from marangburu42 (20)

DOCX
PDF
Write miss
DOCX
Hennchthree 161102111515
DOCX
Hennchthree
DOCX
Hennchthree
DOCX
Sequential circuits
DOCX
Combinational circuits
DOCX
Hennchthree 160912095304
DOCX
Sequential circuits
DOCX
Combinational circuits
DOCX
Karnaugh mapping allaboutcircuits
DOCX
Aac boolean formulae
DOCX
Virtualmemoryfinal 161019175858
DOCX
Io systems final
DOCX
Mass storage structurefinal
DOCX
All aboutcircuits karnaugh maps
DOCX
Virtual memoryfinal
DOCX
Mainmemoryfinal 161019122029
DOCX
Virtualmemorypre final-formatting-161019022904
DOCX
Process synchronizationfinal
Write miss
Hennchthree 161102111515
Hennchthree
Hennchthree
Sequential circuits
Combinational circuits
Hennchthree 160912095304
Sequential circuits
Combinational circuits
Karnaugh mapping allaboutcircuits
Aac boolean formulae
Virtualmemoryfinal 161019175858
Io systems final
Mass storage structurefinal
All aboutcircuits karnaugh maps
Virtual memoryfinal
Mainmemoryfinal 161019122029
Virtualmemorypre final-formatting-161019022904
Process synchronizationfinal

Recently uploaded (20)

PPTX
NEET PG 2025 Pharmacology Recall | Real Exam Questions from 3rd August with D...
PPTX
anaemia in PGJKKKKKKKKKKKKKKKKHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...
PPTX
Respiratory drugs, drugs acting on the respi system
PPTX
SKIN Anatomy and physiology and associated diseases
DOCX
RUHS II MBBS Microbiology Paper-II with Answer Key | 6th August 2025 (New Sch...
PPTX
neonatal infection(7392992y282939y5.pptx
PDF
Human Health And Disease hggyutgghg .pdf
PPTX
anal canal anatomy with illustrations...
PPT
1b - INTRODUCTION TO EPIDEMIOLOGY (comm med).ppt
PDF
Handout_ NURS 220 Topic 10-Abnormal Pregnancy.pdf
PPTX
POLYCYSTIC OVARIAN SYNDROME.pptx by Dr( med) Charles Amoateng
PPTX
Note on Abortion.pptx for the student note
PDF
NEET PG 2025 | 200 High-Yield Recall Topics Across All Subjects
PPTX
Chapter-1-The-Human-Body-Orientation-Edited-55-slides.pptx
PPT
ASRH Presentation for students and teachers 2770633.ppt
PPTX
Neuropathic pain.ppt treatment managment
PPTX
DENTAL CARIES FOR DENTISTRY STUDENT.pptx
PPTX
Electromyography (EMG) in Physiotherapy: Principles, Procedure & Clinical App...
PPTX
CEREBROVASCULAR DISORDER.POWERPOINT PRESENTATIONx
PPT
Obstructive sleep apnea in orthodontics treatment
NEET PG 2025 Pharmacology Recall | Real Exam Questions from 3rd August with D...
anaemia in PGJKKKKKKKKKKKKKKKKHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...
Respiratory drugs, drugs acting on the respi system
SKIN Anatomy and physiology and associated diseases
RUHS II MBBS Microbiology Paper-II with Answer Key | 6th August 2025 (New Sch...
neonatal infection(7392992y282939y5.pptx
Human Health And Disease hggyutgghg .pdf
anal canal anatomy with illustrations...
1b - INTRODUCTION TO EPIDEMIOLOGY (comm med).ppt
Handout_ NURS 220 Topic 10-Abnormal Pregnancy.pdf
POLYCYSTIC OVARIAN SYNDROME.pptx by Dr( med) Charles Amoateng
Note on Abortion.pptx for the student note
NEET PG 2025 | 200 High-Yield Recall Topics Across All Subjects
Chapter-1-The-Human-Body-Orientation-Edited-55-slides.pptx
ASRH Presentation for students and teachers 2770633.ppt
Neuropathic pain.ppt treatment managment
DENTAL CARIES FOR DENTISTRY STUDENT.pptx
Electromyography (EMG) in Physiotherapy: Principles, Procedure & Clinical App...
CEREBROVASCULAR DISORDER.POWERPOINT PRESENTATIONx
Obstructive sleep apnea in orthodontics treatment

File system interface Pre Final

  • 1. 1 CPU-Scheduling (Galvin) Outline  FILE CONCEPT o File Attributes (Name, Identifier, Type, Location, Size, Protection, Time & Date, UserID) o File Operations o File Types o File Structure o Internal File Structure  ACCESS METHODS o Sequential Access o Direct Access o Other Access Methods  DIRECTORY STRUCTURE o Storage Structure o Directory Overview o Single-Level Directory o Two-Level Directory o Tree-Structured Directories o Acyclic-Graph Directories o General Graph Directory  FILE-SYSTEMMOUNTING  FILE SHARING o Multiple Users o Remote File Systems (The Client-Server Model, Distributed Information Systems, Failure Modes) o Consistency Semantics (UNIX Semantics, Session Semantics, Immutable-Shared-Files Semantics)  PROTECTION o Types of Access o Access Control o Other Protection Approaches and Issues Contents FILE CONCEPT File Attributes Different OSes keeptrack ofdifferent file attributes, includingName, Identifier (e.g. inode number), Type (Text, executable, other binary, etc.), Location (E.g., Hard drive), Size, Protection, Time & Date, User ID. Some systems give special significance to names, and particularlyextensions (.exe, .txt, etc.), and some donot. Some extensions maybe of significance to the OS (.exe), andothers onlyto certain applications (.jpg). File Operations  The file ADT supports manycommonoperations:Creating a file, Writing a file, Readinga file, Repositioning withina file, Deletinga file, Truncatinga file.  Informationabout currentlyopenfiles is storedinan openfile table, containing for example:
  • 2. 2 CPU-Scheduling (Galvin) o File pointer - records the current position inthe file, for the next reador write access. o File-open count - How manytimes has the current file beenopened(simultaneouslybydifferent processes)andnot yet closed? When this counter reacheszerothe file canbe removed from the table. o Disk location of the file. o Access rights  Some systems provide support for file locking. o A shared lock is for readingonly. o An exclusive lock is for writing as well as reading. o An advisory lock is informationalonly, andnot enforced. (A "KeepOut" sign, whichmaybe ignored.) o A mandatory lock is enforced. (A trulylockeddoor.) UNIXusedadvisory locks, andWindows uses mandatorylocks. File Types  Windows (andsome other systems) use specialfile extensions to indicate the type of each file. Macintoshstores a creator attribute for eachfile, according to the program that first createdit with the create() system call. Macintoshstores a creator attribute for eachfile, accordingto the program that first createdit withthe create()systemcall. File Structure  Some files containaninternal structure, whichmayor maynot be knownto the OS. For the OS to support particular file formats increasesthe size andcomplexityof the OS.  UNIXtreats all files as sequences of bytes, withnofurther considerationof the internal structure. (Withthe exceptionof executable binary programs, whichit must know how to load and findthe first executable statement, etc.)  Macintosh files have two forks - a resource fork, and a datafork. The resource forkcontains informationrelatingto the UI, such as icons and button images, and canbe modified independentlyof the data fork, which contains the code or data as appropriate. Internal File Structure  Diskfiles are accessed in units of physical blocks, typically512 bytes or some power-of-twomultiple thereof. (Larger physical disks use larger block sizes, to keepthe range ofblock numbers withinthe range of a 32-bit integer.)  Internallyfiles are organizedinunits oflogical units, which maybe as small as a single byte, or maybe a larger size corresponding to some data record or structure size. The number of logical units which fit into one physical block determines its packing, and has animpact on the amount of internal fragmentation(wasted space) that occurs. As a general rule, half a physicalblockis wastedfor eachfile, andthe larger the block sizes the more space is lost to internalfragmentation. ACCESS METHODS  Sequential Access: A sequentialaccessfile emulates magnetic tape operation, andgenerallysupports a few operations: a)readnext - read a record andadvance the tape to the next position. b)write next - write a record andadvance the tape to the next position. c) rewind d) skipn records - Mayor maynot be supported. N maybe limitedto positive numbers, or maybe limitedto +/- 1.  Direct Access: Jump to anyrecord andread that record. Operations supportedinclude: read n - readrecord number n. (Note an argument is now required.) write n - write recordnumber n. (Note anargument is now required.) jumpto recordn - couldbe 0 or the endof file. Query current record - usedto return backto this record later. Sequential access canbe easilyemulated using direct access. The inverse is complicatedandinefficient.  Other Access Methods: An indexed access scheme canbe easilybuilt ontop ofa direct access system. Verylarge files mayrequire a multi- tieredindexingscheme, i.e. indexes of indexes. (Lot of cool and relevant content is there in the book for all chapters) DIRECTORY STRUCTURE  Storage Structure: A diskcanbe usedinits entiretyfor a file system. Alternativelya physical diskcanbe brokenup into multiple partitions, slices, or mini-disks, each of which becomes a virtual diskand canhave its own filesystem. (or be usedfor raw storage, swapspace, etc.)Or, multiple physicaldisks can be combinedintoone volume, i.e. a larger virtual disk, withits own filesystem spanning the physicaldisks.
  • 3. 3 CPU-Scheduling (Galvin)  Directory Overview: Directoryoperations to be supported include: a) Search for a file, b)Create a file (addto the directory) C) Delete a file (erase fromthe directory) d) List a directory(possiblyorderedin different ways) e)Rename a file (maychange sorting order) f) Traverse the file system.  Single-Level Directory: Simple to implement, but each file must have a unique name.  Two-Level Directory: Each user gets their own directoryspace. File names only need to be unique within a givenuser's directory. A master file directoryis used to keep track of each users directory, andmust be maintained when users are added to or removedfrom the system. A separate directoryis generallyneeded for system(executable) files. Systems mayor maynot allowusers to access other directoriesbesides their own If access to other directories is allowed, thenprovision must be made to specifythe directorybeing accessed. Ifaccessis denied, thenspecial consideration must be made for users to run programs locatedin system directories. A searchpath is the list of directories in whichto searchfor executable programs, andcan be set uniquelyfor each user.  Tree-Structured Directories: This is an obvious extensionto the two-tiereddirectorystructure. Eachuser / processhas the concept of a current directoryfrom whichall (relative) searches take place. Files maybe accessedusing either absolute pathnames (relative to the root of the tree) or relative pathnames(relative to the current directory.) Directories are storedthe same as anyother file in the system, except there is a bit that identifies them as directories, andtheyhave some specialstructure that the OS understands.  Acyclic-Graph Directories: When the same files needto be accessed in more thanone place inthe directorystructure (e.g. because theyare being sharedbymore thanone user / process), it can be useful to provide anacyclic-graph structure. UNIXprovidestwo types of links for implementing the acyclic-graph structure. A hardlink (usuallyjust called a link) involves multiple directoryentries that bothrefer to the same file. Hardlinks are onlyvalid for ordinaryfilesinthe same filesystem. A symbolic link, that involves a special file, containing information about where to find the linkedfile. Symbolic links maybe used to link directories and/or filesin other filesystems, as well as ordinaryfilesinthe current filesystem. Windows onlysupports symbolic links, termedshortcuts. Hard links require a reference count, or linkcount for each file, keeping track of howmanydirectoryentries are currently referring to this file. Whenever one of the referencesis removedthe linkcount is reduced, andwhenit reaches zero, the diskspace canbe reclaimed.  General-Graph Directory: If cycles are allowedinthe graphs, thenseveralproblems canarise: Search algorithms cango intoinfinite loops. One solution is to not followlinks in searchalgorithms. (Or not to followsymbolic links, and to onlyallowsymbolic links to refer to directories.) Sub- trees can become disconnected from the rest ofthe tree andstill not have their reference counts reducedto zero. Periodic garbage collection is requiredto detect andresolve this problem. (chkdsk inDOS and fsck in UNIXsearch for these problems, amongothers, eventhough cycles are not supposedto be allowedineither system. Disconnecteddisk blocks that are not markedas free are added back to the file systems with made-upfile names, andcan usuallybe safelydeleted.).ReferFigure11.3
  • 4. 4 CPU-Scheduling (Galvin) FILE SYSTEM MOUNTING The basic idea behind mounting file systems is to combine multiple file systems intoone large tree structure. The mount command is given a filesystem to mount anda mount point (directory) on which to attachit. Once a file system is mountedontoa mount point, anyfurther references to that directoryactuallyrefer to the root of the mountedfile system. Any files (or sub-directories)that hadbeenstored inthe mount point directory prior to mounting the newfilesystem are nowhiddenbythe mounted filesystem, and are no longer available. For this reason some systems only allowmountingontoemptydirectories. Filesystems canonlybe mountedbyroot, unless root has previously configured certainfilesystems to be mountable ontocertainpre- determined mount points. (E.g. root mayallow users to mount floppy filesystems to /mnt or somethinglike it.) Anyone canrunthe mount commandto see what filesystems are currentlymounted. Filesystems maybe mountedread-only, or have other restrictions imposed. The traditional Windows OS runs anextendedtwo-tier directorystructure, where the first tier of the structure separatesvolumesbydrive letters, and a tree structure is implemented belowthat level. Macintoshruns a similar system, where eachnew volume that is found is automaticallymountedand added to the desktop whenit is found. More recent Windows systems allow filesystems to be mountedto anydirectoryinthe filesystem, muchlike UNIX. FILE SHARING  Multiple Users: On a multi-user system, more informationneeds to be stored for eachfile: The owner (user)whoowns the file, andwhocan control its access. The group ofother user IDs that mayhave some specialaccessto the file. What access rights are afforded to the owner (User), the Group, and to the rest of the world (the universe, a.k.a. Others.) Some systems have more complicatedaccesscontrol, allowing or denying specific accessesto specificallynamedusers or groups.  Remote File Systems: The advent ofthe Internet introduces issuesfor accessing files storedonremote computers The original methodwas ftp, allowing individual filesto be transportedacross systems as needed. Ftp can be either account andpassword controlled, or anonymous, not requiring anyuser name or password. Various forms of distributedfile systems allowremote file systems to be mountedontoa local directorystructure, andaccessedusing normal file access commands. (The actualfiles are still transportedacrossth e network as needed, possiblyusing ftpas the underlyingtransport mechanism.)The WWW hasmade it easyonce againto access files onremote systems without mountingtheir filesystems, generallyusing (anonymous)ftp as the underlying file transport mechanism.  The Client-Server Model: When one computer system remotelymounts a filesystem that is physicallylocated onanother system, the system which physicallyowns the filesacts as a server, andthe systemwhichmounts them is the client. User IDs and gro upIDs must be consistent across bothsystems for the systemto work properly. (I.e. this is most applicable across multiple computers managed bythe same organization, sharedbya common groupof users.) The same computer canbe both a client anda server. (E.g. cross-linkedfile systems.). The NFS (NetworkFile System) is a classic example of sucha system.  Distributed Information Systems: The DomainName System, DNS, provides for a unique naming system acrossall of the Internet. Domain names are maintainedbythe Network Information System, NIS. Microsoft's CommonInternet File System, CIFS, establishes a network login for each user ona networked system withsharedfile access. Older Windows systems useddomains, andnewer systems (XP, 2000), use active directories. User names must match acrossthe network for thissystemto be valid. A newer approachis the Lightweight Directory-Access Protocol, LDAP, which providesa secure single sign-onfor all users to accessallresources ona network. Thisis a secure system which is gaininginpopularity, andwhich has the maintenance advantage of combining authorizationinformationin one central location .  Consistency Semantics: Consistency Semantics dealswith the consistencybetweenthe views of sharedfileson a networkedsystem. When one user changes the file, when doother users see the changes? PROTECTION Files must be kept safe for reliability(against accidental damage), and protection (against deliberate malicious access.) The former is usuallymanaged with backup copies. This section discusses the latter.  Types of Access: The following low-level operations are oftencontrolled: o Read - View the contents of the file o Write - Change the contents ofthe file. o Execute - Loadthe file onto the CPU and follow the instructions contained therein. o Append - Add to the endof an existing file. o Delete - Remove a file from the system. o List -View the name andother attributes offiles onthe system. Higher-level operations, suchas copy, cangenerallybe performedthrough combinations ofthe above.
  • 5. 5 CPU-Scheduling (Galvin)  Access Control: One approach is to have complicated Access Control Lists, ACL, which specifyexactlywhat access is allowedor denied for specific users or groups. The AFS usesthis system for distributedaccess. Control is veryfinelyadjustable, but maybe complicated, particularly when the specific users involved are unknown. (AFSallows some wildcards, so for example all users on a certainremote system maybe trusted, or a givenusername maybe trustedwhenaccessing fromanyremote system.) UNIXuses a set of 9 access control bits, in three groups of three. These correspondto R, W, and Xpermissions for eachof the Owner, Group, and Others. (See"manchmod" for full details.) The RWXbits control the following privileges for ordinaryfilesanddirectories: bit Files Directories R Read (view) file contents. Read directory contents. Required to get a listing of the directory. W Write (change) file contents. Change directory contents. Required to create or delete files. X Execute file contents as a program. Access detailed directory information. Required to get a long listing, or to access any specific file in the directory. Note that if a user has X but not R permissions on a directory, they can still access specific files, but only if they already know the name of the file they are trying to access. In addition there are some special bits that canalsobe applied:The set user ID (SUID)bit and/or the set group ID (SGID) bits appliedto executable files temporarily change the identityof whoever runs the program to match that ofthe owner / groupof the executable program. Thisallows users running specific programs to have access to files (whilerunning that program) to which theywouldnormallybe unable to access. Setting of these twobits is usuallyrestricted to root, andmust be done withcaution, as it introduces a potential securityleak. Windows adjusts files access througha simple GUI.  Other Protection Approaches and Issues: o Older systems which didnot originallyhave multi-user file access permissions (DOS andolder versions of Mac)must now be retrofittedif theyare to share files ona network. o Access to a file requires access to all the files along its pathas well. Ina cyclic directorystructure, users mayhave different access to the same file accessedthroughdifferent paths. o Sometimesjust the knowledge of the existence ofa file ofa certain name is a security(or privacy) concern. Hence the distinction betweenthe R andXbits onUNIXdirectories. AssortedContent  XXX To be cleared  I Glossary ReadLater Further Reading  S