0% found this document useful (0 votes)
9 views7 pages

File System Interface Overview

Chapter 10 discusses the file system interface, defining a file as a named collection of related information with various attributes such as name, identifier, type, location, size, protection, and timestamps. It outlines basic file operations including creating, writing, reading, deleting, and truncating files, as well as different file access methods like sequential and direct access. The chapter also explains directory structures, including single-level, two-level, tree-structured, acyclic-graph, and general graph directories, along with the concept of file system mounting to integrate multiple file systems into a unified structure.

Uploaded by

Ramana Venkata
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

File System Interface Overview

Chapter 10 discusses the file system interface, defining a file as a named collection of related information with various attributes such as name, identifier, type, location, size, protection, and timestamps. It outlines basic file operations including creating, writing, reading, deleting, and truncating files, as well as different file access methods like sequential and direct access. The chapter also explains directory structures, including single-level, two-level, tree-structured, acyclic-graph, and general graph directories, along with the concept of file system mounting to integrate multiple file systems into a unified structure.

Uploaded by

Ramana Venkata
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 10 – File System Interface

1. What is a file? What are the attributes of a file?


A file is a named collection of related information that is recorded on secondary storage. A
file is the smallest allotment of logical secondary storage; that is data cannot be written to
secondary storage unless they are within a file.
A file’s attributes vary from one OS to another but consist of the following attributes in
common –
 Name: symbolic file name is the only information kept in human readable form.
 Identifier: number which identifies the file within the file system; it is the non human
readable name for the file.
 Type: information is needed for systems that support different types of files.
 Location: this information is a pointer to a device and to the location of the file on
that device.
 Size: the current size of the file
 Protection: Access control information determines who can do reading, writing,
executing etc.
 Time, date and user identification: This information may be kept for creation, last
modification and last use.
2. What is the basic set of file operations?
A file is an abstract data type. OS can provide system calls to create, write, read, reposition,
delete and truncate files.
1. Creating a file – First space in the file system must be found for the file. Second, an
entry for the new file must be made in the directory.
2. Writing a file – To write a file, specify both the name of the file and the information
to be written to the file. The system must keep a write pointer to the location in the
file where the next write is to take place.
3. Reading a file – To read from a file, directory is searched for the associated entry
and the system needs to keep a read pointer to the location in the file where the
next read is to take place. Because a process is either reading from or writing to a
file, the current operation location can be kept as a per process current file position
pointer.
4. Repositioning within a file – Directory is searched for the appropriate entry and the
current file position pointer is repositioned to a given value. This operation is also
known as file seek.
5. Deleting a file – To delete a file, search the directory for the named file. When
found, release all file space and erase the directory entry.
6. Truncating a file – User may want to erase the contents of a file but keep its
attributes. This function allows all attributes to remain unchanged except for file
length.

Prepared for RVR&JC, Second Year CSE-A Students


 Other common operations include appending new information to the end of an
existing file and renaming an existing file. We may also need operations that allow
the user to get and set the various attributes of a file.
 Most of the file operations mentioned involve searching the directory for the entry
associated with the named file.
 To avoid this constant search, many systems require that an open () system call be
made before a file is first used actively.
 OS keeps a small table called the open file table containing information about all
open files.
 When a file operation is requested, the file is specified via an index into this table so
no searching is required.
 When the file is no longer being actively used, it is closed by the process and the OS
removes its entry from the open file table.
 Create and delete are system calls that work with closed files. The open () operation
takes a file name and searches the directory copying the directory entry into the
open file table.
 The open () call can also accept access mode information – create, read – only, read
– write, append – only, etc. This mode is checked against file’s permissions. If the
request mode is allowed, the file is opened for the process.
 The open () system call returns a pointer to the entry in the open file table. This
pointer is used in all I/O operations avoiding any further searching and simplifying
the system call interface.
3. Write about various file access methods.
When a file is used, the information in it must be accessed and read into computer memory.
The information in the file can be accessed in any of the following ways.
Sequential access: Simplest method. Information in the file is processed in order that is
one record after the other. A read operation reads from the portion of the file that is
pointed by file pointer and automatically advances the file pointer. Similarly, a write
appends to the end of the file and advances to the end of the newly written material (the
new end of file). This method is based on a tape model of a file.

Prepared for RVR&JC, Second Year CSE-A Students


Direct Access: A file is made up of fixed length logical records that allow programs to read
and write records rapidly in no particular order. The direct access method is based on a disk
model of a file since disks allow random access to any file block. Direct access files are of
great use for immediate access to large amounts of information. In this method, file
operations must be modified to include block number as a parameter.
Some systems allow only sequential file access; others allow only direct access.
Other Access Methods: Other access methods can be built on top of a direct access
method. These methods generally involve the construction of an index for the file. This
index contains pointers to the various blocks. To find a record in the file, first search the
index and then use the pointer to access the file directly and to find the desired record.
But with large files, the index file itself may become too large to be kept in memory. One
solution is to create an index for the index file. The primary index file would contain
pointers to secondary index files which would point to actual data items.

Figure - Example of index and relative files


4. Explain in detail about various directory structures.
A directory structure organizes and provides information about all the files in the system.
Single-Level Directory
The simplest directory structure is the single level directory. All files are contained in the
same directory which is easy to support and understand. But this implementation has
following limitations when the number of files increases or when the system has more than
one user.
 Since all files are in same directory, all files names must be unique.
 Keeping track of so many files is a difficult task.
 Even in a single-user system, while using a single level directory, user may find it
difficult to remember the names of all the files as the number of files increases.

Prepared for RVR&JC, Second Year CSE-A Students


Figure - Single-level directory
Two-Level Directory
 Each user gets his own directory space.
 File names only need to be unique within a given user's directory.
 A master file directory is used to keep track of each users directory, and must be
maintained when users are added to or removed from the system.
 A separate directory is generally needed for system (executable) files.
 Systems may or may not allow users to access other directories besides their own
o If access to other directories is allowed, then provision must be made to
specify the directory being accessed.
o If access is denied, then special consideration must be made for users to run
programs located in system directories. A search path is the list of
directories in which to search for executable programs, and can be set
uniquely for each user.

Figure - Two-level directory structure


Tree-Structured Directories
 An extension to the two-tiered directory structure
 Each user / process has the concept of a current directory from which all (relative)
searches take place.
 Files may be accessed using either absolute pathnames (path from the root of the
tree) or relative pathnames (path from the current directory)
 Directories are stored the same as any other file in the system, except there is a bit
that identifies them as directories, and they have some special structure that the OS
understands.

Prepared for RVR&JC, Second Year CSE-A Students


Figure - Tree-structured directory structure
Acyclic-Graph Directories
 A tree structure prohibits the sharing of files and directories. An acyclic graph i.e. a
graph with no cycles allows directories to share subdirectories and files. The same
file or subdirectory may be in two different directories.
 With a shared file, only one actual file exists. Sharing is particularly important for
subdirectories. Shared files and subdirectories can be implemented in several ways.
o One way is to create a new directory entry called a link.
 A link is a pointer to another file or subdirectory.
o Another approach in implementing shared files is to duplicate all information
about them in both sharing directories.
 An acyclic graph directory structure is flexible than a tree structure but it is more
complex. Several problems may exist such as multiple absolute path names or
deletion.

Prepared for RVR&JC, Second Year CSE-A Students


Figure - Acyclic-graph directory structure
General Graph Directory
 A problem with using an acyclic graph structure is ensuring that there are no cycles.
 The primary advantage of an acyclic graph is the relative simplicity of the algorithms
to traverse the graph and to determine when there are no more references to a file.
 If cycles are allowed to exist in the directory, avoid searching any component twice.
 A similar problem exists when we are trying to determine when a file can be deleted.
 The difficulty is to avoid cycles as new links are added to the structure.

Figure - General graph directory

Prepared for RVR&JC, Second Year CSE-A Students


5. What is file system mounting?
 The basic idea behind mounting file systems is to combine multiple file systems into
one large tree structure.
 Once a file system is mounted onto a mount point, any further references to that
directory actually refer to the root of the mounted file system.
 Any files ( or sub-directories ) that had been stored in the mount point directory
prior to mounting the new filesystem are now hidden by the mounted filesystem,
and are no longer available. For this reason some systems allow mounting onto only
empty directories.
 Filesystems can only be mounted by root, unless root has previously configured
certain filesystems to be mountable onto certain pre-determined mount points. (
E.g. root may allow users to mount floppy filesystems to /mnt or something like it. )
Anyone can run the mount command to see what filesystems are currently
mounted.
 Filesystems may be mounted read-only, or have other restrictions imposed.

Figure - File system (a) Existing system (b) Unmounted volume

Figure - Mount point

Prepared for RVR&JC, Second Year CSE-A Students

You might also like