📄 5.t
字号:
.\" Copyright (c) 1986, 1993.\" The Regents of the University of California. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)5.t 8.1 (Berkeley) 6/8/93.\".ds RH Functional enhancements.NH File system functional enhancements.PPThe performance enhancements to theUNIX file system did not requireany changes to the semantics ordata structures visible to application programs.However, several changes had been generally desired for some time but had not been introduced because they would require users to dump and restore all their file systems.Since the new file system alreadyrequired all existing file systems tobe dumped and restored, these functional enhancements were introduced at this time..NH 2Long file names.PPFile names can now be of nearly arbitrary length.Only programs that read directories are affected by this change.To promote portability to UNIX systems thatare not running the new file system, a set of directoryaccess routines have been introduced to provide a consistentinterface to directories on both old and new systems..PPDirectories are allocated in 512 byte units called chunks.This size is chosen so that each allocation can be transferredto disk in a single operation.Chunks are broken up into variable length records termeddirectory entries. A directory entrycontains the information necessary to map the name of afile to its associated inode.No directory entry is allowed to span multiple chunks.The first three fields of a directory entry are fixed lengthand contain: an inode number, the size of the entry, and the lengthof the file name contained in the entry.The remainder of an entry is variable length and containsa null terminated file name, padded to a 4 byte boundary.The maximum length of a file name in a directory iscurrently 255 characters..PPAvailable space in a directory is recorded by havingone or more entries accumulate the free space in theirentry size fields. This results in directory entriesthat are larger than required to hold theentry name plus fixed length fields. Space allocatedto a directory should always be completely accounted forby totaling up the sizes of its entries.When an entry is deleted from a directory,its space is returned to a previous entryin the same directory chunk by increasing the size of theprevious entry by the size of the deleted entry.If the first entry of a directory chunk is free, then the entry's inode number is set to zero to indicatethat it is unallocated..NH 2File locking.PPThe old file system had no provision for locking files.Processes that needed to synchronize the updates of afile had to use a separate ``lock'' file.A process would try to create a ``lock'' file. If the creation succeeded, then the processcould proceed with its update;if the creation failed, then the process would wait and try again.This mechanism had three drawbacks.Processes consumed CPU time by looping over attempts to create locks.Locks left lying around because of system crashes hadto be manually removed (normally in a system startup command script).Finally, processes running as system administratorare always permitted to create files,so were forced to use a different mechanism.While it is possible to get around all these problems,the solutions are not straight forward,so a mechanism for locking files has been added..PPThe most general schemes allow multiple processesto concurrently update a file.Several of these techniques are discussed in [Peterson83].A simpler technique is to serialize access to a file with locks.To attain reasonable efficiency,certain applications require the ability to lock pieces of a file.Locking down to the byte level has been implemented in theOnyx file system by [Bass81].However, for the standard system applications,a mechanism that locks at the granularity of a file is sufficient..PPLocking schemes fall into two classes,those using hard locks and those using advisory locks.The primary difference between advisory locks and hard locks is theextent of enforcement.A hard lock is always enforced when a program tries toaccess a file;an advisory lock is only applied when it is requested by a program.Thus advisory locks are only effective when all programs accessinga file use the locking scheme.With hard locks there must be some overridepolicy implemented in the kernel.With advisory locks the policy is left to the user programs.In the UNIX system, programs with system administratorprivilege are allowed override any protection scheme.Because many of the programs that need to use locks mustalso run as the system administrator,we chose to implement advisory locks rather than create an additional protection scheme that was inconsistentwith the UNIX philosophy or couldnot be used by system administration programs..PPThe file locking facilities allow cooperating programs to applyadvisory.I sharedor.I exclusivelocks on files.Only one process may have an exclusivelock on a file while multiple shared locks may be present.Both shared and exclusive locks cannot be present ona file at the same time.If any lock is requested whenanother process holds an exclusive lock,or an exclusive lock is requested when another process holds any lock,the lock request will block until the lock can be obtained.Because shared and exclusive locks are advisory only,even if a process has obtained a lock on a file,another process may access the file..PPLocks are applied or removed only on open files.This means that locks can be manipulated withoutneeding to close and reopen a file.This is useful, for example, when a process wishesto apply a shared lock, read some informationand determine whether an update is required, thenapply an exclusive lock and update the file..PPA request for a lock will cause a process to block if the lockcan not be immediately obtained.In certain instances this is unsatisfactory.For example, a process thatwants only to check if a lock is present would require a separatemechanism to find out this information.Consequently, a process may specify that its lockingrequest should return with an error if a lock can not be immediatelyobtained.Being able to conditionally request a lockis useful to ``daemon'' processesthat wish to service a spooling area.If the first instance of thedaemon locks the directory where spooling takes place,later daemon processes caneasily check to see if an active daemon exists.Since locks exist only while the locking processes exist,lock files can never be left active afterthe processes exit or if the system crashes..PPAlmost no deadlock detection is attempted.The only deadlock detection done by the system is that the fileto which a lock is applied must not already have alock of the same type (i.e. the second of two successive callsto apply a lock of the same type will fail)..NH 2Symbolic links.PPThe traditional UNIX file system allows multipledirectory entries in the same file systemto reference a single file. Each directory entry``links'' a file's name to an inode and its contents.The link concept is fundamental;inodes do not reside in directories, but exist separately andare referenced by links.When all the links to an inode are removed,the inode is deallocated.This style of referencing an inode doesnot allow references across physical filesystems, nor does it support inter-machine linkage. To avoid these limitations.I "symbolic links"similar to the scheme used by Multics [Feiertag71] have been added..PPA symbolic link is implemented as a file that contains a pathname.When the system encounters a symbolic link whileinterpreting a component of a pathname,the contents of the symbolic link is prepended to the restof the pathname, and this name is interpreted to yield theresulting pathname.In UNIX, pathnames are specified relative to the rootof the file system hierarchy, or relative to a process'scurrent working directory. Pathnames specified relativeto the root are called absolute pathnames. Pathnamesspecified relative to the current working directory aretermed relative pathnames.If a symbolic link contains an absolute pathname,the absolute pathname is used,otherwise the contents of the symbolic link is evaluatedrelative to the location of the link in the file hierarchy..PPNormally programs do not want to be aware that there is asymbolic link in a pathname that they are using.However certain system utilitiesmust be able to detect and manipulate symbolic links.Three new system calls provide the ability to detect, read, and writesymbolic links; seven system utilities required changesto use these calls..PPIn future Berkeley software distributionsit may be possible to reference file systems located onremote machines using pathnames. When this occurs,it will be possible to create symbolic links that span machines..NH 2Rename.PPPrograms that create a new version of an existingfile typically create thenew version as a temporary file and then rename the temporary filewith the name of the target file.In the old UNIX file system renaming required three calls to the system.If a program were interrupted or the system crashed between these calls,the target file could be left with only its temporary name.To eliminate this possibility the \fIrename\fP system callhas been added. The rename call does the rename operationin a fashion that guarantees the existence of the target name..PPRename works both on data files and directories.When renaming directories,the system must do special validation checks to insurethat the directory tree structure is not corrupted by the creationof loops or inaccessible directories.Such corruption would occur if a parent directory were movedinto one of its descendants.The validation check requires tracing the descendents of the targetdirectory to insure that it does not include the directory being moved..NH 2Quotas.PPThe UNIX system has traditionally attempted to share all availableresources to the greatest extent possible.Thus any single user can allocate all the available spacein the file system.In certain environments this is unacceptable.Consequently, a quota mechanism has been added for restricting theamount of file system resources that a user can obtain.The quota mechanism sets limits on both the number of inodesand the number of disk blocks that a user may allocate.A separate quota can be set for each user on each file system.Resources are given both a hard and a soft limit.When a program exceeds a soft limit,a warning is printed on the users terminal;the offending program is not terminatedunless it exceeds its hard limit.The idea is that users should stay below their soft limit betweenlogin sessions,but they may use more resources while they are actively working.To encourage this behavior,users are warned when logging in if they are overany of their soft limits.If users fails to correct the problem for too many login sessions,they are eventually reprimanded by having their soft limitenforced as their hard limit..ds RH Acknowledgements.sp 2.ne 1i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -