170 likes | 307 Views
Week 8. February 26, 2004 Adrienne Noble. Important Dates. Due Friday, Feb 27 Homework 8 Due Wednesday, March 10 Project 4. Questions?. Lecture Homework 8 Project 4. Project 4. Modify a Linux file system Currently, 13KB files 8000 distinct files 30 character file names
E N D
Week 8 February 26, 2004 Adrienne Noble
Important Dates • Due Friday, Feb 27 • Homework 8 • Due Wednesday, March 10 • Project 4
Questions? • Lecture • Homework 8 • Project 4
Project 4 • Modify a Linux file system • Currently, • 13KB files • 8000 distinct files • 30 character file names • Your project: • Increase maximum file size • Increase maximum file name length
Where to start • Go through the mechanical aspects of compiling and running the file system • How to link a module into the linux source tree. • Refresh your VMWare skills • Read over the code • cse451fs.h is a good place to start
A file system on disk • Given a file system on a 4MB disk with 1KB blocks (4096 blocks total), how would you represent the following on disk? • / • etc • passwd • fstab • bin • sh • date
Other specifics • Only one partition • Used for the cse451fs • File sizes are as follows: • /etc/passwd: 1024 bytes • /etc/fstab: 100 bytes • /bin/sh: 10,000 bytes • /bin/date: 5,000 bytes • Structure on disk
Sizes on disk 1 1 1 85 4008
Boot Block • Contains the bootloader executable • Not really part of the file system, so we won’t discuss it today
Superblock • Contains the master information about the file system (superblock recorde) and the inode map • Superblock record has the following format: (from cse451fs.h) struct cse451_super_block { __u16 s_nNumInodes; // inode map is tail of superblock __u16 s_nDataMapStart; // block # of first data map block __u32 s_nDataMapBlocks; // data map size, in blocks __u32 s_nInodeStart; // block # of first inode block __u32 s_nNumInodeBlocks; // number of blocks of inodes __u32 s_nDataBlocksStart; // block # of first data block __u32 s_nDataBlocks; // number of blocks of data __u32 s_nBusyInodes; // number of inodes in use __u16 s_magic; // magic number char s_imap[0]; // name for inode map };
Inode Map • Tracks which inodes are currently in use • We have 3 directories and 4 files • Total of 7 inodes required • Possible inode map would have the first 7 bits in the 33rd bype of the superblock set to 1, with the remaining 7937 bits set to 0
Data Map • Tracks which data blocks are currently in use – just a bit array
Inode Blocks • Only 7 inodes allocated • Assuming inode map like before, the first 7 inodes are valid • These fit on a single block (7*64<1024) • Inodes have the following format: (from cse451fs.h) struct cse451_inode { __u16 i_mode; __u16 i_nlinks; __u16 i_uid; __u16 i_gid; __u32 i_filesize; __u32 i_datablocks[CSE451_NUMDATAPTRS]; };
Data Blocks • First 20 data blocks are in use • File blocks contain arbitrary data (whatever the file contains) • Directory blocks contain the following: struct cse451_dir_entry { __u16 inode; char name[CSE451_MAXDIRNAMELENGTH]; };