Professional Documents
Culture Documents
CSC204 - Chapter 2.2-2019-NEW-2NOV20201
CSC204 - Chapter 2.2-2019-NEW-2NOV20201
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.
FILE
OS provides a uniform logical view of
information storage
5
Name – only information kept in human-
readable form
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
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
16
• Stores information about all files
• Both the directory structure and the files reside on disk (secondary
storage)
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
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
53
November 20
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
November 20 66
LINKED ALLOCATION
67
LINKED ALLOCATION
68
INDEXED ALLOCATION
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:
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.