File Management, file system - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

File Management, file system

Description:

File system organized into layers. File control block storage structure consisting of information about a file. 3 ... Truncate ... – PowerPoint PPT presentation

Number of Views:815
Avg rating:3.0/5.0
Slides: 42
Provided by: patt207
Category:

less

Transcript and Presenter's Notes

Title: File Management, file system


1
File Management, file system
2
File-System Structure
  • File structure
  • Logical storage unit
  • Collection of related information
  • File system resides on secondary storage (disks)
  • File system organized into layers
  • File control block storage structure consisting
    of information about a file

3
Model of I/O organization
Logical I/O
Basic File System
Basic I/O Supervisor file I/O initiation and
termination scheduling access to optimize
performance
4
File System I/O and Software Architecture
Basic File System physical I/O, placement,
buffering of blocks
Logical I/O Enables programs to access records
provides general-purpose record I/O capability
maintains basic data about file
Basic I/O Supervisor file I/O initiation and
termination scheduling access to optimize
performance
create,delete open, close, read, write, append,
seek get-attributes, set-attributes
5
File Structure
  • Some kinds of files
  • byte sequence
  • record sequence
  • tree

6
File Operations
  • File is an abstract data type
  • Create
  • Write
  • Read
  • Reposition within file
  • Delete
  • Truncate
  • Open(Fi) search the directory structure on disk
    for entry Fi, and move the content of entry to
    memory
  • Close (Fi) move the content of entry Fi in
    memory to directory structure on disk

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

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

9
More access methods Indexed File
  • Index provides lookup capability
  • Contains key field and a pointer to the main file
  • May be exhaustive or partial index
  • Scheme may use multiple indexes for different key
    fields
  • new records are added to an overflow file
    structure

10
More access methods The Hashed File
  • Directly access a block at a known address
    (using, e.g. modulo operation on the main key)

11
A Typical File-system Organization
A.T. MOS fig of same concept
12
Directory Structure
  • A collection of nodes containing information
    about all files

Directory
Files
F 1
F 2
F 3
F 4
F n
Both the directory structure and the files reside
on disk Backups of these two structures are kept
on tapes
13
Operations Performed on Directory
  • Search for a file
  • Create a file
  • Delete a file
  • List a directory
  • Rename a file
  • Traverse the file system

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

15
Single-Level Directory
  • A single directory for all users

Naming problem Grouping problem
16
Two-Level Directory
  • Separate directory for each user
  • Path name
  • Can have the same file name for different user
  • Efficient searching
  • Limited grouping capability

17
Tree-Structured Directories
  • (sub)directory a file
  • Grouping Capability
  • Current directory (working directory)
  • cd /spell/mail/prog
  • type list
  • Absolute or relative path name

18
Acyclic-Graph Directories
  • shared subdirectories and files
  • Two different names (aliasing)
  • w deletes list ? dangling ptr Solutions
  • Backpointers, so we can delete all pointers
    -Variable size records a problem
  • Entry-hold-count solution
  • New directory entry type
  • Link another name (pointer) to an existing file
  • Resolve the link follow pointer to locate the
    file

19
Open Files
  • Several pieces of data are needed to manage open
    files
  • File pointer pointer to last read/write
    location, per process that has the file open
  • File-open count counter of number of times a
    file is open to allow removal of data from
    open-file table when last processes closes it
  • Disk location of the file cache of data access
    information
  • Access rights per-process access mode information

20
In-Memory File System Structures
fd
FCBs
21
File System Mounting
  • A file system must be mounted before it can be
    accessed
  • file system is mounted at a mount point

22
File Sharing
  • allow files to be shared among users
  • issues
  • Access rights
  • Management of simultaneous access

23
Access Rights (managed by owner)
  • Knowledge User can only determine that the file
    exists and who its owner is
  • Execute user can load and execute a program but
    cannot copy it
  • Read user can read the file
  • Append user can add data to the file but cannot
    modify/delete contents
  • Update user can modify, deleted, and add to the
    files data.
  • Change protection user can change access rights
    granted to other users

24
Domain Structure, Access Matrices
  • Access-right ltobject-name, rights-setgt
  • rights-set a subset of all valid operations on
    the object.
  • For a process in Di to do op on object Oj, op
    must be in the access matrix.
  • Can be expanded to dynamic protection.
  • Operations to add, delete access rights.
  • Special access rights
  • owner of Oi
  • copy op from Oi to Oj
  • control Di can modify Dj access rights
  • transfer switch from domain Di to Dj

25
Simultaneous Access
  • Locks
  • on entire file when it is to be updated
  • on the individual records during the update (cf
    2-phase locking in DBs)
  • OS may provide different read/write locks
  • Mutual exclusion and deadlock are issues for
    shared access

26
Open 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

27
File Sharing Consistency Semantics
  • Consistency semantics specify how multiple users
    are to access a shared file simultaneously
  • Similar to Ch 7 process synchronization
    algorithms
  • Unix file system (UFS) implements
  • Writes to an open file visible immediately to
    other users of the same open file
  • Sharing file pointer to allow multiple users to
    read and write concurrently
  • Andrew File System (AFS) implemented complex
    remote file sharing semantics
  • AFS has session semantics
  • Writes only visible to sessions starting after
    the file is closed

28
Disks
29
Secondary Storage Management
  • Space must be allocated to files
  • Must keep track of the space available for
    allocation
  • Methods of File Allocation
  • Contiguous allocation
  • External fragmentation will occur
  • Chained allocation
  • Each block contains a pointer to next block
  • No external fragmentation
  • Best for sequential files
  • Indexed allocation
  • File allocation table contains a separate
    one-level index for each file

30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
(No Transcript)
34
Combined Scheme UNIX
35
Implementing Directories (1)
  • (a) A simple directory
  • fixed size entries
  • disk addresses and attributes in directory entry
  • (b) Directory in which each entry just refers to
    an i-node

36
Implementing Directories (2)
  • Two ways of handling long file names in directory
  • (a) In-line
  • (b) In a heap

37
Discussion
  • Q how does the OS keep info on free/occupied
    disk blocks (memory frames)?
  • What if file system is distributed/network-based?

38
Free-Space Management
  • Bit vector (n blocks)

0
1
2
n-1

0 ? blocki free 1 ? blocki occupied
biti
???
Block number calculation
(number of bits per word) (number of 0-value
words) offset of first 1 bit
39
Free-Space Management (Cont.)
  • Bit map requires extra space
  • Example
  • block size 212 bytes
  • disk size 230 bytes (1 gigabyte)
  • n 230/212 218 bits (or 32K bytes)
  • Easy to get contiguous files
  • Linked list (free list)
  • Cannot get contiguous space easily
  • No waste of space

40
Schematic View of Virtual File System
41
Schematic View of NFS Architecture
  • Network interface client-server protocol
  • Uses UDP (over IP over most commonly- ethernet)
  • Mounting and caching
Write a Comment
User Comments (0)
About PowerShow.com