DOC PREVIEW
CMU CS 15410 - File System (Interface)

This preview shows page 1-2-16-17-18-33-34 out of 34 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15-410, F’04- 1 -File System (Interface)Nov. 10, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL27_Filesystem15-410“...RADIX-50??...”15-410, F’04- 2 -SynchronizationTodayTodayChapter 11, File system interfaceOk to skip: remote/distributed (11.5.2!!)Also read Chapter 13Also read Chapter 13Mght help demystify readline() some15-410, F’04- 3 -SynchronizationTwo interesting papers about disksTwo interesting papers about diskshttp://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdfGoogle for “200 ways to revive a hard drive”15-410, F’04- 4 -What's a file?Abstraction of Abstraction of persistent storagepersistent storageHide details of storage devicessector addressing: CHS vs. LBASCSI vs. IDEHide details of allocation/location on a storage deviceLogicalLogical grouping of data grouping of dataMay be physically scatteredPrograms, dataPrograms, dataSome internal structureSome internal structure15-410, F’04- 5 -Typical file attributesName – 14? 8.3? 255?Name – 14? 8.3? 255?Unicode? ASCII? 6-bit? RADIX-50?Identifier - “file number”Identifier - “file number”Type (or not)Type (or not)Location – device, block listLocation – device, block listSize – real or otherwiseSize – real or otherwiseProtection – Who can do what?Protection – Who can do what?Time, date, last modifier – monitoring, curiousityTime, date, last modifier – monitoring, curiousity15-410, F’04- 6 -“ Extended” file attributesBSD UnixBSD Unixarchivednodumpappend-only (by user/by operating system)immutable (by user/by operating system)MacOSMacOSicon color15-410, F’04- 7 -Operations on FilesCreate – locate space, enter into directoryCreate – locate space, enter into directoryWrite, Read – according to position pointer/cursorWrite, Read – according to position pointer/cursorSeek – adjust position pointerSeek – adjust position pointerDelete – remove from directory, release spaceDelete – remove from directory, release spaceTruncateTruncateTrim data from endOften all of itAppend, RenameAppend, Rename15-410, F’04- 8 -Open-file StateExpensive to specify name for each read()/write()Expensive to specify name for each read()/write()String-based operationDirectory look-up“ Open-file” structure stores“ Open-file” structure storesFile-system / partitionFile-system-relative file numberRead vs. writeCursor position15-410, F’04- 9 -Open files (Unix Model)“In-core”“In-core” file state file stateMirror of on-disk structureFile number, size, permissions, modification time, ...Housekeeping info Back pointer to enclosing file system Pointer to disk device hosting the file Who holds locks on ranges of fileHow to access file (vector of methods)Pointer to file's type-specific dataSharedShared when file is opened multiple times when file is opened multiple times15-410, F’04- 10 -Open files (Unix Model)“ Open file”“ Open file” state (result of one open() call) state (result of one open() call)Access mode (read vs. write, auto-append, ...)Credentials of process (when it opened the file)Cursor positionPointer to underlying “ open file”SharedShared by multiple processes by multiple processes “ copied” by fork() inherited across exec()15-410, F’04- 11 -Exampleint fd1, fd2, fd3;off_t pos2, pos3;char buf[10];fd1 = open(“foo.c”, O_RDONLY, 0);fd2 = dup(fd1);fd3 = open(“foo.c”, O_RDONLY, 0);read(fd1, &buf, sizeof (buf));pos2 = lseek(fd2, 0L, SEEK_CUR);/*10*/pos3 = lseek(fd3, 0L, SEEK_CUR);/*0*/15-410, F’04- 12 -“ Open File” vs. “ In-Core File”Processfd1: 3fd2: 4fd3: 5012345vnode #334readers 2writers 0ttyp5rows: 24cols: 80r/or/wPos 10Pos 015-410, F’04- 13 -File types (or not)GoalGoalAvoid printing a binary executable fileFind program which “understands” a file selected by userDerive “ type” from file namesDerive “ type” from file names*.exe are executable, *.c are CTag file with type informationTag file with type informationMacOS: 4-byte type, 4-byte creatorUnix: Both/neither – Leave it (mostly) up to usersUnix: Both/neither – Leave it (mostly) up to users15-410, F’04- 14 -File StructureWhat's What's inin a file? a file?Stream of bytes? What character set? US-ASCII? Roman-1? Unicode?Stream of records?Array of records? Tree of records?Record structure?Record structure?End of “ line” CR, LF, CR+LFFixed-length? Varying? Bounded?15-410, F’04- 15 -File Structure - UnixProgram loader Program loader needs to knowneeds to know about executables about executables“ Magic numbers” in first two bytes obsolete A.OUT types - OMAGIC, NMAGIC, ZMAGIC ELF #! - scriptOtherwise, Otherwise, array of bytesarray of bytesUser/application remembers meaning (hopefully!)For a good time...For a good time...Try the “ file” commandRead /usr/share/magic Marvel at the dedication of the masses15-410, F’04- 16 -File Structure – MacOSData forkData forkArray of bytesApplication-dependent structureResource forkResource forkTable of resourcesIcon, Menu, Window, Dialog boxMany resources are widely used & understoodDesktop program displays icons from resource fork15-410, F’04- 17 -Access MethodsProvided by OS or optional program libraryProvided by OS or optional program librarySequentialSequentialLike a taperead() next, write() next, rewind()Sometimes: skip forward/backwardDirect/relativeDirect/relativeArray of fixed-size recordsRead/write any record, by #15-410, F’04- 18 -Access Methods – IndexedFile contains File contains recordsrecordsRecords contain Records contain keyskeysIndexIndex maps keys maps keys ⇒⇒ records recordsSort data portion by keyBinary search in multi-level listFancy extensionsFancy extensionsMultiple keys, multiple indicesAre we having a database yet?Missing: relations, triggers, consistency, transactions, ...Unix equivalent: dbm/ndbm/gdbm/bdb/...15-410, F’04- 19 -Directory OperationsLookup(“ index.html” )Lookup(“ index.html” )Create(“ index.html” )Create(“ index.html” )Delete(“ index.html” )Delete(“ index.html” )Rename(“ index.html” , “ index.html~” );Rename(“ index.html” , “ index.html~” );Iterate over directory contentsIterate over directory contentsScan file systemScan file systemUnix “ find” commandBackup


View Full Document

CMU CS 15410 - File System (Interface)

Download File System (Interface)
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 File System (Interface) 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 File System (Interface) 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?