Project 5 Roadmap Logical disk layout Directory Entry GOSFS_Dir_Entry blockList[10] flags MAX_FILES_PER_DIR size filename[128] acl[10] data blocks GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry GOSFS_Dir_Entry Directory Block Directory Data storage –Direct Data storage – Direct Mapping Mapping GOSFS_Dir_Entry.blockList[10] 0 1 2 3 4 5 6 7 8 9 12KB file depicted DISK 4KB data block 4KB data block 4KB data block = used Data storage Indirect Data storage –Single – Single Indirect GOSFS_Dir_Entry.blockList[10] 40KB file depicted 4KB data block …. 0 1 2 3 4 5 6 7 8 9 DISK 4KB data block 4KB data block single indirect block 0 1 2 3 4 . . . 1022 1023 4KB data block 4KB data block Data storage –Double Data storage – Double Indirect Indirect GOSFS_Dir_Entry.blockList[10] 4136KB file depicted 4KB data block single indirect block 0 1 2 3 4 . . . 1022 1023 …. 0 1 2 3 4 5 6 7 8 9 DISK 4KB data block 4KB data block 0 1 2 3 4 . . . 1022 1023 double indirect block 0 1 2 3 4 . . . 1022 1023 single indirect block 4KB data block 4KB data 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 Steps vsf.c: Mount(char *devname, char *pathPrefix, char *fstype) gosfs.c:GOSFS_Mount(struct Mount_Point *mountPoint) 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()