Chapter 11: FileSystem Interface - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 11: FileSystem Interface

Description:

Operations (usually from within a program, ie., function calls): Create. Write. Read ... Make 'raw' files on a device part of a directory tree. ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 31
Provided by: marily189
Category:

less

Transcript and Presenter's Notes

Title: Chapter 11: FileSystem Interface


1
Chapter 11 File-System Interface
  • File Concept
  • Access Methods
  • Directory Structure
  • File System Mounting
  • File Sharing
  • ProtectionAnnotated for use with Silberschatzs
    book used during CS350, Fall 03Instructor's
    annotation in Blue Last updated 4/25/03, 11/30/03

2
File Concept
  • Collection of related data
  • Contiguous logical address space mapped onto
    physical device by OS, but presents a view
    (interface) to an application which is
    independent of any deviceusually non-volatile
  • Users view smallest allotment of logical
    secondary storage.From a user viewpoint data
    cannot be written to secondary storage unless it
    is in a file
  • Sequence of bytes, bits, lines, or records file
    has a structure defined by file type
    interpretation depends on OS and/or application
  • Type or extension usually indicates meaning of
    contents
  • Data
  • numeric
  • character, ex rat.txt - text file
  • binary, ex rat.xls - spread sheet, application
    supported
  • Program, ex rat.exe - executable module, OS
    supported

3
File Structure
The internal representation of the data
  • None - sequence of words, bytes
  • Simple record structure
  • Lines
  • Fixed length
  • Variable length
  • Complex Structures
  • Formatted document
  • Relocatable load file
  • Can simulate last two with first method by
    inserting appropriate control characters - ex MS
    Word documents.
  • Who decides (you mean support? - see previous
    slide)
  • Operating system
  • Program

4
File Attributes
  • Name only information kept in human-readable
    form.
  • Identifier - a machine readable field
    corresponding to the name - typically a number
  • 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.

5
File Operations
  • File is an abstract data type - operation are
    associated with file type, p. 373Operations
    (usually from within a program, ie., function
    calls)
  • Create
  • Write
  • Read
  • Reposition within file file seek
  • Delete
  • Truncate
  • Open(Fi) search the directory structure on disk
    for entry Fi, and move the content of entry to
    memory - to the open file table, attributes of
    file is pointed to by a file descriptor or
    handle returned by open call. The open file
    table is not searched it is directly accessed via
    the file descriptor. Open file table is like a
    cache for the directory.
  • Close (Fi) move the content of entry Fi in
    memory to directory structure on disk (if
    modified?).

6
File Types Name, Extension
Big questions Who supports file extensions
(types)? support is shared by OS and the
application varies according to the OS Also
who supports the file structure (internal format,
logical records, etc OS or application? OS
minimally supports executable files. UNIX
provides only minimal OS support. Internal file
structure Mapping the logical record size to the
physical block (sector) is the problem here. See
sect 11.1.5
7
Access Methods
  • Sequential Access- Tape model must sequentially
    move thru file- no insertion of records,
    append at end- can read anywhere by searching
    from beginning for record- Current position (cp)
    pointer indicates next record to be accessed-
    write append to end of file read next , cp
  • write next , cp
  • reset , cp 0
  • no read after last write (beyond EOF)
  • Direct Access- Disk model random access of
    fixed blocks- File is seen as numbered series of
    fixed length logical blocks or records that allow
    programs to read/write records in no particular
    order.- R/W records in no particular order
  • read n
  • write n
  • position to n
  • read next //simulation of sequential
  • write next
  • rewrite n
  • n relative block number

8
Sequential-access File
9
Simulation of Sequential Access on a
Direct-access File simulation of direct access
on sequential more difficult
10
Example of Index access methods and Relative Files
- Build on top of direct access - must search
index and then directly access via disk pointer
(or convert relative block number to a physical
disk address) - index written on disk and copied
to memory (cache ) - can have multilevel index
tables, index the index table - sound familiar? -
Index will get you to a physical block containing
the logical record (relatively small logical
records packed in a larger physical block (ex
sector) - FAT access method (used on PC) related
to this idea, and ISAM on IBM mainframes.
11
Directory Structure
  • A collection of nodes containing information
    about all files.
  • A way of locating files on the disk- by name IBM
    mainframe buzz word Volume Table of Contents
    (VTOC)
  • Contains access information about the file such
    as name, location, size, type, etc. Example do
    ls -l -a on UNIX

Directory
This example shows the one minimal feature of a
directory, namely relating file names to their
locations.
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.
12
A Typical File-system Organization
Organize disk into partitions (minidisks as per
IBM mainframes) - Each with its own directory -
files and directories stored in partitions -
Partitions appear as a logical disk to user - may
be larger that a disk for multiple disk systems
(Ex RAID) - Ideally user is oblivious to
partition management and sees only disk drives.
Typical for PCs
Example for a RAID system
13
Information in a Device (say disk) Directory
  • Name
  • Type
  • Address pointer to, or indicator of physical
    location of file generally not visible to the
    user the main guts of the entry.
  • Current length
  • Maximum length
  • Date last accessed (for archival)
  • Date last updated (for dump)
  • Owner ID (who pays)
  • Protection information (discuss later)
  • Check this stuff on UNIX doing ls -l -a
  • Must minimally have name and address

14
Operations Performed on Directory
  • Search for a file
  • Create a file
  • Delete a file
  • List a directory
  • Rename a file
  • Traverse the file system

15
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,
    )

16
Single-Level Directory- some history
  • Directories originally set up for multi-user
    systems
  • A single directory for all users.

Cat,bo, are file names
lt--Actual data for files
  • Naming problemJust a list of all users files
    names must be unique - problem
  • with duplicate names
  • Grouping problem difficult to organize files

17
Two-Level Directory-some modern history
  • Separate directory for each user - solves
    duplicate name problem.
  • Example IBM VM system - each user (on a
    different virtual machine) had a single level
    directory
  • Path name
  • Can have the same file name for different user
  • Efficient searching
  • No grouping capability

18
Tree-Structured Directories - what we have today
Does it all introduces the concept of a
folder - can have folders within folders
(folders is a Windows buzz word)names in the
directory entry are file names OR the names of
other directories - the idea is from UNIX
19
Tree-Structured Directories (Cont.)
  • Efficient searching -can quickly skip to desired
    subdirectory before searching for data files
  • Grouping Capability easy to organize files
  • Current directory (working directory)
  • cd /spell/mail/prog
  • type list

20
Tree-Structured Directories (Cont.)
  • Absolute (from root) or relative (from current
    directory) path name
  • suppose your home directory on UNIX is
    /u0/users/0/cs350, and inder cs350 you have a
    subdirctoryproject containing an executable rw.
    Executing rw from cs350 can be done as
    /u0/users/0/cs350/project/rw - specify absolute
    pathor. /project/rw - use relative path (.
    means current dirctory)
  • Creating a new file is done in current directory.
  • Delete a file
  • rm ltfile-namegt
  • Creating a new subdirectory is done in current
    directory.
  • mkdir ltdir-namegt
  • Example if in current directory /mail
  • mkdir count

mail
prog
copy
prt
exp
count
Deleting mail ? deleting the entire subtree
rooted by mail. In UNIX rm -rf mail
recursively clears all subdirectories - a
dangerous command!
21
Acyclic-Graph Directories
  • Have shared subdirectories and files lt key
    idea.
  • In UNIX this is the symbolic link - powerful
    method for sharing files among large groups of
    users over a network. Uses path name to shared
    file.
  • Can have distinct different file names for same
    file alias
  • Must ensure that there are no cycles in the graph

22
Acyclic-Graph Directories (Cont.)
  • Shared file may have two different names
    (aliasing)
  • When could a shared file be deleted?
  • If dict deletes list ? dangling pointer (see
    prev. slide).
  • Solutions
  • Backpointers, so we can delete all
    pointers.Variable size records a problem.
  • Backpointers using a daisy chain organization.
  • Entry-hold-count solution. - remove file only
    when all references to it are gone -
    increment/decrement count.
  • Two problems to avoid in acyclic graphs
  • dangling pointers - UNIX if shared file deleted,
    leave all symbolic links - leave it up to the
    user to handles these links
  • avoid cycles when adding links - cycles detection.

23
General Graph Directory gtgtgtomitltltlt
24
General Graph Directory (Cont.) gtgtgtomitltltlt
  • How do we guarantee no cycles?
  • Allow only links to file not subdirectories.
  • Garbage collection.
  • Every time a new link is added use a cycle
    detectionalgorithm to determine whether it is OK.

25
File System Mounting
  • Mounting Associating data (or file) on a device
    to a directory to a directory/file system in
    user space. Make raw files on a device part of
    a directory tree.
  • A file system must be mounted before it can be
    accessed.
  • The directory structure can be built out of
    multiple partitions/disks (or from multiple
    devices, or remote networked machines), which
    must be mounted to make them available within
    the file system name space
  • A unmounted file system is mounted at a mount
    point within the directory tree.

26
Existing. (b) Unmounted Partition
27
Mount Point
New FS mounted over previous directory subtree
at users and would obscure previous tree.
Better create another subdirectory under users
to be the mount point. See pp 394-395.
28
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.
  • On UNIX - remote file systems would be mounted

29
Protection
  • File owner/creator should be able to control
  • what can be done
  • by whom
  • Types of access
  • Read
  • Write
  • Execute
  • Append
  • Delete
  • List

30
Access Lists and Groups
  • Mode of access read, write, execute
  • Three classes of users
  • RWX
  • a) owner access 7 ? 1 1 1 RWX
  • b) group access 6 ? 1 1 0
  • RWX
  • c) public access 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
Write a Comment
User Comments (0)
About PowerShow.com