Indicate type of FS inumber of its root dir Will be read first when file system

Indicate type of fs inumber of its root dir will be

This preview shows page 33 - 51 out of 63 pages.

Indicate type of FS & inumber of its root dir Will be read first when file system is mounted 33
Image of page 33
inumber Each inode is identified by a number Low-level number of file name Can figure out location of inode from inumber 34
Image of page 34
inumber => location inumber = 32 => address: offset in bytes from the beginning => which sector? 35
Image of page 35
inumber => location of inode Address: 12K + 32 * 256 = 20K Sector #: 20K/512 = 40 more generally ( inodeStartAddress + inumber inode size)/sector size 36
Image of page 36
inode => location of data blocks A number of direct pointers E.g., 8 pointers, each points to a data block Enough for 8*4K = 32K size of file Also has a slot for indirect pointer Pointing to a data block storing direct pointers Assume 4 bytes for block address (e.g., represented in CHS), so 1024 pointers/block Now file can have (8 + 1024) blocks or 4,128KB 37
Image of page 37
Multi-level index Pointers may be organized into multiple levels Indirect pointer (as in previous slide) Inode (pointer1, pointer2, …, indirect pointer) Indirect pointer -> a block of direct pointers Double indirect pointers Inode (pointer1, pointer2, …, indirect pointer) Indirect pointer -> a block of indirect pointers instead -> each points to a block of direct pointers Triple indirect pointers Indirect pointer -> a block of indirect pointers -> each points to a block of indirect pointers -> each points to a block of direct pointers 38
Image of page 38
Double Indirect Pointers 39 inode Block of indirect pointers Indirect pointer Indirect pointer Block of direct pointers direct pointers
Image of page 39
Advantages of multi-level index Grow to more levels as needed Direct pointers handle most of the cases Many files are small 40
Image of page 40
Directory organization Directory itself stored as a file For each file in the directory, it stores: name, inumber, record length, string length 41 Actual length
Image of page 41
Record length vs string length String length = # of characters in file name + 1 (for \0: end of string) Record length >= string length Due to entry reuse 42
Image of page 42
Reusing directory entries If file is deleted (using rm command) or a name is unlinked (using unlink command) File is finally deleted when its last (hard) link is removed Then inumber in its directory entry set to 0 (reserved for empty entry) So we know it can be reused 43
Image of page 43
Storing a directory Also as a file with its own inode + data block inode: file type: directory (instead of regular file) pointer to block(s) in data region storing directory entries 44
Image of page 44
Roadmap Files and directories CRUD operations Implementation Data structures: how to organize blocks, e.g., into array/tree Access methods : turn system calls to operations on data structures 45
Image of page 45
Open for read fd = open("/foo/bar", O_RDONLY) 46
Image of page 46
Open for read fd = open("/foo/bar", O_RDONLY) Need to locate inode of the file "/foo/bar" Assume inumber of root, say 2, is known (e.g., when the file system is mounted) 47
Image of page 47
Open for read 1. Read inode and content of / (2 reads) Look for "foo" in / -> foo's inumber 2. Read inode and content of /foo (2 reads) Look for "bar" in /foo -> bar's inumber 3. Read inode of /foo/bar (1 read) Permission check + allocate file descriptor 48
Image of page 48
Cost of open() Need 5 reads of inode/data block 49
Image of page 49
File-open table per process File descriptor File name Inumber Position offset 3 /foo/bar 32382 0 4 /foo/more 48482 512 50
Image of page 50
Image of page 51

You've reached the end of your free preview.

Want to read all 63 pages?

  • Fall '14

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes