⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p1

📁 UNIX版本6的源代码
💻
📖 第 1 页 / 共 2 页
字号:
the programs which use them, not by the system..s23.2 Directories.esDirectories providethe mapping between the names of filesand the files themselves, and thusinduce a structure on the file system as a whole.Each user has a directory of his own files;he may also create subdirectories to containgroups of files conveniently treated together.A directory behaves exactly like an ordinary file except that itcannot be written on by unprivileged programs, so that the systemcontrols the contents of directories.However, anyone withappropriate permission may read a directory just like any other file..pgThe system maintains several directoriesfor its own use.One of these is the \fIroot\fR directory.All files in the system can be found by tracinga path through a chain of directoriesuntil the desired file is reached.The starting point for such searches is often theroot.Another system directory contains all the programs providedfor general use; that is, all the \fIcommands\fR.As will be seen, however, it is by no means necessarythat a program reside in this directory for itto be executed..pgFiles are named by sequences of 14 orfewer characters.When the name of a file is specified to thesystem, it may be in the form of a.ft Ipath name,.ft Rwhichis a sequence of directory names separated by slashes ``\|/\|''and ending in a file name.If the sequence begins with a slash, the search begins in theroot directory.The name \fI/\|alpha\|/\|beta\|/\|gamma\fR causes the system to searchthe root for directory \fIalpha,\fRthen to search \fIalpha\fR for \fIbeta,\fRfinally to find \fIgamma\fR in \fIbeta\fR.\fIGamma\fR may be an ordinary file, a directory, or a specialfile.As a limiting case, the name ``/\|'' refers to the root itself..pgA path name not starting with ``/\|'' causes the system to begin thesearch in the user's current directory.Thus, the name \fIalpha\|/\|beta\fR specifies the file named \fIbeta\fR insubdirectory \fIalpha\fR of the currentdirectory.The simplest kind of name, for example \fIalpha\fR,refers to a file which itself is found in the currentdirectory.As another limiting case, the null file name refersto the current directory..pgThe same non-directory file may appear in several directories underpossibly different names.This feature is called \fIlinking;\fRa directory entry for a file is sometimes called a link.\*sUNIX\*n differs from other systems in which linking is permittedin that all links to a file have equal status.That is, a file does not exist within a particular directory;the directory entry for a file consists merelyof its name and a pointer to the information actuallydescribing the file.Thus a file exists independently of anydirectory entry, although in practice a file is made todisappear along with the last link to it..pgEach directory always has at least two entries.The name``\|\fB.\|\fR'' in each directory refers to the directory itself.Thus a programmay read the current directory under the name ``\fB\|.\|\fR'' without knowingits complete path name.The name ``\fB\|.\|.\|\fR'' by convention refers to the parent of thedirectory in which it appears, that is, to the directory in whichit was created..pl +1.pgThe directory structure is constrained to have the formof a rooted tree.Except for the special entries ``\|\fB\|.\|\fR'' and ``\fB\|.\|.\|\fR'', each directorymust appear as an entry in exactly one other, which is itsparent.The reason for this is to simplify the writing of programswhich visit subtrees of the directory structure, and moreimportant, to avoid the separation of portions of the hierarchy.If arbitrary links to directories were permitted, it wouldbe quite difficult to detect when the last connection fromthe root to a directory was severed..s2.pl -13.3 Special files.esSpecial files constitute the most unusual feature of the \*sUNIX\*nfile system.Each I/O device supported by \*sUNIX\*nis associated with at least one such file.Special files are read and written just like ordinarydisk files, but requests to read or write result in activation of the associateddevice.An entry for each special file resides in directory \fI/\|dev,\fRalthough a link may be made to one of these filesjust like an ordinary file.Thus, for example,to punch paper tape,one may write on the file \fI\|/\|dev\|/\|ppt\fR.Special files exist for each communication line, each disk,each tape drive,and for physical core memory.Of course,the active disksand the core special file are protected fromindiscriminate access..pgThere is a threefold advantage in treatingI/O devices this way:file and device I/Oare as similar as possible;file and device names have the samesyntax and meaning, so thata program expecting a file nameas a parameter can be passed a devicename; finally,special files are subject to the sameprotection mechanism as regular files..s23.4 Removable file systems.esAlthough the root of the file system is always stored on the samedevice,it is not necessary that the entire file system hierarchyreside on this device.There is a \fImount\fR system request which has two arguments:the name of an existing ordinary file, and the name of a specialfile whose associatedstorage volume (e. g. disk pack) should have the structureof an independent file systemcontaining its own directory hierarchy.The effect of \fImount\fR is to causereferences to the heretofore ordinary fileto refer instead to the root directoryof the file system on the removable volume.In effect, \fImount\fRreplaces a leaf of the hierarchy tree (the ordinary file)by a whole new subtree (the hierarchy stored on theremovable volume).After the \fImount\fR,there is virtually no distinctionbetween files on the removable volume and those in thepermanent file system.In our installation, for example,the root directory resideson the fixed-head disk,and the large disk drive, which contains user's files,is mounted by the system initializationprogram;the four smaller disk drives are availableto users for mounting theirown disk packs.A mountable file system is generated bywriting on its corresponding special file.A utility program is available to createan empty file system,or one may simply copy an existing file system..pgThere is only one exception to the rule of identicaltreatment of files on different devices:no link may exist between one file system hierarchy andanother.This restriction is enforced so as to avoidthe elaborate bookkeepingwhich would otherwise be required to assure removal of the linkswhen the removable volume is finally dismounted.In particular, in the root directories ofall file systems, removable or not, thename``\fB\|.\|.\|\fR''refers to the directory itself instead of to its parent..s23.5 Protection.esAlthough the access control scheme in \*sUNIX\*nis quite simple, it has some unusual features.Each user of the system is assigned a uniqueuser identification number.When a file is created, it is marked withthe user \*sID\*n of its owner.Also given for new filesis a set of seven protection bits.Six of these specifyindependently read, write, and execute permissionfor theowner of the file and for all other users..pgIf the seventh bit is on, the systemwill temporarily change the user identificationof the current user to that of the creator of the file wheneverthe file is executed as a program.This change in user \*sID\*n is effective onlyduring the execution of the program which calls for it.The set-user-\*sID\*n feature providesfor privileged programs which may use filesinaccessible to other users.For example, a program may keep an accounting filewhich should neither be read nor changedexcept by the program itself.If the set-user-identification bit is on for theprogram, it may access the file althoughthis access might be forbidden to other programsinvoked by the given program's user.Since the actual user \*sID\*nof the invoker of any programis always available,set-user-\*sID\*n programsmay take any measures desired to satisfy themselvesas to their invoker's credentials.This mechanism is used to allow users to executethe carefully-writtencommandswhich call privileged system entries.For example, there is a system entryinvokable only by the ``super-user'' (below)which createsan empty directory.As indicated above, directories are expected tohave entries for ``\fB\|.\|\fR'' and ``\fB\|.\|.\|\fR''.The command which creates a directoryis owned by the super-userand has the set-user-\*sID\*n bit set.After it checks its invoker's authorization tocreate the specified directory,it creates it and makes the entriesfor ``\fB\|.\|\fR'' and ``\fB\|.\|.\|\fR''..pgSince anyone may set the set-user-\*sID\*nbit on one of his own files,this mechanism is generallyavailable without administrative intervention.For example,this protection scheme easily solves the \*sMOO\*naccounting problem posed in [\n+r]..pgThe system recognizes one particular user \*sID\*n (that of the ``super-user'') asexempt from the usual constraints on file access; thus (for example)programs may be written to dump and reload the filesystem withoutunwanted interference from the protectionsystem.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -