OS Unit 5
OS Unit 5
of
Engineerin
g
Operating Systems
(UNIT-5)
RV College
of
Engineerin
Unit-5
g
File Systems
File Naming, File Structure, File Types, File Access, File Attributes, File Operations, An example program
using File-System calls, File-System Layout, Implementing Files
Files are an abstract mechanism, the most important characteristic of any abstract mechanism is the way
that the objects being managed are named.
The rule for file naming varies from system to system, but all the current OSs allow strings as file names.
Therefore, myfile, file1, my_file, etc. are the three legal file names.
Digits and special characters can also be used to name a file, such as myfile, file-2-1, file_21, 32, etc.,
which are also legal file names.
The naming of files is supported by many file systems as long as the names contain all 255 possible
characters.
Almost every OS supports two-part file names. These two parts of the file names are separated by a
period or dot (.).
The part that comes after the period (.) is known as the file extension, and it typically provides some kind
of information regarding the file
Regular Files
Regular files contain user information. Generally, regular files are either ASCII files or binary files. These two
types of files are described below.
ASCII Files: ASCII files basically consist of lines of text. The big plus point or advantage of ASCII files is that
they can be displayed and printed as is, and they can also be edited using any text editor such as Notepad,
Wordpad, Notepad+, etc.
Binary Files: The binary files listed on the printer produce random garbage. Generally, binary files have some
internal structure that is only known to the programs that use them. Technically, binary files are just a
sequence of bytes, and the OS will only execute a file if it has the proper format
Having only one directory in a system with multiple users may result in different users accidentally using the same names
for their files.
So, in this two-level directory system, the names chosen by one user don't affect the names
chosen by another user, and having the same name in two or more directories doesn't cause any
problems
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING March 22, 2025 8
RV College File Types
of
Engineerin
g
Character Special Files
Character special files are mostly about I/O and are used to model serial input/output devices like printers, networks, and
so on.
Sequential-Access
It is the simplest access method. Information in the file is processed in order, one record after the other. This mode of
access is by far the most common
A fixed-length logical record that allows the program to read and write record rapidly. in no particular order.
The direct access is based on the disk model of a file since disk allows random access to any file block. For direct access,
the file is viewed as a numbered sequence of block or record. Thus, we may read block 14 then block 59, and then we can
write block 17.
Sequential Access
read next
• after the other. This mode of access is bynext
write far the most common
reset
no read after last write
(rewrite)
Direct Access – file is fixed length logical records
read n
write n
position to n
read next
write next
rewrite n
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND MACHINEnLEARNING
= relative block numberMarch 22, 2025 11
RV College File Access
of
Engineerin
g
The index, like an index in the back of a book, contains the pointer to the various blocks
• after the other. This mode of access is by far the most common
A file has a name and data. Moreover, it also stores meta information like file creation date and time, current
size, last modified date, etc. All this information is called the attributes of a file system.
Here, are some important File attributes used in OS:
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
On-disk
In-memory structures