DOC PREVIEW
CMU CS 15410 - L25_Filesystem

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:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 3415-410, S’04- 1 -File System (Interface)Mar. 29, 2004Dave EckhardtDave EckhardtBruce MaggsBruce MaggsL25_Filesystem15-410“...RADIX-50??...”15-410, S’04- 1 -SynchronizationCheckpoint 3Checkpoint 3Due midnight tonightSummary – “Where are you now, where will you be”Details – announce bboardTodayTodayChapter 11, File system interfaceOk to skip: remote/distributed (11.5.2!!)Don't forget about Chapter 13Don't forget about Chapter 13Reviewing might help demystify readline() someDon't forget about reading schedule on web siteDon't forget about reading schedule on web site15-410, S’04- 1 -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, S’04- 1 -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, S’04- 1 -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, S’04- 1 -“Extended” file attributesBSD UnixBSD Unixarchivednodumpappend-only (by user/by operating system)immutable (by user/by operating system)MacOSMacOSicon color15-410, S’04- 1 -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, S’04- 1 -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 storesOpen-file” structure storesFile-system / partitionFile-system-relative file numberRead vs. writeCursor position15-410, S’04- 1 -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, S’04- 1 -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, S’04- 1 -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, S’04- 1 -“Open File” vs. “In-Core File”Processfd1: 3fd2: 4fd3: 5012345vnode #334readers 2writers 0ttyp5rows: 24cols: 80r/or/wPos 10Pos 015-410, S’04- 1 -File types (or not)GoalGoalAvoid printing a binary executable fileFind program which “understands” a fileFilter file namesFilter file names*.exe are executable, *.c are CTag fileTag fileMacOS: 4-byte type, 4-byte creatorUnix: Both/neither – Leave it (mostly) up to usersUnix: Both/neither – Leave it (mostly) up to users15-410, S’04- 1 -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, S’04- 1 -File Structure - UnixOS OS 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, S’04- 1 -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, S’04- 1 -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, S’04- 1 -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?Unix equivalent: dbm/ndbm/gdbm/bdb/...15-410, S’04- 1 -Directory


View Full Document

CMU CS 15410 - L25_Filesystem

Download L25_Filesystem
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 L25_Filesystem 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 L25_Filesystem 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?