0% found this document useful (0 votes)
5 views15 pages

files1

The document discusses file concepts and directory structures in operating systems, covering file attributes, operations, types, and access methods. It explains directory operations, single-level, two-level, tree-structured, and acyclic graph directory structures, including their advantages and challenges. The document also highlights the differences in link types between UNIX and Windows systems.

Uploaded by

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

files1

The document discusses file concepts and directory structures in operating systems, covering file attributes, operations, types, and access methods. It explains directory operations, single-level, two-level, tree-structured, and acyclic graph directory structures, including their advantages and challenges. The document also highlights the differences in link types between UNIX and Windows systems.

Uploaded by

krishnaveni kits
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

KKR & KSR INSTITUTE OF TECHNOLOGY & SCIENCES

(Approved by AICTE, New Delhi, Affiliated to JNTUK Kakinada)


(Accredited by NAAC – ‘A’ Grade )
Department of Information Technology

Sub: OPERATING SYSTEMS Sub Code:20IT5T01


B.Tech III Year I sem Regulation : R20
Faculty Name: CH. Krishnaveni Academic Year :2022-2023

Topic: File concepts


File Concept
1. File Attributes
Different OS keep track of different file attributes, including:
• Name - Some systems give special significance to names, and particularly
extensions ( .exe, .txt, etc. ), and some do not. Some extensions may be of
significance to the OS ( .exe ), and others only to certain applications ( .jpg )

• Identifier ( e.g. inode number )

• Type - Text, executable, other binary, etc.

• Location - on the hard drive.

• Size

• Protection

• Time & Date

• User ID
2 File Operations
The file ADT supports many common operations:
Creating a file
Writing a file
Reading a file
Repositioning within a file
Deleting a file
Truncating a file.
Information about currently open files is stored in an open file table, containing for
example:
File pointer - records the current position in the file, for the next read or write
access.
File-open count - How many times has the current file been opened Some
systems provide support for file locking.
A shared lock is for reading only.
A exclusive lock is for writing as well as reading.
An advisory lock is informational only, and not enforced. ( A "Keep Out" sign,
which may be ignored. )
A mandatory lock is enforced. ( A truly locked door. )
UNIX used advisory locks, and Windows uses mandatory locks.
3 File Types
Windows ( and some other systems ) use special file extensions to
indicate the type of each file:
Access Methods
1 Sequential Access
A sequential access file emulates magnetic tape operation, and generally
supports a few operations:
read next - read a record and advance the tape to the next position.
write next - write a record and advance the tape to the next position.
rewind
skip n records - May or may not be supported. N may be limited to
positive numbers, or may be limited to +/- 1.
2 Direct Access
Jump to any record and read that record. Operations supported include:
• read n - read record number n. ( Note an argument is now required. )
• write n - write record number n. ( Note an argument is now required. )
• jump to record n - could be 0 or the end of file.
• Query current record - used to return back to this record later.
• Sequential access can be easily emulated using direct access. The inverse is
complicated and inefficient.
3 Other Access Methods
An indexed access scheme can be easily built on top of a direct access system. Very
large files may require a multi-tiered indexing scheme, i.e. indexes of indexes.
KKR & KSR INSTITUTE OF TECHNOLOGY & SCIENCES
(Approved by AICTE, New Delhi, Affiliated to JNTUK Kakinada)
(Accredited by NAAC – ‘A’ Grade )
Department of Information Technology

Sub: OPERATING SYSTEMS Sub Code:20IT5T01


B.Tech III Year I sem Regulation: R20
Faculty Name: CH. Krishnaveni Academic Year :2022-2023

Topic: Directory Structure


Directory Overview
Directory operations to be supported include:
Search for a file
Create a file - add to the directory
Delete a file - erase from the directory
List a directory - possibly ordered in different ways.
Rename a file - may change sorting order
Traverse the file system.
1. Single-Level Directory
Simple to implement, but each file must have a unique name.
2. Two-Level Directory
• Each user gets their own directory space.
• File names only need to be unique within a given user's directory.
• A master file directory is used to keep track of each users directory, and must
be maintained when users are added to or removed from the system.
• A separate directory is generally needed for system ( executable ) files.
• Systems may or may not allow users to access other directories besides their
own
 If access to other directories is allowed, then provision must be made to
specify the directory being accessed.
 If access is denied, then special consideration must be made for users to
run programs located in system directories. A search path is the list of
directories in which to search for executable programs, and can be set
uniquely for each user.
3.Tree-Structured Directories
An obvious extension to the two-tiered directory structure, and the one with which we
are all most familiar.
Each user / process has the concept of a current directory from which all ( relative )
searches take place.
Files may be accessed using either absolute pathnames ( relative to the root of the
tree ) or relative pathnames ( relative to the current directory. )
Directories are stored the same as any other file in the system, except there is a bit that
identifies them as directories, and they have some special structure that the OS
understands.
One question for consideration is whether or not to allow the removal of directories
that are not empty - Windows requires that directories be emptied first, and UNIX
provides an option for deleting entire sub-trees.
An acyclic graph directory structure in an operating system allows files and directories to
be accessed from multiple locations without having to create duplicate copies. This is
achieved by using links (also known as aliases) to connect different parts of the directory
structure, enabling a file or directory to be part of multiple parent directories.
• UNIX provides two types of links for implementing the acyclic-graph structure.
 A hard link ( usually just called a link ) involves multiple directory entries that
both refer to the same file. Hard links are only valid for ordinary files in the same
file system.
 A symbolic link, that involves a special file, containing information about where
to find the linked file. Symbolic links may be used to link directories and/or files
in other file systems, as well as ordinary files in the current file system.
• Windows only supports symbolic links, termed shortcuts.
General Graph Directory
• If cycles are allowed in the graphs, then several problems can arise:
• Search algorithms can go into infinite loops. One solution is to not follow links in
search algorithms. ( Or not to follow symbolic links, and to only allow symbolic links
to refer to directories. )
• Sub-trees can become disconnected from the rest of the tree and still not have their
reference counts reduced to zero. Periodic garbage collection is required to detect
and resolve this problem. ( DOS and UNIX search for these problems, among others,
even though cycles are not supposed to be allowed in either system. Disconnected
disk blocks that are not marked as free are added back to the file systems with
made-up file names, and can usually be safely deleted. )

You might also like