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

Unit-2 OS Ch-3 Complete

The document discusses file structures and file management in operating systems. It covers topics like file attributes, directory structures, file operations, file sharing, and remote file systems. Different file structures are described including single level, two level, tree structure and acyclic graph directories.

Uploaded by

Vaibhav
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)
66 views

Unit-2 OS Ch-3 Complete

The document discusses file structures and file management in operating systems. It covers topics like file attributes, directory structures, file operations, file sharing, and remote file systems. Different file structures are described including single level, two level, tree structure and acyclic graph directories.

Uploaded by

Vaibhav
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/ 14

OS UNIT 2: Chapter 3 1

File Structure
Files can be organized as a simple sequence of words
or bytes without any specific structure.
They can also be structured into simple records such
as lines, Fixed/Variable length records.
They can also have more complex structures such as
Formatted docs, Relocatable load files.
It is possible to simulate complex structures using the
first method by inserting appropriate control
characters.
The structure of a file is determined by OS & specific
program accessing the file.
File Operations
Creating a File:
o Finding space in the file system and creating an
entry in the directory.
Writing a File:
o System call specifies file name and data to be
written.
o System searches directory for file location.
o Write pointer in the file indicates the next write
location and is updated after each write operation.
Reading a File:
o System call specifies file name and memory location
for data.
o Directory searched for file's location.
o Read pointer indicates the next read location and
is updated after each read operation.
Repositioning within a File (File Seek):
o Directory searched for the appropriate file entry.
o Current-file-position pointer repositioned to a
given value.
Deleting a File:
OS UNIT 2: Chapter 3 2

o Directory searched for the file. o File space


released and directory entry erased.
Truncating a File:
o Allows erasing file contents while keeping
attributes.
o Resets file length to zero and releases file space.
File Attributes o Name: The human-readable title
of the file.
o Identifier: A unique numeric tag that distinguishes
the file within the file system. o Type: Specifies
the category or type of the file, especially
relevant for systems supporting various file
formats.
o Location: This indicates the specific storage
location of the file on the device, often in the
form of a pointer. o Size: The current size of the
file, usually measured in bytes or other appropriate
units. o Protection: Determines the permissions
associated with the file, governing who can read,
write, or execute it.
o Time, Date, and User Identification: Records
metadata including creation/modification timestamps
and user IDs for security and usage tracking
purposes.
These attributes collectively form the information about
files stored in the directory structure, which is
maintained on the disk.
Q) What kind of data are necessary for maintaining open
files in operating systems. Where is the data kept?
Ans:
o The OS needs several pieces of data to manage open
files:
o File position: pointer to last read/write location,
per process that has the file open
OS UNIT 2: Chapter 3 3

o File-open count: counter of number of times a file


is open. To allow removal of data from open-file
table when last processes close it
o Disk Location of the file: cached in memory, so it
does not need to be read from file all the time
o Access rights: per-process access mode information
Directory Structure
To effectively manage large amounts of data,
organization is essential. This is where directory
structure comes into play. Directory structure refers to
the arrangement of nodes containing information about
all files within a system. It encompasses all attributes
of files and allows for further division into
subdirectories. Each directory within the structure
possesses a unique name for its files.

Fig: A File System Organization

Operations Performed on Directory


Searching
A directory can be searched for a particular file or for
another directory. It can also be searched to list all
the files with the same name.
Creating
A new file can be created and inserted to the directory
or new directory can be created keeping in mind that its
name must be unique under that particular directory.
Deleting
OS UNIT 2: Chapter 3 4

If a file is no longer needed by the user, it can be


deleted from the directory. The entire directory can
also be deleted if it is not needed. An empty directory
can also be deleted. When a directory is empty it is
resembled by dot and dotdot.
List a directory
List of all the files in the directory can be retrieved
and also the contents of the directory entry, for each
file in a list. To read the list of all the files in the
directory, it must be opened and after reading the
directory must be closed to free up the internal
tablespace.
Renaming
The name of the file or a directory represents the
content it holds and its use. The file or directory can
be renamed in case, the content inside or the use of
file get changed. Renaming the file or directory also
changes its position inside the directory.
Traverse the file system
We may wish to access every directory and every file
within a directory structure.
Types of Directory Structure

Single Two Tree Acyclic


Level Level Structured Graph

Single level Directory:


• Simple Structure
• All files present in a same directory
• Unique File name
OS UNIT 2: Chapter 3 5

• No System file sub


directory
• Naming & grouping
problems Two level
Directory:
• Each User have User
File Directory (UFD)
• Root is called Master
File Directory (MFD)
• MFD works as index for
UFD
• Efficient Searching
• Can have the same file
name for different
user
• No grouping capability
Tree Structure Directory:
• Extension of two-level directory structure
• Allows users to create their own sub directory & to
organize their files accordingly
• Subdirectory contains a set of files of
subdirectories
• The Tree has a Root Directory
• Every file in the system
has a unique path name.
• Absolute path name:
Indirect path from
directory
• Relative path name: Path
from current directory.

Acyclic Graph Directory


OS UNIT 2: Chapter 3 6

• A shared directory or file can be found in the file


system in two or more locations simultaneously.
• When a file is shared,
there exists only one
actual file, and any
changes made by one person
are instantly visible to
others.
• It offers greater
flexibility compared to a
simple tree structure but
is also more complex.
• Similar to files, we can
have multiple complex path
names, resulting in
different filenames
referring to the same file.
• For instance, in a scenario where multiple users are
collaborating on a project, the project files can
be shared within a common subdirectory among these
users. This type of file directory is referred to
as an Acyclic graph directory.
File Sharing
• It is the practice of distributing or providing
access to digital media such as computer programs,
multimedia (audio, video, images) etc.
• Sharing of files on multi user system is desirable
• Sharing may be done through a protection scheme
• On distributed systems, files may be shared across
a network
• Network File System (NFS) is a common distributed
file sharing method
Multi User Systems
• On a multi user system, more info is needed to be
stored for each file
OS UNIT 2: Chapter 3 7

• To implement sharing & protection, the system must


maintain more file & directory attributes than a
single user system.
• Concept of File Owner (User) and Group is used by
most system
• Owner: Changes attributes, Grant access and has most
control over the file
• Group Attributes are a subset of users who can share
access to the file
• User IDs identify users, allowing permissions and
protections to be per-user
• Group IDs allow users to be in groups, permitting
group access rights
Remote File System
Remote file systems enable an application that runs on
a client computer to access files stored on a different
computer
• The original method was FTP, manually transferring
files between machines via programming like FTP.
• The second method uses a Distributed File System
(DFS) in which remote directories are visible from
a local machine.
• The third method WWW (World Wide Web), a browser is
needed to gain access to the remote files, and
separate operations (essentially a wrapper for FTP)
are used to transfer files.
Client Server Model
• The client-server model enables clients to access
remote file systems hosted by servers.
• Servers have the capability to serve multiple
clients concurrently.
• Identifying clients and users on clients can be
insecure or complex.
• NFS (Network File System) is the standard UNIX
client-server file sharing protocol.
OS UNIT 2: Chapter 3 8

• CIFS (Common Internet File System) is the standard


protocol used in Windows environments.
• Standard operating system file calls are translated
into remote calls to facilitate communication
between clients and servers.
Distributed Information Systems (distributed naming
services) such as LDAP, DNS, NIS, Active Directory
implement unified access to information needed for
remote computing.
Failure Modes:
• Remote file systems add new failure modes, due to
network failure, server failure etc.
• Recovery from failure can involve state information
about status of each remote request.
• Stateless protocols such as NFS include all
information in each request, allowing easy recovery
but less security.
Layered File System:
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.
OS UNIT 2: Chapter 3 9

o When an application program requests a file, the


initial inquiry is directed to the logical file
system.
o The logical file system contains metadata of the
file and directory structure.
o If the application program lacks the necessary
permissions for the file, this layer will generate
an error.
o Files are typically divided into various logical
blocks for storage and retrieval.
o To facilitate storage and retrieval, logical blocks
need to be mapped to physical blocks, a task handled
by the File Organization module.
o After determining the physical block required by the
application program, the File Organization module
communicates this information to the basic file
system.
o The basic file system issues commands to the I/O
control to fetch the required blocks.
o I/O controls utilize device drivers, which contain
codes to access the hard disk.
OS UNIT 2: Chapter 3 10
OS UNIT 2: Chapter 3 11
OS UNIT 2: Chapter 3 12
OS UNIT 2: Chapter 3 13
OS UNIT 2: Chapter 3 14

Join Now:-

NFS Info Junction:-


https://whatsapp.com/channel/002
9VaMvqwsDeON2ZWt3Bu1M

©️ NFS Club:-
https://chat.whatsapp.com/CX7qyc
rvE2QIpfeBPBrbxe

Huge to Thanks to Adith

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy