You are on page 1of 76

•CHAPTER 2 : OPERATING

SYSTEM – USER VIEW


•2.2 File System
•    2.2.1 Understanding File
CSC 204: PRACTICAL System/File Concept
•    2.2.2 Access Methods
APPROACH OF •    2.2.3 Directory Structure
•    2.2.4 File System Mounting
OPERATING SYSTEMS •    2.2.5 File Sharing
•    2.2.6 File Protection
The mechanism for storing,
catalogue and retrieve set of
named files and the directory
structure into which they are
organised.
FILE
SYSTEM In modern operating systems
where it is possible for several
user to access the same files
simultaneously, it has also
become necessary for such
features as access control and
different forms of file protection
to be implemented.

November 20 2
A typical file system consists of:
• Collection of Files
File contains related data
• Metadata (Directory Structure)
FILE
Organizes & provides
SYSTEM information about all files in the
system
• Partitions
Separates physically or logically
large collections of directories

3
TYPICAL FILE SYSTEM
4
A file is a collection of (binary, numeric or
character) data. A file could represent a
program, a document or in some cases part
of the file system itself.

Can be stored on various storage media

FILE
OS provides a uniform logical view of
information storage

OS abstracts from the physical properties of its


storage devices to define a logical storage unit, FILE.

Files are mapped by the OS onto physical


devices

All files have a name by which they can be


accessed by the user. In most modern file
systems the name consists of three parts, its
unique name, a period and an extension.

5
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

FILE Location – pointer to file location on device

ATTRIBUTES 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
6
• Create
• Space in the file system must be
found for the file
• Entry for the new file must be
made in the directory
FILE ◎Write - System call specifying the
OPERATIO name of the file and the
information to be written. System
N keeps a pointer to the location
where the next write is to take
place

7
…FILE OPERATION

• Read
• System call specifying the name of the
file and where the next block of the
file should be put.
• A process is either reading from a file
or writing to a file, the current
operation location can be kept as per
process “current-file-position” pointer
• Both read and write operations. Use
this same pointer to save space &
system complexity

8
…FILE OPERATION

Reposition Delete – Search Truncate – Open(Fi) – Close (Fi) –


within file – file the directory for Erases the search the move the
seek the names file, content of a file directory content of entry
Current file
release all file but keeps its structure on Fi in memory to
position pointer
space, and attributes disk for entry Fi, directory
is repositioned to
erase the and move the structure on
a given value.
directory entry content of entry disk.
Need not involve
an actual I/O to memory.

November 20 9
• Appending
• Renaming
• Copy
…FILE • Move
OPERATIO
N

10
…FILE
TYPES

11
• Files contain information
• Information must be accessed
and read into memory for
FILE processing
ACCESS • Sequential Access
METHOD • Direct Access

November 20 12
SEQUENTIAL
FILE ACCESS
• Different file systems also support
different access methods.
• The simplest method of accessing
information in a file is sequential
access. 
• Method of retrieving data from a
storage device in an ordered
sequence. This is where the
information in a file is accessed
from the beginning one record at
a time. 

November 20 13
• The device must read or move
through all information up to the
point it is attempting to read or write
to.
• A tape drive (tape magnetic) is an
example of a sequential access drive,
where the drive must move the tape
…SEQUENTIAL forward or backward until it reaches
FILE ACCESS its destination.
• Although this method is very simple in
its operation and ideally suited for
certain tasks such as playing media it
is very inefficient for more complex
tasks such as database management.

14
15
November 20

DIRECT ACCESS • Direct access allows records to be read or written


over in any order the application requires.
• Allow any part of the drive to be read in any
order with little reduction in transfer rate.
• Direct access is better suited to most applications
than sequential access
SEQUENTIAL
VS DIRECT
ACCESS

16
• Stores information about all files
• Both the directory structure and the files reside on disk (secondary
storage)

DIRECTORY • Contains file’s name and identifier


• Identifier in turn locates other file attributes
STRUCTURE • More than 1KB of information for each file
• Directory structure size in MBs
• Backups of files and directory structure kept on tapes

17
INFORMATION
IN A • Name
DIRECTORY • Type
• Address
• Current length
• Maximum length
• Date last accessed
• Date last updated
• Owner ID
• Protection information 18
• List a directory
• Search for a file
• Create a file
• Delete a file
OPERATIONS
PERFORMED • Rename a file
ON DIRECTORY • Traverse the file system (able to
view ALL the files & directory is
the OS. E.g – MSDOS uses the dir
command)

19
• Efficiency – locating a file
quickly.
• Naming – convenient to users.
ORGANIZE • Two users can have same name for
THE different files.
DIRECTORY • The same file can have several
different names.
(LOGICALLY)
• Grouping – logical grouping of
TO OBTAIN files by properties, (e.g., all Java
programs, all games, …)

20
• Schemes for defining the logical
structure of a directory:
HOW TO 1.Single level directory
ORGANIZE 2.Two level directory
A 3.Tree structured directory
DIRECTORY 4.Acyclic graph directory
5.General graph directory

November 20 21
• A single directory for all users.
SINGLE-LEVEL • Naming problem
DIRECTORY • Grouping problem

22
• Separate directory for each user.
• Has path name
TWO-LEVEL
• Can have the same file name for different
DIRECTORY user
• Efficient searching
• No grouping capability
23
• In two-level directory, this tree
structure has MFD as root of path
through UFD to user file name at leaf.
• Each user has its own UFD (User File
Dir)
• UFDs have similar structure
…TWO- • When a user logs in, the MFD (Master
LEVEL File Dir) is searched
DIRECTORY • MFD is indexed by user name or
account no.
• Each entry in MFD points to a UFD
• User name and file name define a
path name

24
• When a user refers to a file, only
his own UFD is searched. This
solves the name-collision problem
Disadvantages
• What about system files?
…TWO- • Since file name would be searched
LEVEL in the current UFD only, system
files need to be copied to each
DIRECTORY UFD!!
• Standard solution: special user
directory is defined to contain
system files. Ex: user 0

25
…SYSTEM
FILES…

November 20 26
TREE-
STRUCTURED
DIRECTORIES
November 20 27
Tree-Structured Directories ..
windows
28
• Generalization of two-level
directory (with arbitrary height)
• Each user has a current directory
…TREE- (working directory)
STRUCTURED
• Can change current directory via
DIRECTORIES
cd command or system call
• Path names can be absolute or
relative

29
• If a user can WANT to access
another user’s files, then the
PATH concept of path name is needed.
NAME • Standard syntax -- /user/file.ext

30
…TREE-STRUCTURED DIRECTORIES

relative

November 20 31
…TREE-STRUCTURED DIRECTORIES

System call

November 20 32
• Advantages
…TREE- • Efficient searching
STRUCTURED
• Grouping capability
DIRECTORIES

November 20 33
…TREE-STRUCTURED DIRECTORIES -
OPERATIONS
• 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”.

November 20 34
• Have shared subdirectories and
files.

ACYCLIC-
GRAPH
DIRECTORIES

35
• A situation where two
programmers are working on a
joint project, file pertaining to
project can be stored in a
subdirectory of each user –
shared subdirectory!
ACYCLIC-
GRAPH • Tree structure prohibits the
sharing of files or directories
DIRECTORIES
• A shared file or directory will
exist in the file system in two or
more places at once
• AGD allows files and directories
to be shared
November 20 36
• Shared file is not the same as
two copies of the file
• With a shared file, only one
actual file exists
…ACYCLIC- • Shared subdirectories (SD)
GRAPH
• Files created in SD will
DIRECTORIES
automatically appear in all the
shared SDs

November 20 37
• A link – a pointer to another file
or subdirectory
• Link may be implemented as an
absolute or a relative path
• When a reference to a file is
…ACYCLIC- made, directory is searched
GRAPH
• If directory entry is marked as a
DIRECTORIES
link, name of the real file is
included in the link information
• Link is resolved using the path
name to locate the real file

November 20 38
Duplication
• Duplicate all information in both
the sharing directories
• Original and copy
indistinguishable
…ACYCLIC- • Maintaining consistency when a
GRAPH file is modified is a problem
DIRECTORIES Problems
• AGD is more flexible but more
complex
• File may have multiple absolute
path names. Different file names
refer to the same file!!
39
…ACYCLIC-GRAPH DIRECTORIES
▪ Have shared subdirectories and files using
acyclic graph
▪ Two different names exist – (aliasing
problem)
▪ Solutions:
▪ Preserve file until all references to it
are deleted => Reference count
solution

November 20 40
ACYCLIC-GRAPH DIRECTORIES

November 20 41
… ACYCLIC-GRAPH DIRECTORIES
▪ Want to avoid searching any shared
components twice
▪ Reference count solution does not hold due
to self-reference => use garbage collection
▪ Acyclic structure is much easier to work with

November 20 42
• A file system must be mounted
before it can be accessed.
• An unmounted file system is
mounted at a mount point.
FILE SYSTEM • Mounting takes place before a
MOUNTING computer can use any kind of
(OR storage device (such as a hard
drive, CD-ROM, or network share).
MAPPING) The user or their operating system
must make it accessible through
the computer's file system. A user
can only access files on mounted
media

November 20 43
File System Mounting (windows)

November 20 44
• Drive map
• Drive mapping is how operating
systems, such as Microsoft
File Windows, associate a local drive
letter (A through Z) with a shared
System storage area to another computer
over a network.
Mountin • After a drive has been mapped, a
g [Drive software application on a client's
computer can read and write files
mapping] from the shared storage area by
accessing that drive, just as if that
drive represented a local physical
hard disk drive.

November 20 45
File System Mounting [Drive
mapping]

November 20 46
…FILE SYSTEM MOUNTING
(a) Existing. (b)
Unmounted Partition

November 20 47
MOUNT POINT

November 20 48
FILE SHARING

• Sharing of files on multi-user systems is


desirable.
• Sharing may be done through a
protection scheme – owner, group,
universe.
• On distributed systems, files may be
shared across a network.
• Network File System (NFS) is a common
distributed file-sharing method.

November 20 49
• User IDs identify users, allowing
permissions and protections to
FILE- be per-user
SHARING
MULTIPLE • Group IDs allow users to be in
groups, permitting group access
USERS rights

November 20 50
• Uses networking to allow file
system access between systems
REMOTE • Manually via programs like FTP
• Automatically, seamlessly using
FILE distributed file systems
SYSTEM • Semi-automatically via the world
wide web

51
REMOTE
FILE SYSTEM

52
• Client-server model allows clients to mount remote file systems
from servers
• Server can serve multiple clients

…REMOTE • Client and user-on-client identification is insecure (spoof)


or complicated
• NFS is standard UNIX client-server file sharing protocol
FILE • CIFS is standard Windows protocol (CIFS (Common Internet
File System))

SYSTEM • Standard operating system file calls are translated into


remote calls
• Distributed Information Systems (distributed naming services)
such as LDAP, DNS, NIS, Active Directory implement unified access
to information needed for remote computing

53
November 20

FILE • File • Types of


PROTECTION owner/creato access
r should be
able to • Read
control: • Write
• what can • Execute
be done • Append
• by whom
•Delete
• List

54
ACCESS
LISTS
AND
GROUPS

55
…ACCESS LISTS AND GROUPS
• To define an appropriate access for a particular file
(ex: game) or subdirectory
chmod 761 game
7 = 111 , 6 = 110 , 1 = 001 => owner has RWX access,
group has RW access only & public has X access only.
=> drwxrw---x
• Attach a group G to a file
chgrp G game

November 20 56
WINDOWS 7 ACCESS-CONTROL LIST
MANAGEMENT

57
Final exam Q

58
LINUX ACCESS –CONTROL LIST

59
FILE ALLOCATION
• File viewed as a contiguous sequence of bytes
• Allocation is actually storing the bytes
Fragmentation types can be divided into:
• External – unusable empty space between files
• Internal – allocated but there is unused space (file
smaller than block)

60
contiguous sequence of bytes

61
External Fragmentation

62
internal Fragmentation vs
external fragmentation

63
TYPES OF FILE ALLOCATION

Contiguous Allocation

Linked Allocation

Indexed Allocation

64
CONTIGUOUS ALLOCATION

65
CONTIGUOUS ALLOCATION

• Each file occupies a set of contiguous blocks on the disk.


• Advantages:
• Simple – only starting location (block number) and length
(number of blocks) are required.
• Random access.
• Disadvantages:
• Wasteful of space (dynamic storage-allocation problem).
• Files cannot grow.

November 20 66
LINKED ALLOCATION

• Each file is a linked list of


disk blocks: blocks may be
scattered anywhere on the
disk.
• Allocate as needed, link
together; e.g., file starts at
block 9
• slow, as we have to access
each block

67
LINKED ALLOCATION

• Simple – need only starting address


• Free-space management system – no waste
of space
• No random access
• Clusters of blocks are used for better
performance (disk head moving) and to have
fewer pointers

68
INDEXED ALLOCATION

• Brings all pointers


together into the index
block.
• Need index table
• Random access
• Random access without
external fragmentation,
but have overhead of
index block.

69
COMPARISON OF ALLOCATION TYPES

70
• FAT, NTFS and EXT
• File Allocation Table (FAT) - table
that the Operating System uses to
locate files on a disk
• Due to fragmentation, a file may be
divided into many sections that are
FILE scattered around the disk. The FAT
keeps track of all these pieces.
SYSTEM - • It is divided by 3 types:

FAT, NTFS • FAT12


• FAT16
and EXT • FAT32
• FAT32 is the most advanced file
system.
• FAT32 supports smaller cluster
sizes and larger volumes than
FAT12/FAT16, which results in
more efficient space allocation on
71
FAT32 volumes.
FILE
SYSTEM -
FAT, NTFS
and EXT

72
•New Technology File System (NTFS) is a
file system that was introduced by
Microsoft in 1993 that supports HD sizes
up to 256TB.
•NTFS is the primary file system used in
FILE Microsoft's Windows 7, Windows Vista,
Windows XP, Windows 2000, Windows
SYSTEM - NT, Windows Server 2003 and Windows
Server 2008.
FAT, NTFS • NTFS allows you to gain the maximum
and EXT benefits for the needs of today’s
enterprise business environments such as
increased security, more robust and
reliable performance, as well as a design
for greater storage growth, features not
found in FAT.

73
FILE
SYSTEM -
FAT, NTFS
and EXT

74
•Extension (EXT) - A file extension are
the three until five letters at the end of
the name of a computer file.
FILE •The file extension is separated by a dot
SYSTEM - from the filename. For example: doc is
the file extension of the file
FAT, NTFS document.doc.
•The file extension indicates, which
and EXT program can open/view the file when you
double click on the filename.

75
2.2 FILE SYSTEM
2.2.4 FAT, NTFS and EXT
❑ Extension (EXT) - A file extension are the three
untill five letters at the end of the name of a
computer file.
❑ The file extension is separated by a dot from
the filename. For example: doc is the file
extension of the file document.doc.
❑ The file extension indicates, which program can
open/view the file when you double click on the
filename.

You might also like