Reading: Washington. Thank You, Hank!
Reading: Washington. Thank You, Hank!
• Tannenbaum: 6.1-6.3
Copyright note: figures and some elements from slides by Hank Levy, CSE451, University of
Washington. Thank you, Hank!
• Silbershatz, Galvin, and Gagne: 11, 12
• sync(fd) • FlushFileBuffers(handle, …)
• Random access
• seek(fd, pos) • SetFilePointer(handle, …) – Random access given a block/byte #
• close(fd) • CloseHandle(handle, …) – Examples: data set for demand paging, libraries, databases. . .
• unlink(name) • DeleteFile(name)
• Keyed/Indexed access
• rename(old, new) • CopyFile(name)
– FS contains an index to a particular field of each record in a file
• MoveFile(name) – Apps can find a file based on value in that record (similar to DB)
– Can be considered a form of random access
1
Directories Directories (2)
• Directories provide: • Let’s say you want to open “/one/two/three” in Unix
fd = open(“/one/two/three”, O_RDWR);
– A way for users to organize their files
– A convenient file name space for both users and FS’s
• What goes on inside the Unix file system?
– Open directory “/” (well known, can always find)
• Most file systems support multi-level directories – Search the directory for “one”, get location of “one”
– Naming hierarchies (/, /usr, /usr/local, /usr/local/bin, …) – Open directory “one”, search for “two”, get location of “two”
– Open directory “two”, search for “three”, get loc. of “three”
• Most file systems support the notion of current directory – Open file “three”
– Permissions are checked at each step
2
Contiguous Allocation (2) Linked Allocation
• Contiguous allocation advantages • Linked Allocation
– Sequential and random access are easy
– Link the blocks of the file together as a linked list.
– Low overhead
– Simple – In file descriptor, just keep pointer to first block.
– Few seeks – In each block of file keep pointer to next block.
– Very good sequential access performance
• Advantages?
• Disadvantages:
– Horrible fragmentation!
– Hard to predict needs at file creation time • Disadvantages?
– May over-allocate
– Hard to enlarge files
3
Indexed allocation example Multi-level Indexed Allocation (2)
• Create a ‘tree’ of block pointers to find all the blocks of a • Advantages of Multi-level Indexed Allocation
– Simple
given file: – Easy to implement
– Incremental expansion
– Easy access to small files
0 • Why?
…
1 – Good random access to blocks
…
– Easy to insert blocks in the middle of file
…
13
14
…
…
• Disadvantages
…