Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

22CS301 - Operating Systems

22CS301 OPERATING SYSTEM

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Module 3- File and Device Management


Session Topic
3.1 File-System Interface: File concept – Access Methods

3.2 Directory Structure – Directory Organization

3.3 File system mounting - File Sharing and Protection;

3.4 File System Implementation: File System


Structure- Directory implementation
3.5 Allocation Methods
3.6 Free Space Management

3.7 Mass Storage Structure


3.8 Disk Scheduling
3.9 Disk Management

3.10 I/O Systems


3.11 System Protection and Security,
3.12 System Threats

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

3.2 File System Interface –Directory Structure – Directory Organization

Course Outcome:
Upon completion of the session, students shall have ability to

CO5 Apply concepts of file system interface,implementation, and disk management [AP]
to optimize storage utilization and random access to files.

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Directory Structure

• A collection of nodes containing information about all files


• A directory is a container that is used to contain folders and files. It organizes
files and folders in a hierarchical manner.

• Both the directory structure and the files reside on disk

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Operations Performed on Directory

• Search for a file


• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Directory Organization

The directory is organized logically to obtain

• Efficiency – locating a file quickly


• Naming – convenient to users
– Two users can have same name for different files
– The same file can have several different names
• Grouping – logical grouping of files by properties, (e.g., all
Java programs, all games, …)

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Single-Level Directory

• A single directory for all users all the files are in the same directory,
they must have a unique name

• Naming problem
• Grouping problem

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Single-Level Directory
Advantages

• Implementation is very simple.

• If the sizes of the files are very small then the searching becomes faster.

• File creation, searching, deletion is very simple since only one directory.

Disadvantages

• We cannot have two files with the same name.

• The directory may be very big therefore searching for a file take so much time.

• Protection cannot be implemented for multiple users.

• There are no ways to group same kind of files.

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Two-Level Directory

• Separate directory for each user

In the two-level directory structure, each user has their own user files directory (UFD).
The UFDs have similar structures, but each lists only the files of a single user.
System’s master file directory (MFD) is searched whenever a new user id is correct.

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Two-Level Directory

Characteristics of two level directory system

• Each files has a path name as /User-name/directory-name/


• Different users can have the same file name.
• Searching becomes more efficient as only one user's list
needs to be traversed.
• The same kind of files cannot be grouped into a single
directory for a particular user.

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Tree-Structured Directories
• Tree directory structure is most commonly used in our personal computers.
• Directory structure resembles a real tree upside down, where the root directory is at the
peak.
• This root contains all the directories for each user.
• The users can create subdirectories and even store files in their directory.
• A user do not have access to the root directory data and cannot modify it. And, even in this
directory the user do not have access to other user’s directories.

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Acyclic-Graph Directories

• The tree structured doesn't allow the same file to exist in multiple directories.
• We can provide sharing by making the directory an acyclic graph.
• 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.
• These kinds of directory graphs can be made using links or aliases.
• We can have multiple paths for a same file.
• Links can either be symbolic (logical) or hard link (physical).

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Acyclic-Graph Directories
If a file gets deleted in acyclic graph structured directory
system, then
1. In the case of soft link, the file just gets deleted and we
are left with a dangling pointer.
2. In the case of hard link, the actual file will be deleted
only if all the references to it gets deleted.

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Acyclic-Graph Directories (Cont.)

• Two different names (aliasing)


• If dict deletes w/list  dangling pointer
Solutions:
– Backpointers, so we can delete all pointers.
• Variable size records a problem
– Backpointers using a daisy chain organization
– Entry-hold-count solution
• New directory entry type
– Link – another name (pointer) to an existing file
– Resolve the link – follow pointer to locate the file

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

General Graph Directory


– Allow only links to files not subdirectories
– Garbage collection
– Every time a new link is added use a cycle detection algorithm to determine
whether it is OK

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Current Directory

• Can designate one of the directories as the current (working) directory


– cd /spell/mail/prog
– type list
• Creating and deleting a file is done in current directory
• Example of creating a new file
– If in current directory is /mail
– The command
mkdir <dir-name>
– Results in:

– Deleting “mail”  deleting the entire subtree rooted by “mail”

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Protection

• File owner/creator should be able to control:


– What can be done
– By whom
• Types of access
– Read
– Write
– Execute
– Append
– Delete
– List

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Access Lists and Groups in Unix

• Mode of access: read, write, execute


• Three classes of users on Unix / Linux
RWX
a) owner access 7  111
RWX
b) group access 6  110
RWX
c) public access 1  001
• Ask manager to create a group (unique name), say G, and add some users to the group.
• For a file (say game) or subdirectory, define an appropriate access.

• Attach a group to a file

chgrp G game

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

A Sample UNIX Directory Listing

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Windows 7 Access-Control List Management

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Try……
• Find the correct matching answer
Files in the same directory Tree Structure Directory

Each user has their own user files Single Level Directory
directory (UFD)

Directory structure used in Two level Directory


our personal computers

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Answer

Files in the same directory Single Level Directory

Each user has their own user files Two level Directory
directory (UFD)

Directory structure used in Tree Structure Directory


our personal computers

MODULE 3 -File System Interface-Directory Structure – Directory Organization


22CS301 - Operating Systems

Next Session…
3.3 File system mounting - File Sharing and Protection;

MODULE 3 -File System Interface-Directory Structure – Directory Organization

You might also like