210 likes | 678 Views
Minix File System Functions. allocates and de-allocates space for files keeps tracks of disk blocks and free space protects files against unauthorized usage carries out file system calls . File System in the Minix Structure. At which layer of the Minix structure is FS located?.
E N D
Minix File System Functions • allocates and de-allocates space for files • keeps tracks of disk blocks and free space • protects files against unauthorized usage • carries out file system calls Minix File System
File System in the Minix Structure • At which layer of the Minix structure is FS located? Minix File System
File System Messages • The file system accepts 39 types of messages. • All but two are for Minix system calls. • Examples of message types are: • access, chdir, close, creat, link, time, lseek, mount, open, read, rename, unlink, umount, write. Minix File System
File System Layout • The file system is stored on a disk or ona portion of a disk. • It contains the following structures: • boot block • super block • zone bit map • I-nodes • disk blocks with data Minix File System
Boot Block • each file system begins with it • it contains executable code • it starts the process of loading the o.s. • it is marked with a magic number which is a flag indicating if the block is bootable or not. Minix File System
Super-Block on Disk and in Main Memory • Contains the layout of the file system: • number of nodes • number of zones (V1- 16 bit) • number of I-node bit map blocks • number of zone bit map blocks • first data zone • log2 (zone/block) • maximum file size • magic number • padding • number of zones (V2 -32 bit) Minix File System
Super Block in Main Memory • Pointer to I-node of mounted file system. • Pointer to I-node mounted upon. • Device number • System Flags (read only, etc.) • FS version Minix File System
Bit Maps • Are used to keep track of which I-nodes and zones are free. • When the I-node (or zone) is allocated the corresponding bit is set to 1. • When the I-node (or zone) is deallocted the corresponding bit is set to 0. • The I-node 0 is never used. Minix File System
mkfs • Is a utility program that builds a file system. • Example: • mkfs /dev/fd1 144 • creates an empty 1440 block file system on the floppy drive 1. • It zeroes I-node 0 and sets the lowest bit in the bit map to 1, so the file system never tries to allocate I-node 0. Minix File System
Zones vs. blocks • Zones are collections of consecutive blocks on the disk. (2, 4, 8…) • Zone size/block size is always a power of two. • File space is allocated on per/zone basis. • Why? Minix File System
I-Node Structure • Mode - file type and rwx bits • Number of links • Uid • Gid • File size (in bytes) • Access, modification, status change times • Zone 0-7 addresses • Indirect Zone address • Double Indirect Zone address Minix File System
The Block Cache • Minix use a block cache to improve file system performance • The cache is implemented as an array of buffers. • Buffers hold disk block data. • LRU is for block replacement policy • Hash table is used to provide fast access to buffered blocks. • Super-block is written through. Data blocks are not. Minix File System
Directories and Paths • Consist of files 16-byte entries. • First two bytes form a 16-bit I-node number • Remaining 14 bytes are the file name • File name lookup is done one component at a time. • E.g. • To look up the path /usr/me/myprogram, the system looks up / for usr, then usr for me and then me for myprogram. Minix File System
Mounted File System • A flag is set in the memory copy of the I-node of the mounted upon directory. • This flag indicates that the I-node is mounted upon. • The super block of the mounted file system is placed in the super block table. • If a file system is mounted on /usr, how does the lookup work for /usr/me/myprogram? Minix File System
File Descriptors • File descriptor is an index in a filp (file position) table. • Filp table contains file position and I-node pointer of the file and the file mode, and the count of processes using it. • Filp is a shared table that allows for: • sharing files with out sharing file positions • sharing files and share file positions (e.g. between parent and a child) Minix File System
What is a file lock and when it is used? • What is the difference between advisory and mandatory locking? Minix File System
File Locking • Minix support advisory file locking that permits any part or multiple parts of a file to be marked as locked. • Advisory locking means that the o.s. does not enforce the lock but processes are responsible for it. • File_lock table (similar to filp table) is used to keep track of locks. Minix File System
Pipes • Pipes are treated like files that are never written to the disk. • They are used to send data between processes. • A process awaiting data from an empty pipe suspends until there is some data in the pipe. Minix File System
Special Files • Special files such as disks and terminals are accessed via their major device number stored in the I-node. • Major device number is an index into a file system table that maps it onto the corresponding task number. • The file system then send a message with the request to this task and waits for a reply. Minix File System
An Example: The Read System Call • User program executes: • n=read(fd,buffer, nbytes • A library procedure read is called. • This procedure sends message READ to FS and blocks waiting for the reply. • FS calls a local procedure that retrieves data blocks from the cache or from the calls a task to read it from the disk. • Once the data is placed in the cache and in the user’s buffer the reply is send. Minix File System