13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Physical representation 2176.2 File layoutEach file on the disk is associated with ancillary information stored in a file descriptor.It might have the following structure:1 type2 FileDescriptorType =3 record4 Permissions : AccessRights; { may be organized in groups }5 FileType : (Data, Directory, Indirect, Device)6 Length : integer; { in bytes or words }7 CreationTime : Date; { when first created }8 ModificationTime : Date; { when last written }9 AccessTime : Date; { when last opened }10 ReferenceCount : integer; { number of aliases }11 Layout : array of Extent; { tells which physical (disk)12 blocks correspond to which virtual (data) blocks }13 end;The associated directory structure might look like this:14 const15 MaxFileNameSize = ... { whatever }16 type17 DirectoryEntry =18 record19 Name : array 1:MaxFileNameSize of char;20 { For simplicity, we assume only one component }21 Version : integer;22 Descriptor : FileDescriptorIndex;23 end;24 Directory = array of DirectoryEntry;The FileType field (line 5) is used to distinguish major categories of files. Directories areused in a very different way from data files. Device files are usually not files at all but aconvenient way to unify transput with the file system. On some operating systems, suchas Exec-8 for the Univac 1100 computer, the Data type is further categorized as ‘‘sourceprogram,’’ ‘‘object code,’’ or ‘‘load image.’’ One can imagine other categories as well,such as ‘‘mail file’’ and ‘‘command file.’’ In those operating systems that do not use thefile descriptor to distinguish these different uses for data files, they can still be distinguishedby the file name (using conventions we discussed earlier) or by the file contents.The Layout field (line 11) is used to find the physical block that holds any givenbyte of the file. For the purpose of sequential access, each physical block can also containthe block number of its successor. This extra information can reduce the number ofSeek operations needed to read an entire file sequentially. Of course, such redundantinformation must be updated when the contents of the file change (for example, whennew data are written at the end). If this redundant information (which may be treated as ahint) is wrong, the truth (that is, the corresponding absolute) may be deduced from thefile descriptor. At the worst, a salvage operation may be able to reconstruct the file fromextra information stored in each data block identifying the file to which it belongs.The declarations above are intended for file structures that allow aliases. Eachalias for the file has its own directory entry, and all those entries point to the same file

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!