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

3rd Chapter

This document provides an overview of file systems, defining files as data structures that store sequences of records and explaining their organization within directories. It details the structure of file systems, including pathnames, file types, attributes, access control lists, and the use of pipes for inter-process communication. Additionally, it introduces various text processing commands and filters that can be used within a file system.

Uploaded by

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

3rd Chapter

This document provides an overview of file systems, defining files as data structures that store sequences of records and explaining their organization within directories. It details the structure of file systems, including pathnames, file types, attributes, access control lists, and the use of pipes for inter-process communication. Additionally, it introduces various text processing commands and filters that can be used within a file system.

Uploaded by

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

CHAPTER 3

What is a 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.

File system

A file system is a process that manages how and where data on a storage disk, typically a hard
disk drive (HDD), is stored, accessed and managed.

Pathnames

The pathname is a specific label for a file's directory location while within an operating system.
 Absolute path name
 Relative path name
Absolute pathname
Specifies the path with reference to the root of the file system. (Always begins with /, for
the root directory).
System configuration files that normally do not change location should be addressed with
an absolute pathname.
Relative pathname
Specifies the path with reference to the user’s current location. (cd ../include).
 Uses to signify the current directory.
 Uses to signify the parent directory.
 Used to refer to files that are either impossible or inconvenient to access in an
absolute manner.

File System Structure

 File System provide efficient access to the disk by allowing data to be stored, located and
retrieved in a convenient way. A file System must be able to store the file, locate the file
and retrieve the file.
 Most of the Operating Systems use layering approach for every task including file
systems. Every layer of the file system is responsible for some activities.
 The diagram shown below, elaborates how the file system is divided in different layers,
and also the functionality of each layer.

o When an application program asks for a file, the first request is directed to the logical file
system. The logical file system contains the Meta data of the file and directory structure.
If the application program doesn't have the required permissions of the file then this layer
will throw an error. Logical file systems also verify the path to the file.
o Generally, files are divided into various logical blocks. Files are to be stored in the hard
disk and to be retrieved from the hard disk. Hard disk is divided into various tracks and
sectors. Therefore, in order to store and retrieve the files, the logical blocks need to be
mapped to physical blocks. This mapping is done by File organization module. It is also
responsible for free space management.
o Once File organization module decided which physical block the application program
needs, it passes this information to basic file system. The basic file system is responsible
for issuing the commands to I/O control in order to fetch those blocks.
o I/O controls contain the codes by using which it can access hard disk. These codes are
known as device drivers. I/O controls are also responsible for handling interrupts.

Navigating the file system

It's a program that takes in commands and passes them on to the computer's operating
system to run. From the command line, you can navigate the Filesystem.
 cp stands for copy.
 mv: move, similar to copy but moves the file, and removes the original.
 cd: change directory.
 mkdir: Create a new directory
 rm: remove. Or delete -Delete a file, to delete a directory and everything in it, use:
 df: Disk Free - Show the usage of the filesystems.
 du: This at times may be called “Disk Usage”. It will show you how much disk a file or
directory is using.
 chown: stands for change owner/group of files and directories.
 chmod: allows you to change file and directories, read, write, and execute permission bits
and other special permissions. The “-rwxr-x-rx” part!

File Type
It refers to the ability of the operating system to differentiate various types of files like text files,
binary, and source files. However, Operating systems like MS_DOS and UNIX has the following
type of files:

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.

Attributes

[Link]
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.
[Link]
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.
[Link]
In a File System, the Files are classified in different types such as video files, audio files, text
files, executable files, etc.
[Link]
In the File System, there are several locations on which, the files can be stored. Each file carries
its location as its attribute.
[Link]
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.
[Link]
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.
[Link] and Date
Every file carries a time stamp which contains the time and date on which the file is last
modified.

ACCESS CONTROL LIST (ACL)

An ACL is a list of permissions that are associated with a directory or file. It defines which users
are allowed to access a particular directory or file. An access control entry in the ACL defines
the permissions for a user or a group of users. An ACL usually consists of multiple entries.

Pipes

Conceptually, a pipe is a connection between two processes, such that the standard output from
one process becomes the standard input of the other process. In UNIX Operating System, Pipes
are useful for communication between related processes(inter-process communication).
 Pipe is one-way communication only i.e we can use a pipe such that One process write to
the pipe, and the other process reads from the pipe. It opens a pipe, which is an area of
main memory that is treated as a “virtual file”.
 The pipe can be used by the creating process, as well as all its child processes, for reading
and writing. One process can write to this “virtual file” or pipe and another related process
can read from it.
 If a process tries to read before something is written to the pipe, the process is suspended
until something is written.
 The pipe system call finds the first two available positions in the process’s open file table
and allocates them for the read and write ends of the pipe.
Filters / Text Processing Commands
sort
File sorter, often used as a filter in a pipe. This command sorts a text stream or file
forwards or backwards, or according to various keys or character positions
tsort
Topological sort, reading in pairs of whitespace-separated strings and sorting according
to input patterns.
uniq
This filter removes duplicate lines from a sorted file. It is often seen in a pipe coupled
with sort.

expand, unexpand

The expand filter converts tabs to spaces. It is often used in a pipe.


The unexpand filter converts spaces to tabs. This reverses the effect of expand.
cut
A tool for extracting fields from files. It is similar to the print $N command set in awk,
but more limited. It may be simpler to use cut in a script than awk.
paste
Tool for merging together different files into a single, multi-column file. In combination
with cut, useful for creating system log files.
join
Consider this a special-purpose cousin of paste. This powerful utility allows merging two
files in a meaningful fashion, which essentially creates a simple version of a relational
database.
The join command operates on exactly two files, but pastes together only those lines with
a common tagged field (usually a numerical label), and writes the result to stdout.
head
lists the beginning of a file to stdout (the default is 10 lines, but this can be changed). It
has a number of interesting options.
tail
lists the end of a file to stdout (the default is 10 lines). Commonly used to keep track of
changes to a system logfile, using the -f option, which outputs lines appended to the file.
grep
A multi-purpose file search tool that uses Regular Expressions
wc
wc gives a "word count" on a file or I/O stream:
 wc -w gives only the word count.
 wc -l gives only the line count.
 wc -c gives only the character count.
 wc -L gives only the length of the longest line.

You might also like