ThreadOS: File System Implementation Joe McCarthy CSS 430:
10 Slides1.25 MB
ThreadOS: File System Implementation Joe McCarthy CSS 430: Operating Systems - File System Implementation 1
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 2
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 3
In-Memory File System Structures CSS 430: Operating Systems - File System Implementation 4
Indexed Allocation outer-index index table CSS 430: Operating Systems - File System Implementation file 5
Combined Scheme: UNIX UFS 4K bytes per block CSS 430: Operating Systems - File System Implementation 6
ThreadOS Superblock & Inodes Block #0 Superblock int totalBlocks; int totalInodes; int freeList; Inode #0 Block #1 Free Block #y Free Block #z 32bytes Inode #1 Inode #15 Block #2 Free Block #x / root directory Inode #inodeBlocks -1 Block #(totalBlocks – 1) css430 file-system implementation 7
ThreadOS Root Directory (“/”) Entry[] (iNumber) 0 1 2 3 4 5 6 7 8 9 10 inodeBlock-1 fsizes fnames 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 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 css430 file-system implementation 8
CSS430 ThreadOS File System Thread int fd SysLib.open(“fileA”, mode); SysLib.read(fd, ); A simplified structure of Unix file system TCB 0 stdin 1 stdout 2 stderr 3 31 User file Descriptor table struct file: count 1 inode File Table css430 file-system implementation Inode: length count 1 direct[11] indirect Inode Disk 9
CSS 430: Operating Systems - File System Implementation 10