Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

File Systems and Long-term Information Storage: File Organization and Management, Study notes of Operating Systems

Various aspects of file systems, including files, directories, file system implementation, and long-term information storage. Topics covered include file naming, file structure, file types, file access, file attributes, file operations, memory-mapped files, directories, and file system implementation. The document also includes examples of file system calls and file system reliability.

Typology: Study notes

Pre 2010

Uploaded on 08/09/2009

koofers-user-yz4-1
koofers-user-yz4-1 🇺🇸

10 documents

1 / 46

Toggle sidebar

Related documents


Partial preview of the text

Download File Systems and Long-term Information Storage: File Organization and Management and more Study notes Operating Systems in PDF only on Docsity! 1 File Systems Chapter 6 6.1 Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems 2 Long-term Information Storage 1. Must store large amounts of data 2. Information stored must survive the termination of the process using it 3. Multiple processes must be able to access the information concurrently 5 File Types (a) An executable file (b) An archive 6 File Access • 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 marker (seek), then read or … • read and then move file marker File Attributes Attribute Meaning Protection Who can access the file and in what way Password Password needed to access the file Creator ID of the person who created the file Owner Current owner Read-only flag 0 for read/write; 1 for read only Hidden flag 0 for normal; 1 for do not display in listings System flag 0 for normal files; 1 for system file Archive flag 0 for has been backed up; 1 for needs to be backed up ASCll/binary flag 0 for ASCII file; 1 for binary file Random access flag 0 for sequential access only; 1 for random access Temporary flag 0 for normal; 1 for delete file on process exit Lock flags 0 for unlocked; nonzero for locked Record length Number of bytes in a record Key position Offset of the key within each record Key length Number of bytes in the key field Creation time Date and time the file was created Time of last access Date and time the file was last accessed Time of last change Date and time the file has last changed Current size Number of bytes in the file Maximum size Number of bytes the file may grow to Possible file attributes An Example Program Using File System Calls (2/2) /* Open the input file and create the output file */ in_fd = open(argv[1], OO_RDONLY); /* open the source file */ if (in_fd < 0) exit(2): /* if it cannot be opened, exit */ out_fd = creat(argv[2], OUTPUT_MODE); /* create the destination file */ if (out_fd < 0) exit(3); /* if it cannot be created, exit */ /* Copy loop */ while (TRUE) { rd_count = read(in_ fd, buffer, BUF _ SIZE); /* read a block of data */ if (rd_count <= 0) break; /* if end of file or error, exit loop */ wt_count = write(out_fd, buffer, rd_ count); /* write data */ if (wt_count <= 0) exit(4); /* wt_count <= 0 is an error */ } /* Close the files */ close(in_fd): close(out_fd); if (rd_count == 0) /* no error on last read */ exit(0); else exit(5); /* error on last read */ 10 11 Memory-Mapped Files (a) Segmented process before mapping files into its address space (b) Process after mapping existing file abc into one segment creating new segment for xyz 12 Directories Single-Level Directory Systems • A single level directory system – contains 4 files – owned by 3 different people, A, B, and C Path Names jim ast lib jim dict. ‘iim A UNIX directory tree 15 16 Directory Operations 1. Create 2. Delete 3. Opendir 4. Closedir 5. Readdir 6. Rename 7. Link 8. Unlink File System Implementation Partition table \ Entire disk > _ Disk ;_— MBR Boot block Super block Free space mgmt I-nodes Root dir Files and directories A possible fi e system layout 17 20 Implementing Files (3) Linked list allocation using a file allocation table in RAM Implementing Files (4) File Attributes Address of block of pointers Address of disk block 0 _ Address of disk block 1 -———_—_— Address of disk block 2 -—_—_—_— Address of disk black 3 -—> Address of disk black 4 /-——>- Address of disk block 5 -——_>- Address of disk block 6 -———> Address of disk block 7 -—> An example i-node Disk block containing additional disk addresses 21 22 Implementing Directories (1) (a) A simple directory fixed size entries disk addresses and attributes in directory entry (b) Directory in which each entry just refers to an i-node 25 Shared Files (2) (a) Situation prior to linking (b) After the link is created (c)After the original owner removes the file 26 Disk Space Management (1) • Dark line (left hand scale) gives data rate of a disk • Dotted line (right hand scale) gives disk space efficiency • All files 2KB Block size 27 Disk Space Management (2) (a) Storing the free list on a linked list (b) A bit map 30 File System Reliability (1) • A file system to be dumped – squares are directories, circles are files – shaded items, modified since last dump – each directory & file labeled by i-node number File that has not changed 31 File System Reliability (2) Bit maps used by the logical dumping algorithm 32 File System Reliability (3) • File system states (a) consistent (b) missing block (c) duplicate block in free list (d) duplicate data block 35 Log-Structured File Systems • With CPUs faster, memory larger – disk caches can also be larger – increasing number of read requests can come from cache – thus, most disk accesses will be writes • LFS Strategy structures entire disk as a log – have all writes initially buffered in memory – periodically write these to the end of the disk log – when file opened, locate i-node, then find blocks 36 Example File Systems CD-ROM File Systems The ISO 9660 directory entry 37 The CP/M File System (1) Memory layout of CP/M 40 The MS-DOS File System (2) • Maximum partition for different block sizes • The empty boxes represent forbidden combinations 41 The Windows 98 File System (1) The extended MOS-DOS directory entry used in Windows 98 Bytes 42 The Windows 98 File System (2) An entry for (part of) a long file name in Windows 98 Bytes Checksum 45 The UNIX V7 File System (2) A UNIX i-node 46 The UNIX V7 File System (3) The steps in looking up /usr/ast/mbox
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved