Docsity

File Systems - Operating Systems - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download File Systems - Operating Systems - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

10: File Systems 1

OPERATING SYSTEMS

FILE SYSTEMS

10: File Systems 2

FILE SYSTEMS

This material covers Silberschatz Chapters 10 and 11.

File System Interface

The user level (more visible) portion of the file system.

  • Access methods
  • Directory Structure
  • Protection

File System Implementation

The OS level (less visible) portion of the file system.

  • Allocation and Free Space Management
  • Directory Implementation

10: File Systems 4

FILE SYSTEMS INTERFACE

A file can have various kinds of structure

 None - sequence of words, bytes

  • Simple record structure
    • Lines
    • Fixed length
    • Variable length
  • Complex Structures
    • Formatted document
    • Relocatable load file
  • Who interprets this structure?
    • Operating system
    • Program

File

Concept

10: File Systems 5

FILE SYSTEMS INTERFACE

Attributes of a File

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 is kept in the directory structure, which is

maintained on the disk.

File

Concept

10: File Systems 7

FILE SYSTEMS INTERFACE

Note: The command “LDE” – Linux Disk Editor – does amazing things but requires root privilege.

-rw-rw-rw- 1 jbreecherusers 56243 Mon Dec 18 14:25:40 2006

TYPE: regular file LINKS: 1 DIRECT BLOCKS= 0x002462CA MODE: \0666 FLAGS: \10 0x002462CB UID: 01170(jbreecher)ID: 00100(users) 0x002462CC SIZE: 56243 SIZE(BLKS): 128 0x002462CD 0x002462CE ACCESS TIME: Mon Dec 18 14:35:35 2006 0x002462CF CREATION TIME: Mon Dec 18 14:25:40 2006 0x002462D MODIFICATION TIME: Mon Dec 18 14:25:40 2006 0x002462D DELETION TIME: Wed Dec 31 19:00:00 1969 0x002462D 0x002462D 0x002462D 0x002462D INDIRECT BLOCK= 0x002462D 2x INDIRECT BLOCK= 3x INDIRECT BLOCK=

File

Concept

Expanded on next page

10: File Systems 8

FILE SYSTEMS INTERFACE

lde v2.6.1 : ext2 : /dev/mapper/VolGroup00-LogVol Inode: 1170636 (0x0011DCCC) Block: 2384586 ( 0x002462CA ) 0123456789!@$%^ 462CA000 74 68 69 73 20 6D 61 6E : 79 20 6E 6F 74 20 77 6F this many not wo 462CA010 72 6B 20 74 68 69 73 20 : 6D 61 6E 79 20 6E 6F 74 rk this many not 462CA020 20 77 6F 72 6B 20 74 68 : 69 73 20 6D 61 6E 79 20 work this many 462CA030 6E 6F 74 20 77 6F 72 6B : 20 74 68 69 73 20 6D 61 not work this ma 462CA040 6E 79 20 6E 6F 74 20 77 : 6F 72 6B 20 74 68 69 73 ny not work this 462CA050 20 6D 61 6E 79 20 6E 6F : 74 20 77 6F 72 6B 0A 74 many not work.t 462CA060 68 69 73 20 6D 61 6E 79 : 20 6E 6F 74 20 77 6F 72 his many not wor

File

Concept

lde v2.6.1 : ext2 : /dev/mapper/VolGroup00-LogVol Inode: 1170636 (0x0011DCCC) Block: 2384598 ( 0x002462D6 ) 0123456789!@$%^ 462D6000 D7 62 24 00 D8 62 24 00 : 00 00 00 00 00 00 00 00 .b$..b$......... 462D6010 00 00 00 00 00 00 00 00 : 00 00 00 00 00 00 00 00 ................ 462D6020 00 00 00 00 00 00 00 00 : 00 00 00 00 00 00 00 00 ................

10: File Systems 10

If files had only one "chunk" of data, life would be simple. But for large files,

the files themselves may contain structure, making access faster.

SEQUENTIAL ACCESS

  • Implemented by the filesystem.
  • Data is accessed one record right after the last.
  • Reads cause a pointer to be moved ahead by one.
  • Writes allocate space for the record and move the pointer to the new

End Of File.

  • Such a method is reasonable for tape

FILE SYSTEMS INTERFACE

Access

Methods

10: File Systems 11

DIRECT ACCESS

  • Method useful for disks.
  • The file is viewed as a numbered sequence of blocks or records.
  • There are no restrictions on which blocks are read/written in any order.
  • User now says "read n" rather than "read next".
  • "n" is a number relative to the beginning of file, not relative to an absolute

physical disk location.

FILE SYSTEMS INTERFACE Access Methods

10: File Systems 13

Example 1: Index contains the name appearing as the first record in each block. There are as many index entries as there are blocks.

Example 2: Index contains the block number where "A" begins, where "B" begins, etc. Here there are only 26 index entries.

FILE SYSTEMS INTERFACE

Access

Methods

Smith

Smith, John | data

Adams Arthur Asher

Saarnin

Smith, John | data

Adams Baker Charles

Adams | Data Arthur | Data Asher | Data Baker | Data

Saarnin | data

10: File Systems 14

Directories maintain information about files:

For a large number of files, may want a directory structure - directories under directories.

Information maintained in a directory:

Name The user visible name. Type The file is a directory, a program image, a user file, a link, etc. Location Device and location on the device where the file header is located. Size Number of bytes/words/blocks in the file. Position Current next-read/next-write pointers. Protection Access control on read/write/ execute/delete. Usage Open count Usage time of creation/access, etc. Mounting a filesystem occurs when the root of one filesystem is "grafted" into the existing tree of another filesystem.

There is a need to PROTECT files and directories.

Actions that might be protected include: read, write, execute, append, delete, list

FILE SYSTEMS INTERFACE Directory Structure

In Memory only!

10: File Systems 16

Tree-Structured Directory

FILE SYSTEMS INTERFACE Directory Structure

10: File Systems 17

Mounting:

Attaching portions of the file system into a directory structure.

Sharing:

  • Sharing must be done through a protection scheme
  • May use networking to allow file system access between systems
    • Manually via programs like FTP or SSH
    • Automatically, seamlessly using distributed file systems
    • Semi automatically via the world wide web
  • Client-server model allows clients to mount remote file systems from servers
    • Server can serve multiple clients
    • 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

FILE SYSTEMS INTERFACE Other Issues

10: File Systems 19

FILE SYSTEMS INTERFACE Protection

Example on

Windows XP

10: File Systems 20

FILE SYSTEM IMPLEMENTATION

FILE SYSTEM STRUCTURE:

When talking about “the file system”, you are making a statement about both the rules used for file access, and about the algorithms used to implement those rules. Here’s a breakdown of those algorithmic pieces. Application Programs The code that's making a file request.

Logical File System This is the highest level in the OS; it does protection, and security. Uses the directory structure to do name resolution.

File-organization Module Here we read the file control block maintained in the directory so we know about files and the logical blocks where information about that file is located.

Basic File System Knowing specific blocks to access, we can now make generic requests to the appropriate device driver.

IO Control These are device drivers and interrupt handlers. They cause the device to transfer information between that device and CPU memory.

Devices The disks / tapes / etc.