Class Note for CMPSCI 377 at UMass(22)
Class Note for CMPSCI 377 at UMass(22)
Popular in Course
Popular in Department
This 3 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Massachusetts taught by a professor in Fall. Since its upload, it has received 14 views.
Reviews for Class Note for CMPSCI 377 at UMass(22)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
1 File Systems December 6 2007 11 Introduction A le is just a name that is associated with some data Most of the time les are stored on persistent media like the hard disk but they can also be stored in RAM on USB drives or DVDs lt7s possible to store a bunch of les in the same spot but once we start talking about operating systems there are going to be thousands of les and a at structure is infeasible As a result the heirarchical directory structure was created In UNIX this means that there is a root directory and from it other directories branch downwards 12 Directories A directory is just a special kind of le that contains metadata lenames of the les it contains and inodes which are unique numbers for identifying each le In addition directories may contain other directories This im proves locality since les in a directory will be located close to each other in memory as long as they are small enough A disk may be broken up into superblocks and les within a directory will populate the same superblock if they can all t in the same one Otherwise they are split up on disk and locality is decreased In Windows there are multiple roots one for each device 13 Links In in UNIX Links are used in the lesystem to connect multiple 77 les77 to the actual le What I mean by this is that there exists a le somewhere with an inode and it is possible to have a link to it from another directory There are two kinds of links hard links and symbolic links 131 Hard Links Hard links are a bunch of local pointers to the same le The real le has a refcount that keeps track of how many hard links are pointing to it If the le is deleted it remains on disk until its refcount is 0 This means that all of the hard links to it must be deleted rst before the actual le is deleted If the le is moved or renamed the hard links still work One problem with hard links is cycles which are a side e ect of using refcounts It is possible for les to be hard links to each other and as a result they will never be deleted Similarly directories cannot have hard links pointing to them since a directory could point to itself A possible solution to this is 77garbage collection77 on disk7 but as you can imagine this is a bad idea If garbage collection is slow in RAM7 then obviously it is much worse on disk 132 Symbolic Links Symbolic Links are just another name for something7 sort of like a shortcut These are much more brittle than hard links in that if the le is moved or renamed7 the link won7t work anymore You will get a 404 error or some equivalent If they are so brittle7 why would anyone use them The answer is that hard links only work within the same device7 and this is because they use inodes7 which of course vary across di ferent disks 14 Filesystem Poor man s DB lt7s possible to use the directory structure of the lesystem as a sort of database in the sense that a program can store les that are similar within a subdirectory An example of this is Internet Explorer7 which caches all of the images viewed and puts them in a directory This directory is a hash of the name of the website that these images belong to About 1000 les can t under the same hash subdirectory7 so this is very useful for caching and storing les These les use buffer caches7 which are just in memory caches for les 15 Abstraction Traditionally7 the lesystem maps les to locations on disk However7 its very easy to use les to accomplish other things because of their abstraction and easy to use interface For example7 block devices like disk drives can be represented as a le on disk even though that isn7t what actually is going on Other examples are character devices7 like printers or the console7 the proc lesystem7 and named pipes Plan 9 is an example of a lesystem that abstracts everything into les UNIX uses this abstraction to store devices as les in dev Also7 the proc lesystem stores running processes as les Obviously7 this isn7t really happening because storing running processes on disk as les would be painfully slow7 but it is useful for other programs to think of them in this way Finally7 named pipes FIFO are les that can act like unnamed pipes For example7 consider prompt cat le 7 wc l This counts the lines in a le using a pipe However7 it is possible to achieve this same effect using les as pipes This is useful when it is dif cult to do redirection7 such as compressing data 16 File Metadata Each le has rnetadata associated with it7 likethe date it was created7 the time it was last rnodi ed7 etc Originally7 this also included the time it was last accessed7 but soon this was realized to be a bad idea because it involved writing to disk every time the le was read Once this attribute wasn7t kept in the rnetadata anyrnore7 reading les becarne literally twice as fast In addition7 the rnetadata also includes the les perrnissions7 which are divided into three groups user7 group and everyone else Using the chrnod cornrnand7 one can change these permissions to allow or disallow these three groups from reading7 writing7 or executing a le Finally7 the rnetadata includes the le type Notice the distinction between the le type and the type of content that is in a le Some examples of le type are a directory7 le7 block7 device7 or FIFO ln Windows7 the les are typed by their extension as opposed to in the rnetadata The extension implies the type of the contents in the le7 so it is di erent from the UNIX way of typing les
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'