ILLINOIS CS 241 - System Programming File System II

Unformatted text preview:

CS241 System Programming File System IIContentDirectoryDirectory ContentsSingle Level DirectoryProblems With Single Level DirectoryTwo-level DirectorySlide 8Tree Structured DirectoriesSlide 10Acyclic Graph Structured DirectoriesAcyclic Graph Structured DirectoriesGeneral Graph Structured DirectoriesSlide 14UNIX File System Structure (Example)Path NamesLooking up absolute path nameThe UNIX V7 File SystemDirectory OperationsUNIX Directory EntryUNIX Directory ExampleHard Links and Symbolic LinksHard Link ExampleSymbolic Link ExampleSummaryCS241 System ProgrammingFile System IIKlara NahrstedtLecture 213/10/200601/14/19 CS 241 - System Programming, Klara Nahrstedt2Content File systems basic conceptsSummary01/14/19 CS 241 - System Programming, Klara Nahrstedt3DirectoryTo keep track we need –Directories –FoldersDirectory is a file containing correspondence between filenames and file locations01/14/19 CS 241 - System Programming, Klara Nahrstedt4Directory Contentsfile name symbolic namefile type indicates format of filelocation device and locationsizeprotectioncreation, access, and modification dateowner identification01/14/19 CS 241 - System Programming, Klara Nahrstedt5Single Level Directory01/14/19 CS 241 - System Programming, Klara Nahrstedt6Problems With Single Level Directorymore than one userlarge file systems moving files from one system to anothername clashesmodularity01/14/19 CS 241 - System Programming, Klara Nahrstedt7Two-level Directoryintroduced to remove naming problems between usersfirst level contains list of user directoriessecond level contains user filessystem files kept in separate directory or level 1sharing accomplished by naming other users files01/14/19 CS 241 - System Programming, Klara Nahrstedt8Two-level Directory01/14/19 CS 241 - System Programming, Klara Nahrstedt9Tree Structured Directoriesarbitrary depth of directoriesleaf nodes are filesinterior nodes are directoriespath name lists nodes to traverse to find nodeuse absolute paths from rootuse relative paths from current working directory pointer01/14/19 CS 241 - System Programming, Klara Nahrstedt10Tree Structured Directories01/14/19 CS 241 - System Programming, Klara Nahrstedt11Acyclic Graph Structured DirectoriesAcyclic graphs allow sharingtwo users can name same fileimplementation by links - use logical names of files (file system and file)implementation by symbolic links maps pathname into a new pathnameduplicate paths complicate backup copiesneed reference counts for hard links01/14/19 CS 241 - System Programming, Klara Nahrstedt12Acyclic Graph Structured Directories01/14/19 CS 241 - System Programming, Klara Nahrstedt13General Graph Structured Directoriescyclesmore flexiblemore costlyneed garbage collection (circular structures)must prevent infinite searches01/14/19 CS 241 - System Programming, Klara Nahrstedt14General Graph Structured Directories01/14/19 CS 241 - System Programming, Klara Nahrstedt15UNIX File System Structure (Example)dev etchome optusrvarSpecial filesFor devicesSpecificsFor systemUserdirectoriesApplicationpackagesSharable filesVarying Files(e.g. logs)01/14/19 CS 241 - System Programming, Klara Nahrstedt16Path NamesAbsolute names:•/usr/ast/mailbox•Unique•Start from rootRelative names:•Working/current directory • mailboxExamples:•cp /usr/lib/dictionary .•cp ../lib/dictionary .01/14/19 CS 241 - System Programming, Klara Nahrstedt17Looking up absolute path nameLookup absolute path name /usr/ast/file;System –Locate the root directory –Lookup string ‘usr’ in the root directory, get i-node of the /usr directory–Fetch i-node of /usr and extract disk blocks –Search for the string ‘ast’ in /usr, once the entry is found, the i-node number for /usr/ast directory is taken from it–Read i-node of /user/ast and extract directory blocks–Lookup ‘file’ and find i-node of ‘file’Conclusion: use of a relative path name is not only more convenient, but also saves a substantial amount of work for the system!!!01/14/19 CS 241 - System Programming, Klara Nahrstedt18The UNIX V7 File System The steps in looking up /usr/ast/mbox01/14/19 CS 241 - System Programming, Klara Nahrstedt19Directory Operations1. Create•Direction creation•Empty except . And ..2. Delete•Only empty directory can be deleted in some systems•Directory with . And .. Is considered empty3. Opendir•This program opens the directory to list all files in the directory•Before a directory can be read, it must be opened, analogous to opening and reading a file4. Closedir•When a directory has been read, it should be closed to free up internal table space5. Readdir•Returns the next entry in the open directory6. Rename•Rename directory just like any other file7. Link•Linking is a technique that allows a file to appear in more than one directory•Creates a link between an existing file and the name specified by the path•Link of this kind is called ‘hard link’•Each file which has links pointed to it, includes a reference counter in its i-node to keep track of the number of directory entries containing the file8. Unlink•If the file being unlinked is only present in one directory, it is removed from the file system•If the file is present in multiple directories, only the path name specified is removed.01/14/19 CS 241 - System Programming, Klara Nahrstedt20UNIX Directory Entry A UNIX V7 directory entry01/14/19 CS 241 - System Programming, Klara Nahrstedt21UNIX Directory Example 12345 Name 1inode nameDirectory entry in /dirAInode 1234523567“This is the text in the File.”Block 2356701/14/19 CS 241 - System Programming, Klara Nahrstedt22Hard Links and Symbolic LinksA file may be accessed through multiple paths–Such linking between multiple names is known as link (also known as hard link)UNIX allows users to make a new directory entry that points to an existing file4.3 BSD also supported symbolic links, which are files containing the path name of another file or directory–Soft (symbolic) links, unlike hard links, could point to directories and could cross file-system boundaries01/14/19 CS 241 - System Programming, Klara Nahrstedt23Hard Link ExampleGrand Parent directoryFile inode 12345This is the Text in theFile. 23567Block 2356712345 Name 1Directory entry in /dirADirectory entry in /dirB12345Name 201/14/19 CS 241 - System Programming, Klara


View Full Document

ILLINOIS CS 241 - System Programming File System II

Download System Programming File System II
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view System Programming File System II and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view System Programming File System II 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?