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 303-304 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 303
Who can access the file and in what way
Password needed to access the file
ID of the person who created the file
Current owner
Read-only flag
0 for read/write; 1 for read only
Hidden flag
0 for normal; 1 for do not display in listings
System flag
0 for normal files; 1 for system file
Archive flag
0 for has been backed up; 1 for needs to be backed up
ASCII/binary flag
0 for ASCII file; 1 for binary file
Random access flag
0 for sequential access only; 1 for random access
Temporary flag
0 for normal; 1 for delete file on process exit
Lock flags
0 for unlocked; nonzero for locked
Record length
Number of bytes in a record
Key position
Offset of the key within each record
Key length
Number of bytes in the key field
Creation time
Date and time the file was created
Time of last access
Date and time the file was last accessed
Time of last change
Date and time the file was last changed
Current size
Number of bytes in the file
Maximum size
Number of bytes the file may grow to
Figure 4-4.
Some possible file attributes.
4.1.6 File Operations
Files exist to store information and allow it to be retrieved later. Different sys-
tems provide different operations to allow storage and retrieval. Below is a dis-
cussion of the most common system calls relating to files.
The file is created with no data. The purpose of the call is to
announce that the file is coming and to set some of the attributes.
When the file is no longer needed, it has to be deleted to free
up disk space. There is always a system call for this purpose.
Before using a file, a process must open it. The purpose of the
call is to allow the system to fetch the attributes and list of disk
addresses into main memory for rapid access on later calls.
When all the accesses are finished, the attributes and disk ad-
dresses are no longer needed, so the file should be closed to free up
internal table space. Many systems encourage this by imposing a

Page 304
SEC. 4.1
maximum number of open files on processes.
A disk is written in
blocks, and closing a file forces writing of the file’s last block, even
though that block may not be entirely full yet.
Data are read from file. Usually, the bytes come from the cur-
rent position.
The caller must specify how many data are needed and
must also provide a buffer to put them in.
Data are written to the file again, usually at the current posi-
tion. If the current position is the end of the file, the file’s size in-
creases. If the current position is in the middle of the file, existing
data are overwritten and lost forever.
This call is a restricted form of
It can add data only to
the end of the file. Systems that provide a minimal set of system calls
rarely have
, but many systems provide multiple ways of
doing the same thing, and these systems sometimes have
For random-access files, a method is needed to specify from
where to take the data. One common approach is a system call,
that repositions the file pointer to a specific place in the file. After this
call has completed, data can be read from, or written to, that position.
Get attributes
Processes often need to read file attributes to do their
work. For example, the UNIX
program is commonly used to
manage software development projects consisting of many source
files. When
is called, it examines the modification times of all
the source and object files and arranges for the minimum number of
compilations required to bring everything up to date.
To do its job, it
must look at the attributes, namely, the modification times.
Set attributes
Some of the attributes are user settable and can be
changed after the file has been created. This system call makes that
possible. The protection-mode information is an obvious example.
Most of the flags also fall in this category.
It frequently happens that a user needs to change the name
of an existing file. This system call makes that possible.
It is not al-
ways strictly necessary, because the file can usually be copied to a
new file with the new name, and the old file then deleted.
4.1.7 An Example Program Using File-System Calls
In this section we will examine a simple UNIX program that copies one file
from its source file to a destination file. It is listed in Fig. 4-5. The program has
minimal functionality and even worse error reporting, but it gives a reasonable idea
of how some of the system calls related to files work.

Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
Concordia University
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