0
Operating Systems
         CMPSCI 377
         File Systems
            Emery Berger
University of Massachusetts Amherst

...
Files
    Associate


    names with
    data
    Usually


    stored on
    persistent
    media
    (disks)



     U...
File Names
    Hierarchical


    directory
    structure
        Absolute,
    

        relative
        to current
  ...
Directories
    Directory – just special file


        Contains metadata, filenames, inodes
    

              inode =...
Poor Man’s Database
         Because files & directories are easy to use,
     

         they get used as de facto datab...
File Systems Abstraction
    File system manages files


        Traditionally: file system maps files to disk
    

   ...
Device files
    Unix devices live in /dev,


    act like ordinary files
 elnux14> echo quot;fooquot; > /dev/tty
 foo


...
/proc filesystem
    Normal file access to kernel internals


elnux14> ls     -l /proc/30917/
total 0
dr-xr-xr-x      2  ...
Named Pipes (FIFO)
    Special file: acts like unnamed pipe


         E.g., cat file | wc -l
     


    elnux14> mkfif...
Named Pipes (FIFO)
    Special file: acts like unnamed pipe


         E.g., cat file | wc -l
     


    elnux14> mkfif...
Named Pipes (FIFO)
    Special file: acts like unnamed pipe


         E.g., cat file | wc -l
     


    elnux14> mkfif...
Named Pipes (FIFO)
    Special file: acts like unnamed pipe


         E.g., cat file | wc –l
     


    elnux14> mkfif...
Named Pipes (FIFO)
    Exercise:


        Program named “joe” outputs file “joe.out”
    

              Huge (~ 3 GB)
...
Named Pipes (FIFO)
    Exercise:


        Program named “joe” outputs file “joe.out”
    

              Huge (~ 3 GB)
...
File Metadata
    Files have a lot of associated “metadata”;


    ex.: Unix (from stat)
        Date created, last modif...
Untyped Files
    Unix, Windows – file contents untyped


        Stream of bytes
    

        Type implied by conventi...
File Types
    Unix, Windows – file contents untyped


        Stream of bytes
    

        Type implied by convention ...
Access Control
    Unix: each file has associated bits that


    control access (& other stuff)
        Read
    

    ...
Access Control - chmod
    Can read bits via ls, set bits via chmod



elnux14> ls -l ack.scm
-rw-r----- 1 emery fac 197 ...
The End




  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science   20
Upcoming SlideShare
Loading in...5
×

Operating Systems - File Systems

1,524

Published on

From the Operating Systems course (CMPSCI 377) at UMass Amherst, Fall 2007.

Published in: Technology, Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,524
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
108
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "Operating Systems - File Systems"

  1. 1. Operating Systems CMPSCI 377 File Systems Emery Berger University of Massachusetts Amherst UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  2. 2. Files Associate  names with data Usually  stored on persistent media (disks) UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 2
  3. 3. File Names Hierarchical  directory structure Absolute,  relative to current Windows  names = location + dir UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 3
  4. 4. Directories Directory – just special file  Contains metadata, filenames, inodes  inode = unique number for file  May contain other directory, etc.  Beware: fixed max filename length  File systems use directory structure to  improve locality E.g., ext2 – all files in same directory  clustered in same region of disk UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 4
  5. 5. Poor Man’s Database Because files & directories are easy to use,  they get used as de facto databases e.g., Internet Explorer web cache  ~ 1000 files in each hash subdirectory  C:Documents and SettingsEmeryLocal SettingsTemporary Internet FilesContent.IE5> ls -ltra total 1873 -rwx------+ 1 Emery None 67 Jan 10 17:31 desktop.ini drwx------+ 2 Emery None 0 Jan 17 22:42 0NDWKTYT drwx------+ 7 Emery None 0 Feb 19 19:53 . drwx------+ 7 Emery None 0 Apr 20 14:45 .. drwx------+ 2 Emery None 0 May 1 21:41 8HZD6WS6 drwx------+ 2 Emery None 0 May 1 21:54 I4F15DOK drwx------+ 2 Emery None 0 May 1 22:03 XM0N4Q4W -rwx------+ 1 Emery None 1916928 May 3 12:21 index.dat drwx------+ 2 Emery None 0 May 3 12:21 S0RKZRFZ C:Documents and SettingsEmeryLocal SettingsTemporary Internet FilesContent.IE5> UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 5
  6. 6. File Systems Abstraction File system manages files  Traditionally: file system maps files to disk  But: files convenient abstraction  use same, easy interface (read, write) Block devices (/dev/scsi0)  Disk drives – transfer in blocks  Character devices (/dev/tty)  Console, printer  Proc filesystem (/proc/mem)  FIFO (named pipes)  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 6
  7. 7. Device files Unix devices live in /dev,  act like ordinary files elnux14> echo quot;fooquot; > /dev/tty foo UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 7
  8. 8. /proc filesystem Normal file access to kernel internals  elnux14> ls -l /proc/30917/ total 0 dr-xr-xr-x 2 emery fac 0 May 3 13:18 attr -r-------- 1 emery fac 0 May 3 13:18 auxv -r--r--r-- 1 emery fac 0 May 3 13:01 cmdline lrwxrwxrwx 1 emery fac 0 May 3 13:18 cwd -> /nfs/elsrv4/users5/fac/em -r-------- 1 emery fac 0 May 3 13:18 environ lrwxrwxrwx 1 emery fac 0 May 3 13:18 exe -> /bin/tcsh dr-x------ 2 emery fac 0 May 3 12:06 fd -rw-r--r-- 1 emery fac 0 May 3 13:18 loginuid -r-------- 1 emery fac 0 May 3 13:18 maps -rw------- 1 emery fac 0 May 3 13:18 mem -r--r--r-- 1 emery fac 0 May 3 13:18 mounts lrwxrwxrwx 1 emery fac 0 May 3 13:18 root -> / -r--r--r-- 1 emery fac 0 May 3 13:01 stat -r--r--r-- 1 emery fac 0 May 3 13:18 statm -r--r--r-- 1 emery fac 0 May 3 13:01 status dr-xr-xr-x 3 emery fac 0 May 3 13:18 task -r--r--r-- 1 emery fac 0 May 3 13:10 wchan UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 8
  9. 9. Named Pipes (FIFO) Special file: acts like unnamed pipe  E.g., cat file | wc -l  elnux14> mkfifo thePipe elnux14> ls -ld thePipe prw-r----- 1 emery fac 0 May 3 14:00 thePipe elnux14> cat simplesocket.h > thePipe & [1] 32242 elnux14> wc -l < thePipe 155 [1] Done cat simplesocket.h > thePipe elnux14> UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 9
  10. 10. Named Pipes (FIFO) Special file: acts like unnamed pipe  E.g., cat file | wc -l  elnux14> mkfifo thePipe elnux14> ls -ld thePipe prw-r----- 1 emery fac 0 May 3 14:00 thePipe elnux14> cat simplesocket.h > thePipe & [1] 32242 elnux14> wc -l < thePipe 155 [1] Done cat simplesocket.h > thePipe elnux14> UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 10
  11. 11. Named Pipes (FIFO) Special file: acts like unnamed pipe  E.g., cat file | wc -l  elnux14> mkfifo thePipe elnux14> ls -ld thePipe prw-r----- 1 emery fac 0 May 3 14:00 thePipe elnux14> cat simplesocket.h > thePipe & [1] 32242 elnux14> wc -l < thePipe 155 [1] Done cat simplesocket.h > thePipe elnux14> UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 11
  12. 12. Named Pipes (FIFO) Special file: acts like unnamed pipe  E.g., cat file | wc –l  elnux14> mkfifo thePipe elnux14> ls -ld thePipe prw-r----- 1 emery fac 0 May 3 14:00 thePipe elnux14> cat simplesocket.h > thePipe & [1] 32242 elnux14> wc -l < thePipe 155 [1] Done cat simplesocket.h > thePipe elnux14> Useful when cannot do redirection  Especially for compression  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 12
  13. 13. Named Pipes (FIFO) Exercise:  Program named “joe” outputs file “joe.out”  Huge (~ 3 GB)  Compress it automagically using gzip -c &  named FIFO to “joe.out.gz” UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 13
  14. 14. Named Pipes (FIFO) Exercise:  Program named “joe” outputs file “joe.out”  Huge (~ 3 GB)  Compress it automagically using gzip -c &  named FIFO to “joe.out.gz” elnux14> mkfifo joe.out elnux14> gzip –c < joe.out > joe.out.gz & [1] elnux14> joe UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 14
  15. 15. File Metadata Files have a lot of associated “metadata”;  ex.: Unix (from stat) Date created, last modified, last accessed  Size (bytes)  User & group ID of file’s owner  File type (not content type)  Directory  Regular file  Block / character device (disk drive, screen)  FIFO  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 15
  16. 16. Untyped Files Unix, Windows – file contents untyped  Stream of bytes  Type implied by convention (extensions)  .ppt, .pdf, …  Mac: file types stored in metadata  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 16
  17. 17. File Types Unix, Windows – file contents untyped  Stream of bytes  Type implied by convention (extensions)  .ppt, .pdf, …  Mac: file types stored in metadata  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 17
  18. 18. Access Control Unix: each file has associated bits that  control access (& other stuff) Read  Write  Execute  Can specify for three “users”  User (file owner)  Group (set of users)  Other (everyone else)  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 18
  19. 19. Access Control - chmod Can read bits via ls, set bits via chmod  elnux14> ls -l ack.scm -rw-r----- 1 emery fac 197 Feb 25 15:19 ack.scm elnux14> chmod -r ack.scm elnux14> ls -l ack.scm --w------- 1 emery fac 197 Feb 25 15:19 ack.scm elnux14> cat ack.scm cat: ack.scm: Permission denied UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 19
  20. 20. The End UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 20
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×