Modern Operating Systems by Herbert Bos ...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Showing 308-309 out of 1137
Modern Operating Systems by Herbert Bos and Andrew...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Modern Operating Systems by Herbert...
Modern_Operating_Systems_by_Herbert_Bos_and_Andrew_S._Tanenbaum_4th_Ed.pdf-M ODERN O PERATING S YSTEMS
Page 308
SEC. 4.2
DIRECTORIES
277
Root directory
A
B
C
D
Figure 4-6.
A single-level directory system containing four files.
Consequently, a way is needed to group related files together.
A professor, for ex-
ample, might have a collection of files that together form a book that he is writing,
a second collection containing student programs submitted for another course, a
third group containing the code of an advanced compiler-writing system he is
building, a fourth group containing grant proposals, as well as other files for elec-
tronic mail, minutes of meetings, papers he is writing, games, and so on.
What is needed is a hierarchy (i.e., a tree of directories).
With this approach,
there can be as many directories as are needed to group the files in natural ways.
Furthermore, if multiple users share a common file server, as is the case on many
company networks, each user can have a private root directory for his or her own
hierarchy. This approach is shown in Fig. 4-7. Here, the directories
A
,
B
, and
C
contained in the root directory each belong to a different user, two of whom have
created subdirectories for projects they are working on.
User
directory
User subdirectories
C
C
C
C
C
C
B
B
A
A
B
B
C
C
C
B
Root directory
User file
Figure 4-7.
A hierarchical directory system.
The ability for users to create an arbitrary number of subdirectories provides a
powerful structuring tool for users to organize their work. For this reason, nearly
all modern file systems are organized in this manner.
4.2.3 Path Names
When the file system is organized as a directory tree, some way is needed for
specifying file names. Two different methods are commonly used.
In the first
method, each file is given an
absolute path name
consisting of the path from the


Page 309
278
FILE SYSTEMS
CHAP. 4
root directory to the file. As an example, the path
/usr/ast/mailbox
means that the
root directory contains a subdirectory
usr
, which in turn contains a subdirectory
ast
, which contains the file
mailbox
.
Absolute path names always start at the root
directory and are unique.
In UNIX the components of the path are separated by /.
In Windows the separator is \ .
In MULTICS it was >.
Thus, the same path name
would be written as follows in these three systems:
Windows
\usr\ast\mailbox
UNIX
/usr/ast/mailbox
MULTICS
>usr>ast>mailbox
No matter which character is used, if the first character of the path name is the sep-
arator, then the path is absolute.
The other kind of name is the
relative path name
.
This is used in conjunction
with the concept of the
working directory
(also called the
current directory
). A
user can designate one directory as the current working directory, in which case all
path names not beginning at the root directory are taken relative to the working di-
rectory. For example, if the current working directory is
/usr/ast
, then the file
whose absolute path is
/usr/ast/mailbox
can be referenced simply as
mailbox
. In
other words, the UNIX command
cp /usr/ast/mailbox /usr/ast/mailbox.bak
and the command
cp mailbox mailbox.bak
do exactly the same thing if the working directory is
/usr/ast
.
The relative form is
often more convenient, but it does the same thing as the absolute form.
Some programs need to access a specific file without regard to what the work-
ing directory is.
In that case, they should always use absolute path names.
For ex-
ample, a spelling checker might need to read
/usr/lib/dictionary
to do its work. It
should use the full, absolute path name in this case because it does not know what
the working directory will be when it is called. The absolute path name will always
work, no matter what the working directory is.
Of course, if the spelling checker needs a large number of files from
/usr/lib
,
an alternative approach is for it to issue a system call to change its working direc-
tory to
/usr/lib
, and then use just
dictionary
as the first parameter to
open
. By ex-
plicitly changing the working directory, it knows for sure where it is in the direc-
tory tree, so it can then use relative paths.
Each process has its own working directory, so when it changes its working di-
rectory and later exits, no other processes are affected and no traces of the change
are left behind in the file system.
In this way, it is always perfectly safe for a proc-
ess to change its working directory whenever it finds that to be convenient. On the
other hand, if a
library procedure
changes the working directory and does not
change back to where it was when it is finished, the rest of the program may not


Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Concordia University
Concordia_University
School:
Operating_Systems
Course:
Great resource for chem class. Had all the past labs and assignments
Leland P.
Santa Clara University
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades

Students also viewed documents