150 likes | 211 Views
Project 5 Roadmap. Logical disk layout. Directory Entry. flags. GOSFS_Dir_Entry. GOSFS_Dir_Entry. GOSFS_Dir_Entry. GOSFS_Dir_Entry. GOSFS_Dir_Entry. GOSFS_Dir_Entry. GOSFS_Dir_Entry. GOSFS_Dir_Entry. blockList[10]. size. filename[128]. acl[10]. data blocks. Directory.
E N D
Directory Entry flags GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry blockList[10] size filename[128] acl[10] data blocks Directory MAX_FILES_PER_DIR Directory Block
8 9 7 6 3 4 5 Data storage –Direct Mapping Data storage – Direct Mapping GOSFS_Dir_Entry.blockList[10] DISK 0 1 4KB data block 2 4KB data block 4KB data block = used 12KB file depicted
Data storage –Single Indirect Data storage – Single Indirect GOSFS_Dir_Entry.blockList[10] DISK 0 0 1 4KB data block 2 3 4 …. 4KB data block 5 6 4KB data block 7 single indirect block 8 4KB data block 9 0 0 1 2 3 4KB data block 4 . . 40KB file depicted . 1022 1023
0 0 1 2 3 4 . . . 1022 1023 Data storage –Double Indirect Data storage – Double Indirect GOSFS_Dir_Entry.blockList[10] DISK 0 0 1 4KB data block single indirect block 2 3 4 4KB data block …. 5 6 4KB data block 7 0 0 0 0 1 1 2 2 8 4KB data block 3 3 4 4 9 . . . . . . 1022 1022 4KB data block 1023 1023 4136KB file depicted double indirect block single indirect block
Data storage - overview • [0,32KB] – use direct mapped blocks only • (32KB,4128KB] – use direct mapped blocks + single indirect blocks • (4128KB,32MB] – use direct mapped blocks + single indirect blocks + double indirect blocks
Format • SYS_FORMAT • Format(char *dev, char *fstype) • Original Disk Layout • Don’t have to do it in init, will be called from user space • Only for GOSFS, not for PFAT
Mount • SYS_MOUNT • vsf.c: Mount(char *devname, char *pathPrefix, char *fstype) • gosfs.c:GOSFS_Mount(struct Mount_Point *mountPoint) • Steps • check superblock validity • fill out mountPoint • might consider using an instance (see PFAT_Instance in pfat.c) • Make sure it works, so that we can test the rest of your project
Syscalls • SYS_OPEN • Open(char *name, int mode) • Not allowed for directories • Create files when appropriate • SYS_OPENDIRECTORY • OpenDirectory(char *path) • Not allowed for files • SYS_CLOSE • Close(int fd) • SYS_DELETE • Delete(char *path) • If path is a non-empty directory and not empty, forbid !
Syscalls • SYS_READ • Read(int fd, char *buffer, int length) • Not allowed for directories • return value • <0, if failure • >=0 , # bytes available • SYS_WRITE • Write(int fd, char *buffer, int length) • Not allowed for directories • “Grow on write” - allocate blocks “on the fly” if past end of file • “Grow minimum needed” – a random seek to the middle of an empty file and a write result in only one allocated block • Synchronous • SYS_READ/SYS_WRITE increase the offset with #bytes read/written
Syscalls • SYS_READENTRY • ReadEntry(int fd,VFS_Dir_Entry *entry) • Read and return information about a single file in a directory • Advance one file entry at a time, return –1 when the directory ends • Use File->filePos to remember current entry • Seek specifies number of entries to skip (i.e. seek(5) would then read the 5th entry) • Not allowed for files
Syscalls • SYS_STAT • Stat(char *path, VFS_File_Stat *stat) • Works on an unopened file • Simply copy verbatim from GOSFS_Dir_Entry • SYS_FSTAT • FStat(int fd, VFS_File_Stat *stat) • Works on an open file • Simply copy verbatim from GOSFS_Dir_Entry • SYS_SEEK • Seek(int fd, int offset) • Implement only absolute semantics for offset • Allowed to past end of file
Syscalls • SYS_CREATEDIR • CreateDirectory(char *name) • Should NOT go recursively • e.g. CreateDirectory("/d/d1/d2/d3/d4”); • SYS_SYNC • Sync(void) • Should synchronize any outstanding data to disk
The Buffer Cache • idea: keep some disk blocks in memory (buffers); memory is much faster to read/write than disk • buffer life cycle • Get - Modify - Release • bufcache.c • Create_FS_Buffer_Cache(struct Block_Device *dev,…) • Get_FS_Buffer() • Modify_FS_Buffer() • Sync_FS_Buffer() • Release_FS_Buffer()