File Systems in Operating Systems

1
Chapter 10
 File Systems: Interface
L
a
s
t
 
U
p
d
a
t
e
:
 
A
p
r
i
l
 
1
0
,
 
2
0
1
7
Bilkent University 
Department of Computer Engineering
CS342 Operating Systems
2
O
b
j
e
c
t
i
v
e
s
 
a
n
d
 
O
u
t
l
i
n
e
O
B
J
E
C
T
I
V
E
S
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
O
U
T
L
I
N
E
File Concept
Access Methods
Directory Structure
File-System Mounting
File Sharing
Protection
3
F
i
l
e
 
C
o
n
c
e
p
t
file
file
file
file
file
Users
Hard
Disk
CD
USB Disk
file
tape
We just think and use 
files 
when we
want to store 
something
(logical storage unit)
Applications/Processes
Mobile
disk
floppy disk
 
Operating System and its
File System component
4
F
i
l
e
 
C
o
n
c
e
p
t
Hard
Disk
Disk
Driver
File System 
Sub-System
File System Interface
Blocks
Files
Sectors, etc.
Processes
OS
mapping
5
F
i
l
e
 
C
o
n
c
e
p
t
Contiguous logical address space
(a storage)
Content:
Data
numeric
character
binary
Program
file
sequence of bytes 
or records
0
size-1
offset 
(address)
User
s (processes
) view of 
a file 
6
F
i
l
e
 
S
t
r
u
c
t
u
r
e
None - sequence of words, bytes
Simple record structure
Lines
Fixed length records
Variable length records
Complex Structures
Formatted document
Relocatable executable file
 
Can simulate last two with first method by inserting appropriate control
characters
Who decides:
Operating system
Program
7
F
i
l
e
 
A
t
t
r
i
b
u
t
e
s
N
a
m
e
 
 
o
n
l
y
 
i
n
f
o
r
m
a
t
i
o
n
 
k
e
p
t
 
i
n
 
h
u
m
a
n
-
r
e
a
d
a
b
l
e
 
f
o
r
m
I
d
e
n
t
i
f
i
e
r
 
 
u
n
i
q
u
e
 
t
a
g
 
(
n
u
m
b
e
r
)
 
i
d
e
n
t
i
f
i
e
s
 
f
i
l
e
 
w
i
t
h
i
n
 
f
i
l
e
 
s
y
s
t
e
m
T
y
p
e
 
 
n
e
e
d
e
d
 
f
o
r
 
s
y
s
t
e
m
s
 
t
h
a
t
 
s
u
p
p
o
r
t
 
d
i
f
f
e
r
e
n
t
 
t
y
p
e
s
L
o
c
a
t
i
o
n
 
 
p
o
i
n
t
e
r
 
t
o
 
f
i
l
e
 
l
o
c
a
t
i
o
n
 
o
n
 
d
e
v
i
c
e
S
i
z
e
 
 
c
u
r
r
e
n
t
 
f
i
l
e
 
s
i
z
e
P
r
o
t
e
c
t
i
o
n
 
 
c
o
n
t
r
o
l
s
 
w
h
o
 
c
a
n
 
d
o
 
r
e
a
d
i
n
g
,
 
w
r
i
t
i
n
g
,
 
e
x
e
c
u
t
i
n
g
T
i
m
e
,
 
d
a
t
e
,
 
a
n
d
 
u
s
e
r
 
i
d
e
n
t
i
f
i
c
a
t
i
o
n
 
 
d
a
t
a
 
f
o
r
 
p
r
o
t
e
c
t
i
o
n
,
 
s
e
c
u
r
i
t
y
,
 
a
n
d
 
u
s
a
g
e
m
o
n
i
t
o
r
i
n
g
Information about files are kept in the directory structure, which is maintained
on the disk
8
F
i
l
e
s
 
a
n
d
 
D
i
r
e
c
t
o
r
i
e
s
There are two basic things that are stored on disk as part of the area
controlled by the file system
 
- files (store content)
 
- directory information: keeps info about files, their attributes or locations; help
user to organize files
Disk
file
file
File (content)
attrs
attrs
attrs
filename
Directory
filename
filename
9
F
i
l
e
 
O
p
e
r
a
t
i
o
n
s
F
i
l
e
 
i
s
 
a
n
 
a
b
s
t
r
a
c
t
 
d
a
t
a
 
t
y
p
e
C
o
m
m
o
n
 
O
p
e
r
a
t
i
o
n
s
 
t
h
a
t
 
a
r
e
 
s
u
p
p
o
r
t
e
d
 
b
y
 
t
h
e
 
O
p
e
r
a
t
i
n
g
 
S
y
s
t
e
m
:
Create
Write
Read
Reposition within file
Delete
Truncate
Open(F
i
)
 – search the directory structure on disk for entry for  
F
i
, and move the
content of the entry to memory
Close (F
i
)
 – move the content of entry for  
F
i
 in memory to directory structure
on disk
10
O
p
e
n
 
F
i
l
e
File 
X
X
Loc/attr
OS
Process
X
Loc/attr
 
open
Open file table
Directory 
structure
R
A
M
D
i
s
k
11
O
p
e
n
 
F
i
l
e
s
Several pieces of data are needed to manage open files:
File position pointer
:  pointer to last read/write location, per process that
has the file open
File-open count
: number of times a file is open – to allow removal of data
from open-file table when last process closes it
Disk location of the file
: cache of data access information
Access mode
: per-process access mode information (in which mode the
process opened the file).
12
O
p
e
n
 
f
i
l
e
 
i
n
f
o
r
m
a
t
i
o
n
File on Disk (user
s view)
File pointer
Access Rights
File Location
File-Open count
File pointer
Access Rights
File pointer
Access Rights
File pos. pointer
Access Mode
File pointer
Access Rights
File pos. pointer
Access Mode
Per process 
Open file table
Per process 
Open file table
System wide open file table
File Location
File-Open count
File Location
File-Open count
File Location
File-Open count
File pointer
Access Rights
File pointer
Access Rights
File pos. pointer
Access Mode
Byte 0
Process
Process
Process
Main 
memory
13
F
i
l
e
 
L
o
c
k
i
n
g
Provided by some operating systems and file systems
Mediates access to a file
Mandatory or advisory:
M
a
n
d
a
t
o
r
y
 
 
a
c
c
e
s
s
 
i
s
 
d
e
n
i
e
d
 
d
e
p
e
n
d
i
n
g
 
o
n
 
l
o
c
k
s
 
h
e
l
d
 
a
n
d
 
r
e
q
u
e
s
t
e
d
A
d
v
i
s
o
r
y
 
 
p
r
o
c
e
s
s
e
s
 
c
a
n
 
f
i
n
d
 
s
t
a
t
u
s
 
o
f
 
l
o
c
k
s
 
a
n
d
 
d
e
c
i
d
e
 
w
h
a
t
 
t
o
 
d
o
14
F
i
l
e
 
C
o
n
t
e
n
t
 
T
y
p
e
s
15
A
c
c
e
s
s
 
M
e
t
h
o
d
s
S
e
q
u
e
n
t
i
a
l
 
A
c
c
e
s
s
  
read next
  
write next
  
reset
  
no read after last write
   
(rewrite)
D
i
r
e
c
t
 
A
c
c
e
s
s
  
read 
n
  
write 
n
  
position to 
n
   
read next
   
write next
  
rewrite 
n
 
n
 = relative block number
16
S
e
q
u
e
n
t
i
a
l
-
a
c
c
e
s
s
 
F
i
l
e
17
S
i
m
u
l
a
t
i
o
n
 
o
f
 
S
e
q
u
e
n
t
i
a
l
 
A
c
c
e
s
s
 
o
n
 
D
i
r
e
c
t
-
a
c
c
e
s
s
 
F
i
l
e
18
E
x
a
m
p
l
e
 
o
f
 
I
n
d
e
x
 
a
n
d
 
R
e
l
a
t
i
v
e
 
F
i
l
e
s
19
D
i
s
k
 
S
t
r
u
c
t
u
r
e
Disk can be subdivided into 
partitions
Partitions also known as minidisks, slices
Disks or partitions can be RAID protected against failure
Disk or partition can be used raw – without a file system, or formatted with a
file system.
Entity (partition or disk or multiple disks) containing a file system is known as a
Volume.
Each volume has a 
Directory 
or 
Volume Table of Contents, 
that keeps track of
and organizes files. 
There may be many  
general-purpose 
file systems (e.g., NTFS) and also many
special-purpose file systems 
(e.g., /procfs) all within the same operating
system or computer.
20
A
 
T
y
p
i
c
a
l
 
F
i
l
e
-
s
y
s
t
e
m
 
O
r
g
a
n
i
z
a
t
i
o
n
21
D
i
r
e
c
t
o
r
y
 
S
t
r
u
c
t
u
r
e
A collection of entries containing information about files and
organizing the files.
F 1
F 2
F 3
F 4
F n
Directory
Files
Both the directory structure and the files reside on disk
Backups of these two structures are kept on tapes
filename
file content (data)
22
O
p
e
r
a
t
i
o
n
s
 
P
e
r
f
o
r
m
e
d
 
o
n
 
D
i
r
e
c
t
o
r
y
Search
 for a file
Given 
filename
, find out the corresponding 
directory entry
Create
 a file (add a new entry into the directory)
Delete
 a file (remove the related entry from directory)
Rename
 a file (change the name in the respective directory entry)
List
 a directory
List the names of all files in that directory. For each file, more information
may be printed out.
Traverse
 the file system
Starting from root directory, go though all directory entries, including the
subdirectories and their entries, recursively.
23
O
r
g
a
n
i
z
e
 
t
h
e
 
D
i
r
e
c
t
o
r
y
 
(
L
o
g
i
c
a
l
l
y
)
t
o
 
O
b
t
a
i
n
Goals:
Efficiency
 – locating a file quickly
Convenient
 Naming – convenient to users
Two users can have same name for different files
The same file can have several different names
Enabling 
Grouping
 – logical grouping of files by properties, (e.g., all Java
programs, all games, …)
24
S
i
n
g
l
e
-
L
e
v
e
l
 
D
i
r
e
c
t
o
r
y
A single directory for all users
Naming problem
Grouping problem
25
T
w
o
-
L
e
v
e
l
 
D
i
r
e
c
t
o
r
y
Separate directory for each user
n
Path name
n
Can have the same file name for different user
n
Efficient searching
n
No grouping capability
26
T
r
e
e
-
S
t
r
u
c
t
u
r
e
d
 
D
i
r
e
c
t
o
r
i
e
s
27
T
r
e
e
-
S
t
r
u
c
t
u
r
e
d
 
D
i
r
e
c
t
o
r
i
e
s
 
(
C
o
n
t
)
Efficient searching
A 
pathname 
indicates where a file is. Parse the pathname and follow
those subdirectories indicated in the pathname
/usr/home/ali/projects/cs342/file.txt
Grouping Capability
Current directory 
(
working directory
)
cd /spell/mail/prog
type list
28
T
r
e
e
-
S
t
r
u
c
t
u
r
e
d
 
D
i
r
e
c
t
o
r
i
e
s
 
(
C
o
n
t
)
A
b
s
o
l
u
t
e
 
o
r
 
r
e
l
a
t
i
v
e
 
p
a
t
h
 
n
a
m
e
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
mail
prog
copy
prt
exp
count
Deleting 
mail
 

mail
29
A
c
y
c
l
i
c
-
G
r
a
p
h
 
D
i
r
e
c
t
o
r
i
e
s
Have shared subdirectories and files
shared subdirectory
shared file
30
A
c
y
c
l
i
c
-
G
r
a
p
h
 
D
i
r
e
c
t
o
r
i
e
s
 
(
C
o
n
t
.
)
Two different names (
aliasing
)
If one 
deletes
 
 dangling pointer
 
Solutions:
Backpointers (reference list), so we can delete all pointers
Variable size records a problem
Use reference count
New directory entry type
L
i
n
k
 
 
a
n
o
t
h
e
r
 
n
a
m
e
 
(
p
o
i
n
t
e
r
)
 
t
o
 
a
n
 
e
x
i
s
t
i
n
g
 
f
i
l
e
R
e
s
o
l
v
e
 
t
h
e
 
l
i
n
k
 
 
f
o
l
l
o
w
 
p
o
i
n
t
e
r
 
t
o
 
l
o
c
a
t
e
 
t
h
e
 
f
i
l
e
Shared dir or file
X
Y
Z
W
dir
dir
file
file
file
link
file
a directory
a sequence of entries
31
G
e
n
e
r
a
l
 
G
r
a
p
h
 
D
i
r
e
c
t
o
r
y
32
G
e
n
e
r
a
l
 
G
r
a
p
h
 
D
i
r
e
c
t
o
r
y
 
(
C
o
n
t
.
)
How do we guarantee 
no cycles
?
Allow only links to files not subdirectories
Every time a new link is added use a cycle detection
algorithm to determine whether it is OK (will not close loop)
Costly (especially for disk)
33
F
i
l
e
 
S
y
s
t
e
m
 
M
o
u
n
t
i
n
g
A
 
f
i
l
e
 
s
y
s
t
e
m
 
m
u
s
t
 
b
e
 
m
o
u
n
t
e
d
 
b
e
f
o
r
e
 
i
t
 
c
a
n
 
b
e
 
a
c
c
e
s
s
e
d
     (like opening a file to be read)
Mounting a 
new file system
 means placing (attaching – connecting) the new
file system into a location in the 
local directory tree
 (local file system) that
becomes accessible at system boot time.
A
n
 
u
n
m
o
u
n
t
e
d
 
f
i
l
e
 
s
y
s
t
e
m
 
i
s
 
m
o
u
n
t
e
d
 
a
t
 
a
 
m
o
u
n
t
 
p
o
i
n
t
Mount point: the place in the local directory tree where the new file system is
placed. The root of that file system will be that place in the local file system
34
(
a
)
 
E
x
i
s
t
i
n
g
.
 
 
(
b
)
 
U
n
m
o
u
n
t
e
d
 
P
a
r
t
i
t
i
o
n
Local file system
New  file system
to be mounted
35
M
o
u
n
t
 
P
o
i
n
t
mount point
36
L
o
c
a
l
 
f
i
l
e
 
s
y
s
t
e
m
 
a
p
p
e
a
r
a
n
c
e
 
a
f
t
e
r
m
o
u
n
t
i
n
g
37
F
i
l
e
 
S
h
a
r
i
n
g
Sharing of files 
on multi-user systems is desirable
S
h
a
r
i
n
g
 
m
a
y
 
b
e
 
d
o
n
e
 
t
h
r
o
u
g
h
 
a
 
p
r
o
t
e
c
t
i
o
n
 
s
c
h
e
m
e
On 
distributed systems
, files may be shared across a network
Network File System (NFS) is a common distributed file-sharing method
38
F
i
l
e
 
S
h
a
r
i
n
g
UID (user ID)
GID (group ID)
User (owner) permissions
Group permissions
Other people permissions
……
File attributes for a file
Each 
user
 that has an account in the computer has a username and a unique
user ID (
UID
)
The administrator can create groups. A 
group
 may have a set of
usernames (users) associated with it. Each group has a unique group ID (
GID
)
Example: group os_team: ali, veli, selcuk, ….
39
F
i
l
e
 
S
h
a
r
i
n
g
 
 
M
u
l
t
i
p
l
e
 
U
s
e
r
s
P
r
o
t
e
c
t
i
o
n
Protection is based on the use of UIDs and GIDs.
E
a
c
h
 
f
i
l
e
 
h
a
s
 
a
s
s
o
c
i
a
t
e
d
 
p
r
o
t
e
c
t
i
o
n
 
b
i
t
s
 
(
p
e
r
m
i
s
s
i
o
n
s
)
 
f
o
r
 
U
I
D
 
a
n
d
 
G
I
D
.
User ID: read, write, execute?
G
r
o
u
p
 
I
D
:
 
r
e
a
d
,
 
w
r
i
t
e
,
 
e
x
e
c
u
t
e
?
U
I
D
s
 
i
d
e
n
t
i
f
y
 
u
s
e
r
s
,
 
a
l
l
o
w
i
n
g
 
p
e
r
m
i
s
s
i
o
n
s
 
a
n
d
 
p
r
o
t
e
c
t
i
o
n
s
 
t
o
 
b
e
 
p
e
r
-
u
s
e
r
G
I
D
s
 
a
l
l
o
w
 
u
s
e
r
s
 
t
o
 
b
e
 
i
n
 
g
r
o
u
p
s
,
 
p
e
r
m
i
t
t
i
n
g
 
g
r
o
u
p
 
a
c
c
e
s
s
 
r
i
g
h
t
s
40
F
i
l
e
 
S
h
a
r
i
n
g
 
 
R
e
m
o
t
e
 
F
i
l
e
 
S
y
s
t
e
m
s
Uses networking to 
allow file system access between systems
Manually via programs like FTP
A
u
t
o
m
a
t
i
c
a
l
l
y
,
 
s
e
a
m
l
e
s
s
l
y
 
u
s
i
n
g
 
d
i
s
t
r
i
b
u
t
e
d
 
f
i
l
e
 
s
y
s
t
e
m
s
 
(
D
F
S
)
S
e
m
i
 
a
u
t
o
m
a
t
i
c
a
l
l
y
 
v
i
a
 
t
h
e
 
w
o
r
l
d
 
w
i
d
e
 
w
e
b
D
F
S
:
 
C
l
i
e
n
t
-
s
e
r
v
e
r
 
m
o
d
e
l
 
a
l
l
o
w
s
 
c
l
i
e
n
t
s
 
t
o
 
m
o
u
n
t
 
r
e
m
o
t
e
 
f
i
l
e
 
s
y
s
t
e
m
s
 
f
r
o
m
s
e
r
v
e
r
s
Server can serve multiple clients. Client can mount multiple servers.
Client and user-on-client identification is insecure or complicated (**)
N
F
S
 
i
s
 
s
t
a
n
d
a
r
d
 
U
N
I
X
 
c
l
i
e
n
t
-
s
e
r
v
e
r
 
f
i
l
e
 
s
h
a
r
i
n
g
 
p
r
o
t
o
c
o
l
C
I
F
S
 
i
s
 
s
t
a
n
d
a
r
d
 
W
i
n
d
o
w
s
 
p
r
o
t
o
c
o
l
Standard 
operating system file calls
 
are translated 
into 
remote calls
(
*
*
)
 
D
i
s
t
r
i
b
u
t
e
d
 
I
n
f
o
r
m
a
t
i
o
n
 
S
y
s
t
e
m
s
 
(
d
i
s
t
r
i
b
u
t
e
d
 
n
a
m
i
n
g
 
s
e
r
v
i
c
e
s
)
 
s
u
c
h
 
a
s
L
D
A
P
,
 
D
N
S
,
 
N
I
S
,
 
A
c
t
i
v
e
 
D
i
r
e
c
t
o
r
y
 
i
m
p
l
e
m
e
n
t
 
u
n
i
f
i
e
d
 
a
c
c
e
s
s
 
t
o
 
i
n
f
o
r
m
a
t
i
o
n
n
e
e
d
e
d
 
f
o
r
 
r
e
m
o
t
e
/
d
i
s
t
r
i
b
u
t
e
d
 
c
o
m
p
u
t
i
n
g
41
D
i
s
t
r
i
b
u
t
e
d
 
F
i
l
e
 
S
y
s
t
e
m
File
System A
processes
Network
Computer A
VFS
localFS
NFS
File
System B
processes
Computer B
VFS
localFS
NFS
File
System C
processes
Computer C
VFS
localFS
NFS
42
D
i
s
t
r
i
b
u
t
e
d
 
F
i
l
e
 
S
y
s
t
e
m
File
System A
processes
Computer A
File
System C
File
System B
mount point
File System view at computer A after remote file systems are mounted
43
F
i
l
e
 
S
h
a
r
i
n
g
 
 
F
a
i
l
u
r
e
 
M
o
d
e
s
Remote file systems add 
new failure modes
, due to network failure, server
failure
How to recover from failures?
Recovery from failure can involve 
state information 
(to be maintained at
server)  about 
status of each remote request
State information: what files are opened; what is the file position pointer,
etc.
44
F
i
l
e
 
S
h
a
r
i
n
g
 
 
C
o
n
s
i
s
t
e
n
c
y
 
S
e
m
a
n
t
i
c
s
C
o
n
s
i
s
t
e
n
c
y
 
s
e
m
a
n
t
i
c
s
 
s
p
e
c
i
f
y
 
h
o
w
 
m
u
l
t
i
p
l
e
 
u
s
e
r
s
 
a
r
e
 
t
o
 
a
c
c
e
s
s
 
a
 
s
h
a
r
e
d
f
i
l
e
 
s
i
m
u
l
t
a
n
e
o
u
s
l
y
Unix file system (UFS) implements:
Writes to an open file visible immediately to other users of the same
open file
A single file image accessed by all users
AFS has session semantics
Writes only visible to sessions starting after the file is closed
Multiple file images accessed by all users
45
P
r
o
t
e
c
t
i
o
n
File owner/creator should be able to control:
what
 can be done (read, write, execute….)
by 
whom
 (owner, others, group member…)
Types of access 
(what can be done)
Read (a file)
Write (a file)
Execute (a file)
Append (a file)
Delete ( a file)
List (a file)
For directories:
Reading means listing
Writing means being able to create a file
Executing means being able to change into the directory
46
A
c
c
e
s
s
 
L
i
s
t
s
 
a
n
d
 
G
r
o
u
p
s
Mode of access:  read, write, execute
Three classes of users
     
RWX
a
)
 
o
w
n
e
r
 
a
c
c
e
s
s
 
7
1
 
1
 
1
R
W
X
b
)
 
g
r
o
u
p
 
a
c
c
e
s
s
 
6
1
 
1
 
0
     
RWX
c
)
 
p
u
b
l
i
c
 
a
c
c
e
s
s
1
0
 
0
 
1
Ask manager to create a group (unique name), say G, and add
some users to the group.
For a particular file (say 
game
) or subdirectory, define an
appropriate access.
owner
group
public
chmod
761
game
Attach a group to a file
 
         chgrp     G    game
47
W
i
n
d
o
w
s
 
X
P
 
A
c
c
e
s
s
-
c
o
n
t
r
o
l
 
L
i
s
t
M
a
n
a
g
e
m
e
n
t
48
A
 
S
a
m
p
l
e
 
U
N
I
X
 
D
i
r
e
c
t
o
r
y
 
L
i
s
t
i
n
g
49
R
e
f
e
r
e
n
c
e
s
The slides here are adapted/modified from the textbook and its slides:
Operating System Concepts, Silberschatz  et al., 7th & 8th editions,  Wiley.
Operating System Concepts,, Silberschatz et al. Wiley.
Modern Operating Systems, Andrew S. Tanenbaum, 3
rd
 edition, 2009.
Slide Note
Embed
Share

File systems are essential components of operating systems that manage the organization, storage, and retrieval of files. This content explores the function of file systems, their interfaces, design tradeoffs, file concepts, attributes, and structures. It covers topics such as access methods, directory structures, file sharing, protection mechanisms, and more.

  • File Systems
  • Operating Systems
  • Interface
  • File Concepts
  • File Attributes

Uploaded on Dec 12, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Bilkent University Department of Computer Engineering CS342 Operating Systems Chapter 10 File Systems: Interface Last Update: April 10, 2017 1

  2. Objectives and Outline 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 OUTLINE File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection 2

  3. File Concept We just think and use files when we want to store something (logical storage unit) Users Applications/Processes file file file Operating System and its File System component file file file floppy disk Hard Disk Mobile disk USB Disk CD tape 3

  4. File Concept Processes Files File System Interface mapping File System Sub-System Blocks Disk Driver OS Hard Disk Sectors, etc. 4

  5. File Concept 0 Contiguous logical address space (a storage) Content: Data numeric character binary Program offset (address) sequence of bytes or records file size-1 User s (processes ) view of a file 5

  6. File Structure None - sequence of words, bytes Simple record structure Lines Fixed length records Variable length records Complex Structures Formatted document Relocatable executable file Can simulate last two with first method by inserting appropriate control characters Who decides: Operating system Program 6

  7. File Attributes 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 Information about files are kept in the directory structure, which is maintained on the disk 7

  8. Files and Directories There are two basic things that are stored on disk as part of the area controlled by the file system - files (store content) - directory information: keeps info about files, their attributes or locations; help user to organize files Disk attrs file Directory file attrs filename filename filename attrs File (content) 8

  9. File Operations File is an abstract data type Common Operations that are supported by the Operating System: Create Write Read Reposition within file Delete Truncate Open(Fi) search the directory structure on disk for entry for Fi, and move the content of the entry to memory Close (Fi) move the content of entry for Fi in memory to directory structure on disk 9

  10. Open File Process RAM OS Open file table X Loc/attr Disk open Directory structure File X X Loc/attr 10

  11. Open Files Several pieces of data are needed to manage open files: File position pointer: pointer to last read/write location, per process that has the file open File-open count: number of times a file is open to allow removal of data from open-file table when last process closes it Disk location of the file: cache of data access information Access mode: per-process access mode information (in which mode the process opened the file). 11

  12. Open file information Process Process Process File pointer Access Rights Per process Open file table File pointer Access Rights File pointer Access Rights File pointer Access Rights Access Mode File pointer Access Rights Access Mode File pointer Access Rights Access Mode File pos. pointer File pos. pointer File pos. pointer Per process Open file table File Location File-Open count File Location File-Open count File-Open count File-Open count File Location File Location Main memory System wide open file table File on Disk (user s view) Byte 0 12

  13. File Locking Provided by some operating systems and file systems Mediates access to a file Mandatory or advisory: Mandatory access is denied depending on locks held and requested Advisory processes can find status of locks and decide what to do 13

  14. File Content Types 14

  15. Access Methods Sequential Access Direct Access n = relative block number read next write next reset no read after last write (rewrite) read n write n position to n rewrite n read next write next 15

  16. Sequential-access File 16

  17. Simulation of Sequential Access on Direct- access File 17

  18. Example of Index and Relative Files 18

  19. Disk Structure Disk can be subdivided into partitions Partitions also known as minidisks, slices Disks or partitions can be RAID protected against failure Disk or partition can be used raw without a file system, or formatted with a file system. Entity (partition or disk or multiple disks) containing a file system is known as a Volume. Each volume has a Directory or Volume Table of Contents, that keeps track of and organizes files. There may be many general-purpose file systems (e.g., NTFS) and also many special-purpose file systems (e.g., /procfs) all within the same operating system or computer. 19

  20. A Typical File-system Organization 20

  21. Directory Structure A collection of entries containing information about files and organizing the files. filename Directory file content (data) Files F 4 F 2 F 1 F 3 F n Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes 21

  22. Operations Performed on Directory Search for a file Given filename, find out the corresponding directory entry Create a file (add a new entry into the directory) Delete a file (remove the related entry from directory) Rename a file (change the name in the respective directory entry) List a directory List the names of all files in that directory. For each file, more information may be printed out. Traverse the file system Starting from root directory, go though all directory entries, including the subdirectories and their entries, recursively. 22

  23. Organize the Directory (Logically) to Obtain Goals: Efficiency locating a file quickly Convenient Naming convenient to users Two users can have same name for different files The same file can have several different names Enabling Grouping logical grouping of files by properties, (e.g., all Java programs, all games, ) 23

  24. Single-Level Directory A single directory for all users Naming problem Grouping problem 24

  25. Two-Level Directory Separate directory for each user Path name Can have the same file name for different user Efficient searching No grouping capability n n n n 25

  26. Tree-Structured Directories 26

  27. Tree-Structured Directories (Cont) Efficient searching A pathname indicates where a file is. Parse the pathname and follow those subdirectories indicated in the pathname /usr/home/ali/projects/cs342/file.txt Grouping Capability Current directory (working directory) cd /spell/mail/prog type list 27

  28. Tree-Structured Directories (Cont) Absolute or relative path name 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 mail prog copy prt exp count Deleting mail deleting the entire subtree rooted by mail 28

  29. Acyclic-Graph Directories Have shared subdirectories and files shared file shared subdirectory 29

  30. Acyclic-Graph Directories (Cont.) Y X Z Two different names (aliasing) If one deletes dangling pointer Solutions: Backpointers (reference list), so we can delete all pointers Variable size records a problem Use reference count Shared dir or file W New directory entry type Link another name (pointer) to an existing file Resolve the link follow pointer to locate the file a sequence of entries a directory dir dir file file file link file 30

  31. General Graph Directory 31

  32. General Graph Directory (Cont.) How do we guarantee no cycles? Allow only links to files not subdirectories Every time a new link is added use a cycle detection algorithm to determine whether it is OK (will not close loop) Costly (especially for disk) 32

  33. File System Mounting A file system must be mounted before it can be accessed (like opening a file to be read) Mounting a new file system means placing (attaching connecting) the new file system into a location in the local directory tree (local file system) that becomes accessible at system boot time. An unmounted file system is mounted at a mount point Mount point: the place in the local directory tree where the new file system is placed. The root of that file system will be that place in the local file system 33

  34. (a) Existing. (b) Unmounted Partition Local file system New file system to be mounted 34

  35. Mount Point mount point 35

  36. Local file system appearance after mounting 36

  37. File Sharing Sharing of files on multi-user systems is desirable Sharing may be done through a protection scheme On distributed systems, files may be shared across a network Network File System (NFS) is a common distributed file-sharing method 37

  38. File Sharing Each user that has an account in the computer has a username and a unique user ID (UID) The administrator can create groups. A group may have a set of usernames (users) associated with it. Each group has a unique group ID (GID) Example: group os_team: ali, veli, selcuk, . File attributes for a file UID (user ID) GID (group ID) User (owner) permissions Group permissions Other people permissions 38

  39. File Sharing Multiple Users Protection Protection is based on the use of UIDs and GIDs. Each file has associated protection bits (permissions) for UID and GID. User ID: read, write, execute? Group ID: read, write, execute? UIDs identify users, allowing permissions and protections to be per-user GIDs allow users to be in groups, permitting group access rights 39

  40. File Sharing Remote File Systems Uses networking to allow file system access between systems Manually via programs like FTP Automatically, seamlessly using distributed file systems (DFS) Semi automatically via the world wide web DFS: Client-server model allows clients to mount remote file systems from servers Server can serve multiple clients. Client can mount multiple servers. Client and user-on-client identification is insecure or complicated (**) NFS is standard UNIX client-server file sharing protocol CIFS is standard Windows protocol 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/distributed computing 40

  41. Distributed File System Computer B processes VFS Computer C Computer A localFS NFS processes processes File VFS VFS System B localFS NFS localFS NFS File File Network System C System A 41

  42. Distributed File System File System view at computer A after remote file systems are mounted Computer A processes File mount point System A File File System C System B 42

  43. File Sharing Failure Modes Remote file systems add new failure modes, due to network failure, server failure How to recover from failures? Recovery from failure can involve state information (to be maintained at server) about status of each remote request State information: what files are opened; what is the file position pointer, etc. 43

  44. File Sharing Consistency Semantics Consistency semantics specify how multiple users are to access a shared file simultaneously Unix file system (UFS) implements: Writes to an open file visible immediately to other users of the same open file A single file image accessed by all users AFS has session semantics Writes only visible to sessions starting after the file is closed Multiple file images accessed by all users 44

  45. Protection File owner/creator should be able to control: whatcan be done (read, write, execute .) by whom(owner, others, group member ) Types of access (what can be done) Read (a file) Write (a file) Execute (a file) Append (a file) Delete ( a file) List (a file) For directories: Reading means listing Writing means being able to create a file Executing means being able to change into the directory 45

  46. Access Lists and Groups Mode of access: read, write, execute Three classes of users a) owner access b) group access c) public access Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. 7 6 1 RWX 1 1 1 RWX 1 1 0 RWX 0 0 1 owner group public chmod 761 game Attach a group to a file chgrp G game 46

  47. Windows XP Access-control List Management 47

  48. A Sample UNIX Directory Listing 48

  49. References The slides here are adapted/modified from the textbook and its slides: Operating System Concepts, Silberschatz et al., 7th & 8th editions, Wiley. Operating System Concepts,, Silberschatz et al. Wiley. Modern Operating Systems, Andrew S. Tanenbaum, 3rd edition, 2009. 49

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#