100 likes | 366 Views
ThreadOS: File System Implementation. Joe McCarthy. File-System Structure. File system interface provides applications with various system calls and commands such as open, write, read, seek, etc..
E N D
ThreadOS:File System Implementation Joe McCarthy CSS 430: Operating Systems - File System Implementation
File-System Structure • File system interface provides applications with various system calls and commands such as open, write, read, seek, etc.. • File system maintains disk space in blocks and allocates available blocks to each stream-oriented file. • Basic file system (BIOS) maintains data in physical blocks • Device driver reads / writes disk blocks which consists of one (or more) sector(s). • Disk maintains physical block locations indexed by drive#, cylinder#, track# and sector# track sector cylinder CSS 430: Operating Systems - File System Implementation
File-System Implementation • Boot control block contains info needed by system to boot OS from that volume • Volume control block contains volume details • # blocks, block size, free block count/pointers • Directory structure organizes the files • Per-file File Control Block (FCB) contains many details about the file CSS 430: Operating Systems - File System Implementation
In-Memory File System Structures CSS 430: Operating Systems - File System Implementation
Indexed Allocation outer-index file index table CSS 430: Operating Systems - File System Implementation
Combined Scheme: UNIX UFS 4K bytes per block CSS 430: Operating Systems - File System Implementation
ThreadOS Superblock & Inodes Superblock int totalBlocks; int totalInodes; int freeList; Block #0 Free Block #x Free Block #y Free Block #z Inode #0 32bytes Inode #1 Block #1 Inode #15 / root directory Block #2 Inode #inodeBlocks -1 Block #(totalBlocks – 1) css430 file-system implementation
ThreadOS Root Directory (“/”) • Directory() • Initialize “/” directory • bytes2directory( byte data[]) • Initialize directory with byte[] which have been retrieved from disk • directory2bytes() • Converts directory information into byte[] • ialloc( String filename ) • Allocate an iNumber for filename • ifree( short iNumber ) • Deallocate the iNumber • namei( String filename ) • Return filename’s iNumber Entry[] fsizes fnames (iNumber) 0 1 2 3 4 5 6 7 8 9 10 inodeBlock-1 1 4 4 4 4 5 5 6 6 9 6 6 5 / init fsck clri motd mount mknod passwd umount checklist fsdblb config getty css430 file-system implementation
CSS430 ThreadOS File System Thread int fd = SysLib.open(“fileA”, mode); SysLib.read(fd, …); A simplified structure of Unix file system TCB 0 1 2 3 31 stdin stdout Inode: length count 1 direct[11] indirect stderr struct file: count 1 inode Disk User file Descriptor table Inode File Table css430 file-system implementation