0% found this document useful (0 votes)
77 views

File System Print

1. A file is a collection of related information recorded on secondary storage and is the smallest unit of logical storage from a user's perspective. 2. File management in operating systems is based on concepts like file attributes, operations, access permissions, and file systems. File attributes describe characteristics like type, size, and location. 3. There are different types of file access methods including sequential, direct, and indexed sequential. Sequential access reads files in order while direct access allows jumping to any block.

Uploaded by

SK ANARUL
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)
77 views

File System Print

1. A file is a collection of related information recorded on secondary storage and is the smallest unit of logical storage from a user's perspective. 2. File management in operating systems is based on concepts like file attributes, operations, access permissions, and file systems. File attributes describe characteristics like type, size, and location. 3. There are different types of file access methods including sequential, direct, and indexed sequential. Sequential access reads files in order while direct access allows jumping to any block.

Uploaded by

SK ANARUL
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
You are on page 1/ 9

File Managment

A file is a collection of related information that is recorded on secondary


storage. Or file is a collection of logically related entities. From user’s perspective a file is the
smallest allotment of logical secondary storage.
The name of the file is divided into two parts as shown below:
• name
• extension, separated by a period.
The file management of function in operating system (OS) is based on the following
concepts:
1. File Attributes
It specifies the characteristics of the files such as type, date of last modification, size, location
on disk etc. file attributes help the user to understand the value and location of files. File
attributes is one most important feature. It is uses to describe all the information regarding
particular file.
2. File Operations
It specifies the task that can be performed on a file such as opening and closing of file.
3. File Access permission
It specifies the access permissions related to a file such as read and write.
4. File Systems
It specifies the logical method of file storage in a computer system. Some of the commonly
used files systems include FAT and NTFS.
Write the Attributes of File:
A file’s attributes vary from one operating system to another but typically consist of these.
1.Name
Every file carries a name by which the file is recognized in the file system. One directory cannot have
two files with the same name.
2.Identifier
Along with the name, Each File has its own extension which identifies the type of the file. For
example, a text file has the extension .txt, A video file can have the extension .mp4.
3.Type
In a File System, the Files are classified in different types such as video files, audio files, text files,
executable files, etc.
4.Location
In the File System, there are several locations on which, the files can be stored. Each file carries its
location as its attribute.
5.Size
The Size of the File is one of its most important attribute. By size of the file, we mean the number of
bytes acquired by the file in the memory.
6.Protection
The Admin of the computer may want the different protections for the different files. Therefore
each file carries its own set of permissions to the different group of Users.
7.Time and Date
Every file carries a time stamp which contains the time and date on which the file is last modified.
File Operation:
• A file is an abstract data type. To define a file properly, we need to consider the operations that can be
performed on files.
File Managment

• Six basic file operations. The OS can provide system calls to create, write, read, reposition, delete, and
truncate files.
o Creating a file.: Two steps are necessary to create a file.
1. Space in the file system must be found for the file.
2. An entry for the new file must be made in the directory.
o Writing a file. :To write a file, we make a system call specifying 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. The write pointer must be updated whenever a
write occurs.
o Reading a file. :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.
o Repositioning within a file or Seek operation.: The directory is searched for the
appropriate entry, and the current-file-position pointer is repositioned to a given value.
Repositioning within a file need not involve any actual I/O. This file operation is also known
as a file seek.
o Deleting a file.: To delete a file, we search the directory for the named file. Having found the
associated directory entry, we release all file space, so that it can be reused by other files, and
erase the directory entry.
o Truncating a file:Truncating is simply deleting the file except deleting attributes. The
file is not completely deleted although the information stored inside the file gets
replaced.
o 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. On closing it deallocates all the internal descriptors that were created when
the file was opened.
o 9. Append operation:This operation adds data to the end of the file.
o 10. Rename operation:This operation is used to rename the existing file.
File Types:
There are a large number of file types. Each has a particular purpose. The type of a file indicates its use
File type Usual extension Function

Executable exe, com, bin Read to run machine language program

Object obj, o Compiled, machine language not linked

C, java, pas, asm,


Source Code a Source code in various languages

Batch bat, sh Commands to the command interpreter

Text txt, doc Textual data, documents

Word
Processor wp, tex, rrf, doc Various word processor formats
File Managment

File type Usual extension Function

Archive arc, zip, tar Related files grouped into one compressed file

Multimedia mpeg, mov, rm For containing audio/video information

Markup xml, html, tex It is the textual data and documents

Library lib, a ,so, dll It contains libraries of routines for programmers

It is a format for printing or viewing a ASCII or binary


Print or View gif, pdf, jpg file.

1. Media:
Media files store media data such as images, audio, icons, video, etc. Common extensions: img, mp3,
mp4, jpg, png, flac, etc.
2. Programs:
These files store code, markup, commands, scripts, and are usually executable. Common
extensions: c, cpp, java, xml, html, css, js, ts, py, sql, etc.
4. Operating System Level:
These files are present with the OS for its internal use. Common extensions: bin, sh, bat, dl, etc.
5. Document:
These files are used for managing office programs such as documents, spreadsheets, etc. Common
extensions: xl, doc, docx, pdf, ppt, etc.
6. Miscellaneous:
Generic text file(.txt), canvas files, proprietary files, etc.

Different File Access Method:


Files contain a lot of information required by the system. The computer memory may require certain
files during execution. We need very efficient methods to retrieve the information by accessing the
files in the least time possible.
In this article, we will learn about the three types of file access methods. They are:
1. Sequential access
2. Direct access
3. Indexed sequential access
1. Sequential Access Method
A sequential access is that in which the records are accessed in some sequence, i.e., the
information in the file is processed in order, one record after the other. This access method is
the most primitive one.

The idea of Sequential access is based on the tape model which is a sequential access device.
We consider Sequential access method is best because most of the records in a file are to be
processed. For example, transaction files.
File Managment

The figure represents a file. The current pointer is pointing to the record currently being
accessed. In the sequential access method, the current pointer cannot directly jump to any
record. It has to "cross" every record that comes in its path. Suppose there are nine records in
the file from R1 to R9. The current pointer is at record R6. If we want to access record R8, we
have to first access record R6 and record R7. This is one of the major disadvantages of the
sequential access method.

Example: Compilers usually access files in this fashion.

The sequential access method has three operations:

Read next: It will read the next record in the file.

Write next: This operation is used when some more information is to be included in the file. A
new node (a record) will be added at the end of the file.
• Rewind: This will bring the read and write pointers to the beginning of the file.
2. Direct or Random Access Methods

Sometimes it is not necessary to process every record in a file. It is not necessary to process all
the records in the order in which they are present in the memory. In all such cases, direct access
is used.

The disk is a direct access device which gives us the reliability to random access of any file block.
In the file, there is a collection of physical blocks and the records of that blocks.

Eg. Databases are often of this type since they allow query processing that involves immediate
access to large amounts of information. All reservation systems fall into this category.

The direct access method has the following operations:


• Read n: This operation is used to read the nth block. Read 6 would allow us to read
block B6.
• Write n: This operation is used to write in the nth block.
• Goto n: This operation is used to directly access the nth block.
File Managment

Not all operating systems support direct access files. The sequential and direct access of the file
is defined at the time of creation and accessed accordingly later. The direct access of a
sequential file is not possible but Sequential access to a direct access file is possible.
3. Index Access Method
An indexed file is a computer file with an index that allows easy random access to any record
given its file key. The key is an attribute that uniquely identifies a record. We can say that If more
than one index is present the other ones are alternate indexes. The creation of the indexes is
done with the file but maintained by the system.

Directory Structure

What is a directory?

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

Every Directory supports a number of common operations on the file:


1. File Creation
2. Search for the file
3. File deletion
4. Renaming the file
5. Traversing Files
6. Listing of files
There are several logical structures of a directory, these are given below.
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.
File Managment

This type of directories can be used for a simple system.

Advantages
1. Implementation is very simple.
2. If the sizes of the files are very small then the searching becomes faster.
3. File creation, searching, deletion is very simple since we have only one directory.

Disadvantages
1. We cannot have two files with the same name.
2. The directory may be very big therefore searching for a file may take so much time.
3. Protection cannot be implemented for multiple users.
4. There are no ways to group same kind of files.
5. Choosing the unique name for every file is a bit complex and limits the number of files in the
system because most of the Operating System limits the number of characters used to
construct the file name.
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.

This type of directories can be used for a simple system.


File Managment

Advantages
1. Implementation is very simple.
2. If the sizes of the files are very small then the searching becomes faster.
3. File creation, searching, deletion is very simple since we have only one directory.

Disadvantages
1. We cannot have two files with the same name.
2. The directory may be very big therefore searching for a file may take so much time.
3. Protection cannot be implemented for multiple users.
4. There are no ways to group same kind of files.
5. Choosing the unique name for every file is a bit complex and limits the number of files in the
system because most of the Operating System limits the number of characters used to
construct the file name.
Tree-structured directory –
Once we have seen a two-level directory as a tree of height 2, the natural
generalization is to extend the directory structure to a tree of arbitrary height.
This generalization allows the user to create their own subdirectories and to organize their files
accordingly.

A tree structure is the most common directory structure. The tree has a root
directory, and every file in the system has a unique path.
Advantages:
• Very general, since full pathname can be given.
• Very scalable, the probability of name collision is less.
• Searching becomes very easy, we can use both absolute paths as well as relative.
Disadvantages:
File Managment

• Every file does not fit into the hierarchical model, files may be saved into multiple
directories.
• We can not share files.
• It is inefficient, because accessing a file may go under multiple directories.
Acyclic graph directory –
An acyclic graph is a graph with no cycle and allows us to share
subdirectories and files. The same file or subdirectories may be in two different directories. It is a
natural generalization of the tree-structured directory.
It is used in the situation like when two programmers are working on a joint project and
they need to access files. The associated files are stored in a subdirectory, separating
them from other projects and files of other programmers since they are working on a
joint project so they want the subdirectories to be into their own directories. The
common subdirectories should be shared. So here we use Acyclic directories.
It is the point to note that the shared file is not the same as the copy file. If any
programmer makes some changes in the subdirectory it will reflect in both
subdirectories.

Common Terms in Filesystem


1. File
A file is a logical unit of information created by processes that processes produce.
2. Directory
A location on the storage that stores several files within itself.
3. Partition
A part of the storage medium is virtually separate from the rest of the storage.
4. Access Mechanism
The process is followed by the OS to grant a user/process access to a file.
5. File Extension
A label appended to the name of a file after a dot. Gives information of the purpose of and information in
the file.

What is file management and why is it important?


File Managment

5. File management is the process of organizing, storing, naming and deleting files. It is
important because it can make a difference in how easy it is to find and access files you
need.
6. It can be done manually or with a software program. There are many file management
system that are available, but they all have the same basic functions:
7. -Organizing – putting files into folders
8. -Storing – keeping your files saved on your computer
9. -Naming – giving your files an appropriate name for easy identification
10. -Deleting – deleting old or unnecessary files to free up space on your hard drive

You might also like