Chapter 10 File System Interface Joe Mc Carthy
- Slides: 37
Chapter 10: File System Interface Joe Mc. Carthy CSS 430: Operating Systems - File System Interface 1
Chapter 10: File System Interface • • • File Concept Access Methods Directory Structure File-System Mounting File Sharing Protection Material derived, in part, from Operating Systems Concepts with Java, 8 th Ed. © 2009 Silberschatz, Galvin & Gagne CSS 430: Operating Systems - File System Interface 2
File Concept • What is a file? CSS 430: Operating Systems - File System Interface 3
File Concept • Named collection of related information on secondary storage (nonvolatile) • Smallest unit of logical secondary storage – May be composed of multiple physical secondary storage units – Logically contiguous space – May be physically distributed CSS 430: Operating Systems - File System Interface 4
File Structure • Levels of structure – None - sequence of words, bytes – Simple record structure • Lines • Fixed length records • Variable length records – Complex structures • Formatted document • Relocatable load file – Can simulate last two with first method by inserting appropriate control characters • Structure imposed by: – Operating system – Program CSS 430: Operating Systems - File System Interface 5
File Attributes CSS 430: Operating Systems - File System Interface 6
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: specifies who can read, write, execute • Time, date, and owner identification: data for protection, security, and usage monitoring • Information about files are kept in the directory structure, which is maintained on the disk CSS 430: Operating Systems - File System Interface 7
Linux ls –l, stat [joemcc@uw 1 -320 -18 Thread. OS]$ ls -l -rw------- 1 css 430 users 10193 Nov -rw------- 1 css 430 users 8603 Dec -rw-r--r-- 1 css 430 users 8395 Nov -rw------- 1 css 430 users 8817 Nov Kernel*. java 11 2004 Kernel_fil. java 23 2010 Kernel_hw 3 part 1. java 13 2004 Kernel. java 11 2004 Kernel_org. java [joemcc@uw 1 -320 -18 Thread. OS]$ stat Kernel. java File: `Kernel. java' Size: 8395 Blocks: 24 IO Block: 32768 regular file Device: 17 h/23 d Inode: 130884 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1803/ css 430) Gid: ( 100/ users) Access: 2011 -11 -12 19: 40: 45. 00000 -0800 Modify: 2004 -11 -13 20: 36: 20. 00000 -0800 Change: 2011 -10 -17 14: 00: 43. 00000 -0700 CSS 430: Operating Systems - File System Interface 8
File Operations CSS 430: Operating Systems - File System Interface 9
File Operations Descriptions Unix Thread. OS Create a file with its attribute creat(filename, mode) N/A Open the specified file. (Create it if mode specified and necessary) open(filename, flag, mode) Sys. Lib. open(filename, mode) Read from a file read(fd, buf, size) Sys. Lib. read(fd, buffer) Write a file write(fd, buf, size) Sys. Lib. write(fd, buffer) Seek Reposition a file access point lseek(fd, offset, origin) Sys. Lib. seek(fd, offset, whence) Close the file specified with fd close(fd) Sys. Lib. close(fd) Delete Destroy the specified file remove(filename) Sys. Lib. delete(filename) Truncate Resize the file to a specified length truncate(filename, length) N/A Status Returns the specified file status stat(fd, statbuf) Sys. Lib. fsize(fd) Format the disk N/A Sys. Lib. format(files) CSS 430: Operating Systems - File System Interface 10
lseek (logical seek) • lseek( int fd, int offset, int origin ) – Reposition logical file pointer (fp) within an open file – fd: file descriptor • • 0 (STDIN_FILENO) 1 (STDOUT_FILENO) 2 (STDERR_FILENO) … – offset can be + or – (down/right or up/left) – origin (whence in Sys. Lib. seek()) • 0 (SEEK_SET), offset from start of file (offset must be +) • 1 (SEEK_CUR), offset from current fp position • 2 (SEEK_END), offset from end of file (offset must be -) CSS 430: Operating Systems - File System Interface 11
lseek (logical seek) lseek( int fd, int offset, int origin ) • origin == 0 (SEEK_SET) offset (> 0) EOF new file pointer position • origin == 1 (SEEK_CUR) current file pointer position offset (> 0) EOF new file pointer position • origin == 2 (SEEK_END) EOF new file pointer position offset (< 0) CSS 430: Operating Systems - File System Interface 12
Open Files • Several pieces of data are needed to manage open files: – File pointer: pointer to next read/write location, per process that has the file open – File open count: counter of # processes that have opened file - # of processes that have closed it • when 0, can remove entry from system-wide open file table – Disk location of the file: cache of data access information – Access rights: per-process access mode information CSS 430: Operating Systems - File System Interface 13
Recall: File Descriptors (Ch. 3) http: //cs. oberlin. edu/~jdonalds/3 41/lecture 24. html http: //www. cis. temple. edu/~ingargio/cis 307/readings/unix 1. html CSS 430: Operating Systems - File System Interface 14
File Types CSS 430: Operating Systems - File System Interface 15
File Types CSS 430: Operating Systems - File System Interface 16
Access Methods • Sequential Access read next block write next block reset no read after last write (rewrite) • Direct Access read block n write block n position to block n read next block write next block rewrite block n n = relative block number CSS 430: Operating Systems - File System Interface 17
Directory Structure • A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 Fn * Both the directory structure and the files reside on disk CSS 430: Operating Systems - File System Interface 18
A Typical File-System Organization CSS 430: Operating Systems - File System Interface 19
Operations Performed on Directory CSS 430: Operating Systems - File System Interface 20
Operations Performed on Directory • • • Search for a file Create a file Delete a file List a directory Rename a file Change working directory – Navigate / traverse the file system CSS 430: Operating Systems - File System Interface 21
Single-Level Directory • A single directory for all users Naming problem Grouping problem CSS 430: Operating Systems - File System Interface 22
Two-Level Directory • Separate directory for each user n Path names n Can [re]use the same file name for different users n Efficient searching n No grouping capability CSS 430: Operating Systems - File System Interface 23
Tree-Structured Directories n Absolute & relative paths, current working directory n Can [re]use the same file name in any directory n Efficient searching n Grouping capability CSS 430: Operating Systems - File System Interface 24
Acyclic-Graph Directories • For sharing subdirectories and files CSS 430: Operating Systems - File System Interface 25
Acyclic-Graph Directories • For sharing subdirectories and files What if /dict/w/list is deleted? CSS 430: Operating Systems - File System Interface 26
General Graph Directory CSS 430: Operating Systems - File System Interface 27
General Graph Directory • How do we guarantee no cycles? CSS 430: Operating Systems - File System Interface 28
General Graph Directory • How do we guarantee no cycles? – Allow only links to files (not subdirectories) – Garbage collection – Every time a new link is added use a cycle detection algorithm to determine whether it is OK CSS 430: Operating Systems - File System Interface 29
File System Mounting • A file system must be mounted before it can be accessed • A unmounted file system is mounted at a mount point CSS 430: Operating Systems - File System Interface 30
Linux df [css 430@uw 1 -320 -19 ~]$ df Filesystem 1 K-blocks /dev/mapper/VG 00 -lv_root 2951952 /dev/sda 1 101086 tmpfs 1036984 /dev/mapper/VG 00 -lv_home 1967952 /dev/mapper/VG 00 -lv_tmp 1967952 /dev/mapper/VG 00 -lv_usr 60216936 /dev/mapper/VG 00 -lv_var 2984720 metis. uwb. edu: /usr/apps 18385920 medusa. uwb. edu: /home/uwagent 35318528 medusa. uwb. edu: /home/condor 35318528 medusa. uwb. edu: /home/hadoop 35318528 69. 91. 206. 17: /home 2 108598240 metis: /home 4 12095040 Used Available Use% Mounted on 900344 24835 0 1899240 71032 1036984 33% / 26% /boot 0% /dev/shm 35808 1830564 2% /home 36960 1829412 2% /tmp 14042456 43071736 25% /usr 1169764 1664236 42% /var 14719200 2736224 85% /usr/apps 21919264 11611904 66% /home/uwagent 21919264 11611904 66% /home/condor 21919264 77730208 1847840 11611904 26454816 9632800 66% /home/hadoop 75% /net/metis/home 2 17% /net/metis/home 4 CSS 430: Operating Systems - File System Interface 31
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 CSS 430: Operating Systems - File System Interface 32
File Sharing – Multiple Users • User IDs identify users, allowing permissions and protections to be per-user • Group IDs allow users to be in groups, permitting group access rights CSS 430: Operating Systems - File System Interface 33
Protection • File owner/creator should be able to control: – what can be done – by whom • Types of access – Read – Write – Execute – Append – Delete – List CSS 430: Operating Systems - File System Interface 34
Access Lists & Groups • Only administrators can create users & groups • 3 modes of access: read, write, execute • 3 classes of users: a) owner 7 b) group 6 c) universe 4 RWX 111 RWX 110 RWX 100 • Example settings (Linux): – 755 (-rwxr-xr-x) – 644 (-rw-r--r--) – 700 (drwx------) [“d” = directory] CSS 430: Operating Systems - File System Interface 35
Windows XP Access-control List Management CSS 430: Operating Systems - File System Interface 36
A Sample UNIX Directory Listing CSS 430: Operating Systems - File System Interface 37
- The crucible background information
- Mc carthy era
- File-file yang dibuat oleh user pada jenis file di linux
- File-system interface
- Remote file access in distributed file system
- In a file-oriented information system, a transaction file
- What is interface in java
- Areas of the screen that behave as if they were independent
- Office interface vs industrial interface
- An interface
- Difference between logical file and physical file
- File sharing management system
- What does a markup tag tells the web browser
- File system modules in distributed system
- Flat file service
- File system in operating system
- Ufs4.0
- File system in operating system
- User interface design in system analysis and design
- Operating system is an interface between the
- Komponen user interface
- Property management system interfaces
- Input output and form design
- What are the advantages of command line interface
- Os ui
- Writable volumes
- Iget algorithm in unix
- Coda file
- Sistem file
- File management in operating system
- Sun nfs
- Frangipani: a scalable distributed file system
- Coda file system
- Manipulasi file adalah
- File processing system
- Aka.ms/k8slearning
- Hierarchical file system
- Hadoop distributed file system