SlideShare una empresa de Scribd logo
1 de 55
Descargar para leer sin conexión
File Management
   Tanenbaum, Chapter 4


    COMP3231
 Operating Systems

   Leonid Ryzhyk
  Kevin Elphinstone
                          1
Outline
• Files and directories from the programmer
  (and user) perspective
• Files and directory internals – the
  operating system perspective




                                         2
Summary of the FS abstraction
           User's view                 Under the hood
Uniform namespace              Heterogeneous collection of
                               storage devices
Hierarchical structure         Flat address space
Arbitrarily-sized files        Fixed-size blocks
Symbolic file names            Numeric block addresses
Contiguous address space inside Fragmentation
a file
Access control                 No access control
Tools for
 formatting
 defragmentation
 backup
 consistency checking


                                                     3
A brief history of file systems
• Early batch processing systems
  – No OS
  – I/O from/to punch cards
  – Tapes and drums for external storage, but no FS
  – Rudimentary library support for reading/writing tapes and drums




           IBM 709 [1958]




                                                         4
A brief history of file systems
• The first file systems were
  single-level (everything in one
  directory)
• Files were stored in contiguous
  chunks
  – Maximal file size must be known
    in advance
• Now you can edit a program
  and save it in a named file on
  the tape!                 PDP-8 with DECTape [1965]
                                              5
A brief history of file systems
• Time-sharing OSs
   – Required full-fledged file systems
• MULTICS
   – Multilevel directory structure (keep files that belong to
     different users separately)
   – Access control lists
   – Symbolic links


Honeywell 6180 running
      MULTICS [1976]

                                                       6
A brief history of file systems
• UNIX
  – Based on ideas from
    MULTICS
  – Simpler access control
    model
  – Everything is a file!

                    PDP-7




                             7
OS storage stack
                      Application

Syscall interface:     FD table
 creat                 OF table
 open                    VFS
 read                     FS
 write                Buffer cache
 ...
                     Disk scheduler
                     Device driver




                                      8
OS storage stack
                       Application
Hard disk platters:
                        FD table
tracks
sectors                 OF table
                          VFS
                           FS
                       Buffer cache
                      Disk scheduler
                      Device driver




                                       9
OS storage stack
                          Application

Disk controller:           FD table
                           OF table
Hides disk geometry,
bad sectors                  VFS
Exposes linear                FS
sequence of blocks        Buffer cache
                         Disk scheduler
                         Device driver


0                    N



                                          10
OS storage stack
                         Application

Device driver:            FD table
                          OF table
Hides device-specific
protocol                    VFS
Exposes block-device         FS
Interface (linear        Buffer cache
sequence of blocks)
                        Disk scheduler
                        Device driver


0                  N



                                         11
OS storage stack
                            Application

File system:                 FD table
                             OF table
Hides physical location
of data on the disk            VFS
                                FS
Exposes: directory          Buffer cache
hierarchy, symbolic file
                           Disk scheduler
names, random-access
files, protection          Device driver




                                            12
OS storage stack
                           Application

Optimisations:              FD table
                            OF table
Keep recently accessed
disk blocks in memory         VFS
                               FS
Schedule disk accesses     Buffer cache
from multiple processes
                          Disk scheduler
for performance and
fairness                  Device driver




                                           13
OS storage stack
                        Application
Virtual FS:
                         FD table
Unified interface to     OF table
multiple FSs                            VFS
                            FS                     FS2
                                    Buffer cache
                       Disk scheduler         Disk scheduler
                       Device driver          Device driver




                                                   14
OS storage stack
                         Application
File desctriptor and
Open file tables:         FD table
                          OF table
Keep track of files
                            VFS
 opened by user-level
 processes                   FS
Implement semantics      Buffer cache
 of FS syscalls         Disk scheduler
                        Device driver




                                         15
OS storage stack
       Application

        FD table
        OF table
          VFS
           FS
       Buffer cache
      Disk scheduler
      Device driver




                       16
File Names
• File system must provide a convenient naming
  scheme
  – Textual Names
  – May have restrictions
     • Only certain characters
         – E.g. no ‘/’ characters
     • Limited length
     • Only certain format
         – E.g DOS, 8 + 3
  – Case (in)sensitive
  – Names may obey conventions (.c files or C files)
     • Interpreted by tools (UNIX)
     • Interpreted by operating system (Windows)

                                                       17
File Naming




Typical file extensions.
                           18
File Structure




• Three kinds of files
   – byte sequence
   – record sequence
   – key-based, tree structured
      • e.g. IBM’s indexed sequential access method (ISAM)   19
File Structure
• Stream of Bytes            • Records
  – OS considers a file to     – Collection of bytes
    be unstructured              treated as a unit
                                  • Example: employee
  – Simplifies file
                                    record
    management for the
    OS                         – Operations at the level
                                 of records (read_rec,
  – Applications can
                                 write_rec)
    impose their own
    structure                  – File is a collection of
                                 similar records
  – Used by UNIX,
    Windows, most              – OS can optimise
    modern OSes                  operations on records
                                                        20
File Structure
• Tree of Records
  –   Records of variable length
  –   Each has an associated key
  –   Record retrieval based on key
  –   Used on some data processing systems (mainframes)
       • Mostly incorporated into modern databases




                                                     21
File Types
• Regular files
• Directories
• Device Files
   – May be divided into
       • Character Devices – stream of bytes
       • Block Devices
• Some systems distinguish between regular file types
   – ASCII text files, binary files
• At minimum, all systems recognise their own executable
  file format
   – May use a magic number


                                                        22
File Access Types
• Sequential access
  – read all bytes/records from the beginning
  – cannot jump around, could rewind or back up
  – convenient when medium was mag tape
• Random access
  – bytes/records read in any order
  – essential for data base systems
  – read can be …
     • move file pointer (seek), then read or
         – lseek(location,…);read(…)
     • each read specifies the file pointer
         – read(location,…)
                                                  23
File Attributes




Possible file attributes   24
Typical File Operations
1. Create       1. Append
2. Delete       2. Seek
3. Open         3. Get
4. Close           attributes
5. Read         4. Set
6. Write           Attributes
                5. Rename
                                25
An Example Program Using File System Calls
                  (1/2)




                                      26
An Example Program Using File System Calls
                  (2/2)




                                        27
File Organisation and Access
        Programmer’s Perspective
• Given an operating system supporting
  unstructured files that are a stream-of-bytes,
  how can one organise the contents of the files?




                                                28
File Organisation and Access
           Programmer’s Perspective
• Performance                      • Possible access patterns:
  considerations:                     – Read the whole file
   – File system performance          – Read individual blocks or
     affects overall system             records from a file
     performance                      – Read blocks or records
   – Organisation of the file           preceding or following the
     system on disk affects             current one
     performance                      – Retrieve a set of records
   – File organisation (data          – Write a whole file
     layout inside file) affects        sequentially
     performance                      – Insert/delete/update
       • indirectly determines          records in a file
         access patterns
                                      – Update blocks in a file
                                                                29
Classic File Organisations
• There are many ways to organise a file’s
  contents, here are just a few basic
  methods
  – Unstructured Stream (Pile)
  – Sequential Records
  – Indexed Sequential Records
  – Direct or Hashed Records


                                         30
Criteria for File Organization
Things to consider when designing file layout
• Rapid access
   – Needed when accessing a single record
   – Not needed for batch mode
      • read from start to finish
• Ease of update
   – File on CD-ROM will not be updated, so this is not a concern
• Economy of storage
   – Should be minimum redundancy in the data
   – Redundancy can be used to speed access such as an index
• Simple maintenance
• Reliability


                                                                    31
Unstructured Stream
• Data are collected in
  the order they arrive
• Purpose is to
  accumulate a mass of
  data and save it
• Records may have
  different fields
• No structure
• Record access is by
  exhaustive search
                              32
Unstructured Stream Performance
• Update
  – Same size record -
    okay
  – Variable size - poor
• Retrieval
  – Single record - poor
  – Subset – poor
  – Exhaustive - okay



                              33
The Sequential File
• Fixed format used for
  records
• Records are the same
  length
• Field names and lengths
  are attributes of the file
• One field is the key field
   – Uniquely identifies the
     record
   – Records are stored in key
     sequence

                                  34
The Sequential File
• Update
  – Same size record -
    good
  – Variable size – No
• Retrieval
  – Single record - poor
  – Subset – poor
  – Exhaustive - okay



                                 35
Indexed Sequential File
                                                                  Main
• Index provides a lookup                                         File

  capability to quickly reach the
  vicinity of the desired record
                                                     Index
   – Contains key field and a pointer
     to (location in) the main file
   – Indexed is searched to find
     highest key value that is equal
     or less than the desired key        Key
     value                                File Ptr

   – Search continues in the main file
     at the location indicated by the
     pointer


                                                             36
Indexed Sequential File
                                                    Main
• Update                                            File

  – Same size record -
    good                               Index
  – Variable size - No
• Retrieval
  – Single record - good   Key
  – Subset – poor           File Ptr

  – Exhaustive - okay



                                               37
File Directories
• Contains information about files
  – Attributes
  – Location
  – Ownership
• Directory itself is a file owned by the
  operating system
• Provides mapping between file names and
  the files themselves
                                       38
39
Hierarchical, or Tree-Structured
           Directory
• Files can be located by following a path
  from the root, or master, directory down
  various branches
  – This is the absolute pathname for the file
• Can have several files with the same file
  name as long as they have unique path
  names


                                                 40
Current Working Directory
• Always specifying the absolute pathname
  for a file is tedious!
• Introduce the idea of a working directory
  – Files are referenced relative to the working
    directory
• Example: cwd = /home/leonid
  .profile = /home/leonid/.profile


                                                   41
Relative and Absolute
               Pathnames
• Absolute pathname
   – A path specified from the root of the file system to the file
• A Relative pathname
   – A pathname specified from the cwd
• Note: ‘.’ (dot) and ‘..’ (dotdot) refer to current and parent
  directory
Example: cwd = /home/leonid
../../etc/passwd
/etc/passwd
../leonid/../.././etc/passwd
Are all the same file

                                                                     42
Typical Directory Operations

1.   Create     1. Readdir
2.   Delete     2. Rename
3.   Opendir    3. Link
4.   Closedir   4. Unlink



                                43
Nice properties of UNIX naming
• Simple, regular format
  – Names referring to different servers, objects,
    etc., have the same syntax.
     • Regular tools can be used where specialised tools
       would be otherwise be needed.
• Location independent
  – Objects can be distributed or migrated, and
    continue with the same names.


                                                     44
An example of a bad naming
         convention
• From, Rob Pike and Peter Weinberger,
  “The Hideous Name”, Bell Labs TR

UCBVAX::SYS$DISK:[ROB.BIN]CAT_V.EXE;13




                                         45
File Sharing
• In multiuser system, allow files to be
  shared among users
• Two issues
  – Access rights
  – Management of simultaneous access




                                           46
Access Rights
• None
  – User may not know of the existence of the file
  – User is not allowed to read the user directory
    that includes the file
• Knowledge
  – User can only determine that the file exists
    and who its owner is



                                                   47
Access Rights
• Execution
  – The user can load and execute a program but
    cannot copy it
• Reading
  – The user can read the file for any purpose,
    including copying and execution
• Appending
  – The user can add data to the file but cannot
    modify or delete any of the file’s contents
                                                   48
Access Rights
• Updating
  – The user can modify, deleted, and add to the
    file’s data. This includes creating the file,
    rewriting it, and removing all or part of the
    data
• Changing protection
  – User can change access rights granted to
    other users
• Deletion
  – User can delete the file
                                               49
Access Rights
• Owners
  – Has all rights previously listed
  – May grant rights to others using the following
    classes of users
    • Specific user
    • User groups
    • All for public files




                                                50
Case Study:
             UNIX Access Permissions
total 1704
drwxr-x---   3   kevine   kevine      4096   Oct   14   08:13   .
drwxr-x---   3   kevine   kevine      4096   Oct   14   08:14   ..
drwxr-x---   2   kevine   kevine      4096   Oct   14   08:12   backup
-rw-r-----   1   kevine   kevine    141133   Oct   14   08:13   eniac3.jpg
-rw-r-----   1   kevine   kevine   1580544   Oct   14   08:13   wk11.ppt


   • First letter: file type
       d for directories
       - for regular files)
   • Three user categories
       user, group, and other
                                                                             51
UNIX Access Permissions
total 1704
drwxr-x---    3   kevine   kevine       4096   Oct   14   08:13   .
drwxr-x---    3   kevine   kevine       4096   Oct   14   08:14   ..
drwxr-x---    2   kevine   kevine       4096   Oct   14   08:12   backup
-rw-r-----    1   kevine   kevine     141133   Oct   14   08:13   eniac3.jpg
-rw-r-----    1   kevine   kevine    1580544   Oct   14   08:13   wk11.ppt


   • Three access rights per category
       read, write, and execute
                  drwxrwxrwx
                    user                   other
                             group

                                                                               52
UNIX Access Permissions
total 1704
drwxr-x---    3   kevine   kevine      4096   Oct   14   08:13   .
drwxr-x---    3   kevine   kevine      4096   Oct   14   08:14   ..
drwxr-x---    2   kevine   kevine      4096   Oct   14   08:12   backup
-rw-r-----    1   kevine   kevine    141133   Oct   14   08:13   eniac3.jpg
-rw-r-----    1   kevine   kevine   1580544   Oct   14   08:13   wk11.ppt

   • Execute permission for directory?
       – Permission to access files in the directory
   • To list a directory requires read permissions
   • What about drwxr-x—x?

                                                                              53
UNIX Access Permissions
• Shortcoming
  – The three user categories a rather coarse
• Problematic example
  – Joe owns file foo.bar
  – Joe wishes to keep his file private
     • Inaccessible to the general public
  – Joe wishes to give Bill read and write access
  – Joe wishes to give Peter read-only access
  – How????????



                                                    54
Simultaneous Access
• Most OSes provide mechanisms for users to
  manage concurrent access to files
  – Example: lockf(), flock() system calls
• Typically
  – User may lock entire file when it is to be updated
  – User may lock the individual records during the
    update
• Mutual exclusion and deadlock are issues for
  shared access

                                                         55

Más contenido relacionado

La actualidad más candente

Chapter 13 file systems
Chapter 13   file systemsChapter 13   file systems
Chapter 13 file systemsAlvin Chin
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemSadia Bashir
 
File System Implementation - Part1
File System Implementation - Part1File System Implementation - Part1
File System Implementation - Part1Amir Payberah
 
Operating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsOperating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsMukesh Chinta
 
NTFS file system
NTFS file systemNTFS file system
NTFS file systemRavi Yasas
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file systemTaaanu01
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfsLucky Ali
 
Files and directories in Linux 6
Files and directories  in Linux 6Files and directories  in Linux 6
Files and directories in Linux 6Meenakshi Paul
 
Fat 32 file system
Fat 32 file systemFat 32 file system
Fat 32 file systemkeshav546
 
The linux file system structure
The linux file system structureThe linux file system structure
The linux file system structureTeja Bheemanapally
 

La actualidad más candente (19)

Chapter 13 file systems
Chapter 13   file systemsChapter 13   file systems
Chapter 13 file systems
 
Aties Presentation
Aties PresentationAties Presentation
Aties Presentation
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
File System Implementation - Part1
File System Implementation - Part1File System Implementation - Part1
File System Implementation - Part1
 
File system
File systemFile system
File system
 
NTFS vs FAT
NTFS vs FATNTFS vs FAT
NTFS vs FAT
 
Os
OsOs
Os
 
Operating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsOperating Systems - Implementing File Systems
Operating Systems - Implementing File Systems
 
linux file system
linux file systemlinux file system
linux file system
 
File System FAT And NTFS
File System FAT And NTFSFile System FAT And NTFS
File System FAT And NTFS
 
NTFS file system
NTFS file systemNTFS file system
NTFS file system
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file system
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfs
 
Files and directories in Linux 6
Files and directories  in Linux 6Files and directories  in Linux 6
Files and directories in Linux 6
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
 
Fat 32 file system
Fat 32 file systemFat 32 file system
Fat 32 file system
 
Windows file system
Windows file systemWindows file system
Windows file system
 
The linux file system structure
The linux file system structureThe linux file system structure
The linux file system structure
 

Destacado

Tele3113 tut2
Tele3113 tut2Tele3113 tut2
Tele3113 tut2Vin Voro
 
File organization techniques
File organization techniquesFile organization techniques
File organization techniquesMeghlal Khan
 
File Organization
File OrganizationFile Organization
File OrganizationManyi Man
 
Slide comd
Slide comdSlide comd
Slide comddparkin
 
From Performance to Health: Wearables for the Rest of Us.
From Performance to Health: Wearables for the Rest of Us.From Performance to Health: Wearables for the Rest of Us.
From Performance to Health: Wearables for the Rest of Us.Amy Friel
 
শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ
শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ
শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ Abul Bashar
 
Presentation for "Provas de Agergação" - 2 relatorio
Presentation for "Provas de Agergação" - 2 relatorioPresentation for "Provas de Agergação" - 2 relatorio
Presentation for "Provas de Agergação" - 2 relatorioAlvaro Barbosa
 
Marketing kisi2-2014
Marketing kisi2-2014Marketing kisi2-2014
Marketing kisi2-2014Smp Al-Hadi
 
Paczka ciasteczek
Paczka ciasteczekPaczka ciasteczek
Paczka ciasteczekderus19
 
Gizmo spotの御案内(観光促進用)
Gizmo spotの御案内(観光促進用)Gizmo spotの御案内(観光促進用)
Gizmo spotの御案内(観光促進用)Takaho Maeda
 
Kamaroninfo núm. 8 novembre 1996
Kamaroninfo núm. 8 novembre 1996Kamaroninfo núm. 8 novembre 1996
Kamaroninfo núm. 8 novembre 1996Josep Miquel
 
コドモノガタリ イクメン調査120328
コドモノガタリ イクメン調査120328コドモノガタリ イクメン調査120328
コドモノガタリ イクメン調査120328Takaho Maeda
 
Arrangeren
ArrangerenArrangeren
Arrangerenwimdboer
 
referenties C2- The Communication Square Website
referenties C2- The Communication Square Websitereferenties C2- The Communication Square Website
referenties C2- The Communication Square WebsiteValerie Leeman
 
Kamaroninfo núm 24. abril 1998
Kamaroninfo núm 24. abril 1998Kamaroninfo núm 24. abril 1998
Kamaroninfo núm 24. abril 1998Josep Miquel
 
2015 04-22 nije metoade frysk
2015 04-22 nije metoade frysk2015 04-22 nije metoade frysk
2015 04-22 nije metoade fryskwimdboer
 
Presentation about music word.
Presentation about music word.Presentation about music word.
Presentation about music word.ppr88
 

Destacado (20)

Tele3113 tut2
Tele3113 tut2Tele3113 tut2
Tele3113 tut2
 
File organization techniques
File organization techniquesFile organization techniques
File organization techniques
 
File Organization
File OrganizationFile Organization
File Organization
 
Lect09
Lect09Lect09
Lect09
 
Slide comd
Slide comdSlide comd
Slide comd
 
From Performance to Health: Wearables for the Rest of Us.
From Performance to Health: Wearables for the Rest of Us.From Performance to Health: Wearables for the Rest of Us.
From Performance to Health: Wearables for the Rest of Us.
 
শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ
শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ
শিক্ষার্থীদের ঝরে পড়া প্রতিকারে প্রয়োাজন সমন্বিত উদ্যোগ
 
Presentation for "Provas de Agergação" - 2 relatorio
Presentation for "Provas de Agergação" - 2 relatorioPresentation for "Provas de Agergação" - 2 relatorio
Presentation for "Provas de Agergação" - 2 relatorio
 
Marketing kisi2-2014
Marketing kisi2-2014Marketing kisi2-2014
Marketing kisi2-2014
 
Paczka ciasteczek
Paczka ciasteczekPaczka ciasteczek
Paczka ciasteczek
 
Lect04
Lect04Lect04
Lect04
 
Gizmo spotの御案内(観光促進用)
Gizmo spotの御案内(観光促進用)Gizmo spotの御案内(観光促進用)
Gizmo spotの御案内(観光促進用)
 
Goldora duyen
Goldora   duyenGoldora   duyen
Goldora duyen
 
Kamaroninfo núm. 8 novembre 1996
Kamaroninfo núm. 8 novembre 1996Kamaroninfo núm. 8 novembre 1996
Kamaroninfo núm. 8 novembre 1996
 
コドモノガタリ イクメン調査120328
コドモノガタリ イクメン調査120328コドモノガタリ イクメン調査120328
コドモノガタリ イクメン調査120328
 
Arrangeren
ArrangerenArrangeren
Arrangeren
 
referenties C2- The Communication Square Website
referenties C2- The Communication Square Websitereferenties C2- The Communication Square Website
referenties C2- The Communication Square Website
 
Kamaroninfo núm 24. abril 1998
Kamaroninfo núm 24. abril 1998Kamaroninfo núm 24. abril 1998
Kamaroninfo núm 24. abril 1998
 
2015 04-22 nije metoade frysk
2015 04-22 nije metoade frysk2015 04-22 nije metoade frysk
2015 04-22 nije metoade frysk
 
Presentation about music word.
Presentation about music word.Presentation about music word.
Presentation about music word.
 

Similar a Lect08

File system Os
File system OsFile system Os
File system OsNehal Naik
 
Distributed File System
Distributed File SystemDistributed File System
Distributed File SystemNtu
 
linuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdflinuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdfShaswatSurya
 
File Systems
File SystemsFile Systems
File Systemskendersec
 
Ntfs and computer forensics
Ntfs and computer forensicsNtfs and computer forensics
Ntfs and computer forensicsGaurav Ragtah
 
File management
File managementFile management
File managementMohd Arif
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystemsplarsen67
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystemsplarsen67
 
2nd unit part 1
2nd unit  part 12nd unit  part 1
2nd unit part 1Pavan Illa
 
ZFS Tutorial USENIX LISA09 Conference
ZFS Tutorial USENIX LISA09 ConferenceZFS Tutorial USENIX LISA09 Conference
ZFS Tutorial USENIX LISA09 ConferenceRichard Elling
 
UNIX(Essential needs of administration)
UNIX(Essential needs of administration)UNIX(Essential needs of administration)
UNIX(Essential needs of administration)Papu Kumar
 

Similar a Lect08 (20)

009709863.pdf
009709863.pdf009709863.pdf
009709863.pdf
 
Operating System
Operating SystemOperating System
Operating System
 
File system Os
File system OsFile system Os
File system Os
 
Distributed File System
Distributed File SystemDistributed File System
Distributed File System
 
linuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdflinuxfilesystem-180727181106 (1).pdf
linuxfilesystem-180727181106 (1).pdf
 
Posscon2013
Posscon2013Posscon2013
Posscon2013
 
File system
File systemFile system
File system
 
File Systems
File SystemsFile Systems
File Systems
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Ntfs and computer forensics
Ntfs and computer forensicsNtfs and computer forensics
Ntfs and computer forensics
 
Ch1 linux basics
Ch1 linux basicsCh1 linux basics
Ch1 linux basics
 
File management
File managementFile management
File management
 
PythonFuse (PyCon4)
PythonFuse (PyCon4)PythonFuse (PyCon4)
PythonFuse (PyCon4)
 
File
FileFile
File
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystems
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystems
 
2nd unit part 1
2nd unit  part 12nd unit  part 1
2nd unit part 1
 
File system
File systemFile system
File system
 
ZFS Tutorial USENIX LISA09 Conference
ZFS Tutorial USENIX LISA09 ConferenceZFS Tutorial USENIX LISA09 Conference
ZFS Tutorial USENIX LISA09 Conference
 
UNIX(Essential needs of administration)
UNIX(Essential needs of administration)UNIX(Essential needs of administration)
UNIX(Essential needs of administration)
 

Más de Vin Voro

Tele3113 tut6
Tele3113 tut6Tele3113 tut6
Tele3113 tut6Vin Voro
 
Tele3113 tut5
Tele3113 tut5Tele3113 tut5
Tele3113 tut5Vin Voro
 
Tele3113 tut4
Tele3113 tut4Tele3113 tut4
Tele3113 tut4Vin Voro
 
Tele3113 tut1
Tele3113 tut1Tele3113 tut1
Tele3113 tut1Vin Voro
 
Tele3113 tut3
Tele3113 tut3Tele3113 tut3
Tele3113 tut3Vin Voro
 
Tele3113 wk11tue
Tele3113 wk11tueTele3113 wk11tue
Tele3113 wk11tueVin Voro
 
Tele3113 wk10wed
Tele3113 wk10wedTele3113 wk10wed
Tele3113 wk10wedVin Voro
 
Tele3113 wk10tue
Tele3113 wk10tueTele3113 wk10tue
Tele3113 wk10tueVin Voro
 
Tele3113 wk11wed
Tele3113 wk11wedTele3113 wk11wed
Tele3113 wk11wedVin Voro
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wedVin Voro
 
Tele3113 wk9tue
Tele3113 wk9tueTele3113 wk9tue
Tele3113 wk9tueVin Voro
 
Tele3113 wk8wed
Tele3113 wk8wedTele3113 wk8wed
Tele3113 wk8wedVin Voro
 
Tele3113 wk9wed
Tele3113 wk9wedTele3113 wk9wed
Tele3113 wk9wedVin Voro
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wedVin Voro
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wedVin Voro
 
Tele3113 wk7tue
Tele3113 wk7tueTele3113 wk7tue
Tele3113 wk7tueVin Voro
 
Tele3113 wk6wed
Tele3113 wk6wedTele3113 wk6wed
Tele3113 wk6wedVin Voro
 
Tele3113 wk6tue
Tele3113 wk6tueTele3113 wk6tue
Tele3113 wk6tueVin Voro
 
Tele3113 wk5tue
Tele3113 wk5tueTele3113 wk5tue
Tele3113 wk5tueVin Voro
 
Tele3113 wk4wed
Tele3113 wk4wedTele3113 wk4wed
Tele3113 wk4wedVin Voro
 

Más de Vin Voro (20)

Tele3113 tut6
Tele3113 tut6Tele3113 tut6
Tele3113 tut6
 
Tele3113 tut5
Tele3113 tut5Tele3113 tut5
Tele3113 tut5
 
Tele3113 tut4
Tele3113 tut4Tele3113 tut4
Tele3113 tut4
 
Tele3113 tut1
Tele3113 tut1Tele3113 tut1
Tele3113 tut1
 
Tele3113 tut3
Tele3113 tut3Tele3113 tut3
Tele3113 tut3
 
Tele3113 wk11tue
Tele3113 wk11tueTele3113 wk11tue
Tele3113 wk11tue
 
Tele3113 wk10wed
Tele3113 wk10wedTele3113 wk10wed
Tele3113 wk10wed
 
Tele3113 wk10tue
Tele3113 wk10tueTele3113 wk10tue
Tele3113 wk10tue
 
Tele3113 wk11wed
Tele3113 wk11wedTele3113 wk11wed
Tele3113 wk11wed
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
 
Tele3113 wk9tue
Tele3113 wk9tueTele3113 wk9tue
Tele3113 wk9tue
 
Tele3113 wk8wed
Tele3113 wk8wedTele3113 wk8wed
Tele3113 wk8wed
 
Tele3113 wk9wed
Tele3113 wk9wedTele3113 wk9wed
Tele3113 wk9wed
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
 
Tele3113 wk7tue
Tele3113 wk7tueTele3113 wk7tue
Tele3113 wk7tue
 
Tele3113 wk6wed
Tele3113 wk6wedTele3113 wk6wed
Tele3113 wk6wed
 
Tele3113 wk6tue
Tele3113 wk6tueTele3113 wk6tue
Tele3113 wk6tue
 
Tele3113 wk5tue
Tele3113 wk5tueTele3113 wk5tue
Tele3113 wk5tue
 
Tele3113 wk4wed
Tele3113 wk4wedTele3113 wk4wed
Tele3113 wk4wed
 

Último

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Último (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 

Lect08

  • 1. File Management Tanenbaum, Chapter 4 COMP3231 Operating Systems Leonid Ryzhyk Kevin Elphinstone 1
  • 2. Outline • Files and directories from the programmer (and user) perspective • Files and directory internals – the operating system perspective 2
  • 3. Summary of the FS abstraction User's view Under the hood Uniform namespace Heterogeneous collection of storage devices Hierarchical structure Flat address space Arbitrarily-sized files Fixed-size blocks Symbolic file names Numeric block addresses Contiguous address space inside Fragmentation a file Access control No access control Tools for  formatting  defragmentation  backup  consistency checking 3
  • 4. A brief history of file systems • Early batch processing systems – No OS – I/O from/to punch cards – Tapes and drums for external storage, but no FS – Rudimentary library support for reading/writing tapes and drums IBM 709 [1958] 4
  • 5. A brief history of file systems • The first file systems were single-level (everything in one directory) • Files were stored in contiguous chunks – Maximal file size must be known in advance • Now you can edit a program and save it in a named file on the tape! PDP-8 with DECTape [1965] 5
  • 6. A brief history of file systems • Time-sharing OSs – Required full-fledged file systems • MULTICS – Multilevel directory structure (keep files that belong to different users separately) – Access control lists – Symbolic links Honeywell 6180 running MULTICS [1976] 6
  • 7. A brief history of file systems • UNIX – Based on ideas from MULTICS – Simpler access control model – Everything is a file! PDP-7 7
  • 8. OS storage stack Application Syscall interface: FD table  creat OF table  open VFS  read FS  write Buffer cache  ... Disk scheduler Device driver 8
  • 9. OS storage stack Application Hard disk platters: FD table tracks sectors OF table VFS FS Buffer cache Disk scheduler Device driver 9
  • 10. OS storage stack Application Disk controller: FD table OF table Hides disk geometry, bad sectors VFS Exposes linear FS sequence of blocks Buffer cache Disk scheduler Device driver 0 N 10
  • 11. OS storage stack Application Device driver: FD table OF table Hides device-specific protocol VFS Exposes block-device FS Interface (linear Buffer cache sequence of blocks) Disk scheduler Device driver 0 N 11
  • 12. OS storage stack Application File system: FD table OF table Hides physical location of data on the disk VFS FS Exposes: directory Buffer cache hierarchy, symbolic file Disk scheduler names, random-access files, protection Device driver 12
  • 13. OS storage stack Application Optimisations: FD table OF table Keep recently accessed disk blocks in memory VFS FS Schedule disk accesses Buffer cache from multiple processes Disk scheduler for performance and fairness Device driver 13
  • 14. OS storage stack Application Virtual FS: FD table Unified interface to OF table multiple FSs VFS FS FS2 Buffer cache Disk scheduler Disk scheduler Device driver Device driver 14
  • 15. OS storage stack Application File desctriptor and Open file tables: FD table OF table Keep track of files VFS opened by user-level processes FS Implement semantics Buffer cache of FS syscalls Disk scheduler Device driver 15
  • 16. OS storage stack Application FD table OF table VFS FS Buffer cache Disk scheduler Device driver 16
  • 17. File Names • File system must provide a convenient naming scheme – Textual Names – May have restrictions • Only certain characters – E.g. no ‘/’ characters • Limited length • Only certain format – E.g DOS, 8 + 3 – Case (in)sensitive – Names may obey conventions (.c files or C files) • Interpreted by tools (UNIX) • Interpreted by operating system (Windows) 17
  • 18. File Naming Typical file extensions. 18
  • 19. File Structure • Three kinds of files – byte sequence – record sequence – key-based, tree structured • e.g. IBM’s indexed sequential access method (ISAM) 19
  • 20. File Structure • Stream of Bytes • Records – OS considers a file to – Collection of bytes be unstructured treated as a unit • Example: employee – Simplifies file record management for the OS – Operations at the level of records (read_rec, – Applications can write_rec) impose their own structure – File is a collection of similar records – Used by UNIX, Windows, most – OS can optimise modern OSes operations on records 20
  • 21. File Structure • Tree of Records – Records of variable length – Each has an associated key – Record retrieval based on key – Used on some data processing systems (mainframes) • Mostly incorporated into modern databases 21
  • 22. File Types • Regular files • Directories • Device Files – May be divided into • Character Devices – stream of bytes • Block Devices • Some systems distinguish between regular file types – ASCII text files, binary files • At minimum, all systems recognise their own executable file format – May use a magic number 22
  • 23. File Access Types • Sequential access – read all bytes/records from the beginning – cannot jump around, could rewind or back up – convenient when medium was mag tape • Random access – bytes/records read in any order – essential for data base systems – read can be … • move file pointer (seek), then read or – lseek(location,…);read(…) • each read specifies the file pointer – read(location,…) 23
  • 25. Typical File Operations 1. Create 1. Append 2. Delete 2. Seek 3. Open 3. Get 4. Close attributes 5. Read 4. Set 6. Write Attributes 5. Rename 25
  • 26. An Example Program Using File System Calls (1/2) 26
  • 27. An Example Program Using File System Calls (2/2) 27
  • 28. File Organisation and Access Programmer’s Perspective • Given an operating system supporting unstructured files that are a stream-of-bytes, how can one organise the contents of the files? 28
  • 29. File Organisation and Access Programmer’s Perspective • Performance • Possible access patterns: considerations: – Read the whole file – File system performance – Read individual blocks or affects overall system records from a file performance – Read blocks or records – Organisation of the file preceding or following the system on disk affects current one performance – Retrieve a set of records – File organisation (data – Write a whole file layout inside file) affects sequentially performance – Insert/delete/update • indirectly determines records in a file access patterns – Update blocks in a file 29
  • 30. Classic File Organisations • There are many ways to organise a file’s contents, here are just a few basic methods – Unstructured Stream (Pile) – Sequential Records – Indexed Sequential Records – Direct or Hashed Records 30
  • 31. Criteria for File Organization Things to consider when designing file layout • Rapid access – Needed when accessing a single record – Not needed for batch mode • read from start to finish • Ease of update – File on CD-ROM will not be updated, so this is not a concern • Economy of storage – Should be minimum redundancy in the data – Redundancy can be used to speed access such as an index • Simple maintenance • Reliability 31
  • 32. Unstructured Stream • Data are collected in the order they arrive • Purpose is to accumulate a mass of data and save it • Records may have different fields • No structure • Record access is by exhaustive search 32
  • 33. Unstructured Stream Performance • Update – Same size record - okay – Variable size - poor • Retrieval – Single record - poor – Subset – poor – Exhaustive - okay 33
  • 34. The Sequential File • Fixed format used for records • Records are the same length • Field names and lengths are attributes of the file • One field is the key field – Uniquely identifies the record – Records are stored in key sequence 34
  • 35. The Sequential File • Update – Same size record - good – Variable size – No • Retrieval – Single record - poor – Subset – poor – Exhaustive - okay 35
  • 36. Indexed Sequential File Main • Index provides a lookup File capability to quickly reach the vicinity of the desired record Index – Contains key field and a pointer to (location in) the main file – Indexed is searched to find highest key value that is equal or less than the desired key Key value File Ptr – Search continues in the main file at the location indicated by the pointer 36
  • 37. Indexed Sequential File Main • Update File – Same size record - good Index – Variable size - No • Retrieval – Single record - good Key – Subset – poor File Ptr – Exhaustive - okay 37
  • 38. File Directories • Contains information about files – Attributes – Location – Ownership • Directory itself is a file owned by the operating system • Provides mapping between file names and the files themselves 38
  • 39. 39
  • 40. Hierarchical, or Tree-Structured Directory • Files can be located by following a path from the root, or master, directory down various branches – This is the absolute pathname for the file • Can have several files with the same file name as long as they have unique path names 40
  • 41. Current Working Directory • Always specifying the absolute pathname for a file is tedious! • Introduce the idea of a working directory – Files are referenced relative to the working directory • Example: cwd = /home/leonid .profile = /home/leonid/.profile 41
  • 42. Relative and Absolute Pathnames • Absolute pathname – A path specified from the root of the file system to the file • A Relative pathname – A pathname specified from the cwd • Note: ‘.’ (dot) and ‘..’ (dotdot) refer to current and parent directory Example: cwd = /home/leonid ../../etc/passwd /etc/passwd ../leonid/../.././etc/passwd Are all the same file 42
  • 43. Typical Directory Operations 1. Create 1. Readdir 2. Delete 2. Rename 3. Opendir 3. Link 4. Closedir 4. Unlink 43
  • 44. Nice properties of UNIX naming • Simple, regular format – Names referring to different servers, objects, etc., have the same syntax. • Regular tools can be used where specialised tools would be otherwise be needed. • Location independent – Objects can be distributed or migrated, and continue with the same names. 44
  • 45. An example of a bad naming convention • From, Rob Pike and Peter Weinberger, “The Hideous Name”, Bell Labs TR UCBVAX::SYS$DISK:[ROB.BIN]CAT_V.EXE;13 45
  • 46. File Sharing • In multiuser system, allow files to be shared among users • Two issues – Access rights – Management of simultaneous access 46
  • 47. Access Rights • None – User may not know of the existence of the file – User is not allowed to read the user directory that includes the file • Knowledge – User can only determine that the file exists and who its owner is 47
  • 48. Access Rights • Execution – The user can load and execute a program but cannot copy it • Reading – The user can read the file for any purpose, including copying and execution • Appending – The user can add data to the file but cannot modify or delete any of the file’s contents 48
  • 49. Access Rights • Updating – The user can modify, deleted, and add to the file’s data. This includes creating the file, rewriting it, and removing all or part of the data • Changing protection – User can change access rights granted to other users • Deletion – User can delete the file 49
  • 50. Access Rights • Owners – Has all rights previously listed – May grant rights to others using the following classes of users • Specific user • User groups • All for public files 50
  • 51. Case Study: UNIX Access Permissions total 1704 drwxr-x--- 3 kevine kevine 4096 Oct 14 08:13 . drwxr-x--- 3 kevine kevine 4096 Oct 14 08:14 .. drwxr-x--- 2 kevine kevine 4096 Oct 14 08:12 backup -rw-r----- 1 kevine kevine 141133 Oct 14 08:13 eniac3.jpg -rw-r----- 1 kevine kevine 1580544 Oct 14 08:13 wk11.ppt • First letter: file type d for directories - for regular files) • Three user categories user, group, and other 51
  • 52. UNIX Access Permissions total 1704 drwxr-x--- 3 kevine kevine 4096 Oct 14 08:13 . drwxr-x--- 3 kevine kevine 4096 Oct 14 08:14 .. drwxr-x--- 2 kevine kevine 4096 Oct 14 08:12 backup -rw-r----- 1 kevine kevine 141133 Oct 14 08:13 eniac3.jpg -rw-r----- 1 kevine kevine 1580544 Oct 14 08:13 wk11.ppt • Three access rights per category read, write, and execute drwxrwxrwx user other group 52
  • 53. UNIX Access Permissions total 1704 drwxr-x--- 3 kevine kevine 4096 Oct 14 08:13 . drwxr-x--- 3 kevine kevine 4096 Oct 14 08:14 .. drwxr-x--- 2 kevine kevine 4096 Oct 14 08:12 backup -rw-r----- 1 kevine kevine 141133 Oct 14 08:13 eniac3.jpg -rw-r----- 1 kevine kevine 1580544 Oct 14 08:13 wk11.ppt • Execute permission for directory? – Permission to access files in the directory • To list a directory requires read permissions • What about drwxr-x—x? 53
  • 54. UNIX Access Permissions • Shortcoming – The three user categories a rather coarse • Problematic example – Joe owns file foo.bar – Joe wishes to keep his file private • Inaccessible to the general public – Joe wishes to give Bill read and write access – Joe wishes to give Peter read-only access – How???????? 54
  • 55. Simultaneous Access • Most OSes provide mechanisms for users to manage concurrent access to files – Example: lockf(), flock() system calls • Typically – User may lock entire file when it is to be updated – User may lock the individual records during the update • Mutual exclusion and deadlock are issues for shared access 55