0% found this document useful (0 votes)
52 views10 pages

File Management in Operating Systems

Uploaded by

Kiran Mani
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)
52 views10 pages

File Management in Operating Systems

Uploaded by

Kiran Mani
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 8 : FILE MANAGEMENT

-----------------------------------------------------------------------------------------------

WHAT IS FILE MANAGEMENT?


File management in operating system is nothing but software that handles or manages the
files (binary, text, pdf, docs, audio, video, etc.) present in computer software. The file system
in the operating system is capable of managing individual as well as groups of files present in
the computer system.

WHAT IS FILE?
A file can be defined as a data structure which stores the sequence of records. Files are stored
in a file system, which may exist on a disk or in the main memory. Files can be simple (plain
text) or complex (specially-formatted). The collection of files is known as Directory. The
collection of directories at the different levels, is known as File System.

Alok upadhyay-Department of computer science 1


FILE ATTRIBUTES:
 Name: It is the only information stored in a human-readable form.
 Identifier: Every file is identified by a unique tag number within a file system known
as an identifier.
 Location: Points to file location on device.
 Type: This attribute is required for systems that support various types of files.
 Size: Attribute used to display the current file size.
 Protection: This attribute assigns and controls the access rights of reading, writing,
and executing the file.
 Time, date and security: It is used for protection, security, and also used for
monitoring

FILE OPERATIONS:
1. Create operation: This operation is used to create a file in the file system. It is the most
widely used operation performed on the file system. To create a new file of a particular type
the associated application program calls the file system.

2. Open operation: This operation is the common operation performed on the file. Once the
file is created, it must be opened before performing the file processing operations. When the
user wants to open a file, it provides a file name to open the particular file in the file system.

3. Write operation: This operation is used to write the information into a file. A system call
write is issued that specifies the name of the file and the length of the data has to be written to
the file.

4. Read operation: This operation reads the contents from a file. A Read pointer is
maintained by the OS, pointing to the position up to which the data has been read.

5. Re-position operation: The seek system call re-positions the file pointers from the current
position to a specific place in the file i.e. forward or backward depending upon the user's
requirement.

6. Delete operation: Deleting the file will not only delete all the data stored inside the file it
is also used so that disk space occupied by it is freed.

7. Truncate operation: Truncating is simply deleting the file except deleting attributes. The
file is not completely deleted although the information stored inside the file gets replaced.

8. Close operation: When the processing of the file is complete, it should be closed so that
all the changes made permanent and all the resources occupied should be released.

9. Append operation: This operation adds data to the end of the file.

10. Rename operation: This operation is used to rename the existing file.

Alok upadhyay-Department of computer science 2


FILE TYPES:
 Character Special File: It is a hardware file that reads or writes data character by
character, like mouse, printer, and more.
 Ordinary files:
 These types of files stores user information.
 It may be text, executable programs, and databases.
 It allows the user to perform operations like add, delete, and modify.
 Directory Files: Directory contains files and other related information about those
files. Its basically a folder to hold and organize multiple files.
 Special Files: These files are also called device files. It represents physical devices
like printers, disks, networks, flash drive, etc.

FILE TYPE EXTENSION


Executable exe, com, bin
Source code c, cc, java
Markup xml, html
Library lib, dll
Print or View gif, pdf, jpg
Archive rar, zip, tar
Multimedia mpeg, mp3, mp4, avi, mov

FILE ACCESS METHODS:

1. SEQUENTIAL ACCESS METHOD


 In this type of file access method, records are accessed in a certain pre-defined
sequence. In the sequential access method, information stored in the file is also
processed one by one.
 In sequential access, the OS read the file word by word. A pointer is
maintained which initially points to the base address of the file. If the user
wants to read first word of the file then the pointer provides that word to the
user and increases its value by 1 word. This process continues till the end of
the file.
 EXAMPLE : text files, audio files, video files, etc need to be sequentially
accessed.

Alok upadhyay-Department of computer science 3


2. DIRECT ACCESS METHOD
 The random access method is also called direct random access. This method
allow accessing the record directly. Each record has its own address on which
can be directly accessed for reading and writing.
 The Direct Access is mostly required in the case of database systems.

3. INDEXED ACCESS METHOD


If a file can be sorted on any of the filed then an index can be assigned to a group of
certain records. However, A particular record can be accessed by its index. The index
is nothing but the address of a record in the file.

In index accessing, searching in a large database became very quick and easy but we
need to have some extra space in the memory to store the index value.

Alok upadhyay-Department of computer science 4


4. INDEXED SEQUENTIAL ACCESS METHOD
 ISAM (Indexed sequential access method) is an advanced sequential file organization
method. In this case, records are stored in the file with the help of the primary key.
For each primary key, an index value is created and mapped to the record. This index
contains the address of the record in the file.
 If a record has to be obtained based on its index value, the data block’s address is
retrieved, and the record is retrieved from memory.

DIRECTORY STRUCTURE:
Directory can be defined as the listing of the related files on the disk. The directory may store
some or the entire file attributes.

Single Level Directory

The simplest method is to have one big list of all the files on the disk. The entire system will
contain only one directory which is supposed to mention all the files present in the file
system. The directory contains one entry per each file present on the file system.

Alok upadhyay-Department of computer science 5


Two Level Directory

In two level directory systems, we can create a separate directory for each user. There is one
master directory which contains separate directories dedicated to each user. For each user,
there is a different directory present at the second level, containing group of user's file. The
system doesn't let a user to enter in the other user's directory without permission.

Tree-Structured Directory

 In Tree structured directory system, any directory entry can either be a file or sub
directory. Tree structured directory system overcomes the drawbacks of two level
directory system. The similar kind of files can now be grouped in one directory.
 Each user has its own directory and it cannot enter in the other user's directory.
However, the user has the permission to read the root's data but he cannot write or
modify this. Only administrator of the system has the complete access of root
directory.

Alok upadhyay-Department of computer science 6


Acyclic-Graph Structured Directory

In this system, two or more directory entry can point to the same file or sub directory. That
file or sub directory is shared between the two directory entries.

DIRECTORY OPERATIONS:
1. CREATE: A directory is created.
2. DELETE: a directory is deleted. Only an empty directory can be deleted.
3. OPENDIR: directories can be read.
4. CLOSEDIR: when a directory has been read, it should be closed to free up internal
tablespace.
5. READDIR: this call returns the next entry in an open directory.
6. RENAME: a directory is renamed just like a file.
7. LINK: this is a technique that allows a file to appear in more than one directory.
8. UNLINK:a directory entry is removed.

Alok upadhyay-Department of computer science 7


FILE ALLOCATION METHODS:
Whenever a hard disk is formatted, a system has many small areas called blocks or sectors
that are used to store any kind of file. File allocation methods are different ways by which the
operating system stores information in memory blocks

1. CONTIGUOUS ALLOCATION
Contiguous memory allocation refers to a memory management technique in which
whenever there occurs a request by a user process for the memory, one of the sections
of the contiguous memory block would be given to that process, in accordance with
its requirement.

2. LINKED LIST ALLOCATION


 The Linked file allocation overcomes the drawback of contiguous file
allocation. Here the file which we store on the hard disk is stored in a scattered
manner according to the space available on the hard disk.
 The pointers are used to point to the next block of the same file, therefore
along with the entry of each file each block also stores the pointer to the next
block.
 In this allocation, the starting block given is 9 and the ending block is 25,
therefore the OS searches the empty blocks between 9 and 25 and stores the
files in available blocks, but along with that it also stores the pointer to the
next block in the present block. Hence it requires some extra space to store
that link.

Alok upadhyay-Department of computer science 8


3. INDEXED ALLOCATION
 The indexed file allocation is somewhat similar to linked file allocation as
indexed file allocation also uses pointers but the difference is here all the
pointers are put together into one location which is called index block.
 The blocks and pointers were spread over the memory in the Linked
Allocation method, where retrieval was accomplished by visiting each block
sequentially. But here in indexed allocation, it becomes easier with the index
block to retrieve.

Alok upadhyay-Department of computer science 9


PROTECTION:

TYPES OF ACCESS
 Read : Read from the file
 Write : write or rewrite the file
 Execute : load the file into memory and execute it
 Append: write new information at the end of the file
 Delete: delete the file and free its space for possible reuse
 List: list the name and attributes of the file

ACCESS CONTROL:
 Owner : the user who created the file is the owner
 Group : a set of users who are sharing the file and need similar access is a group or
work group
 Universe : All other users in the system constitute the universe

Alok upadhyay-Department of computer science 10

You might also like