0% found this document useful (0 votes)
24 views37 pages

UNIT- IV OS

Uploaded by

seilmonbhaii1
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)
24 views37 pages

UNIT- IV OS

Uploaded by

seilmonbhaii1
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/ 37

▪ File concept, File Attributes

▪ File types and structures,


▪ Directory structure,
▪ File Access methods and matrices,
▪ File security,
▪ User authentication
▪ Cases studies
▪ A file is a named collection of related information that is recorded on secondary

storage such as magnetic disks, magnetic tapes and optical disks.

▪ File is a sequence of bits, bytes, lines or records whose meaning is defined by the

files creator and user.


▪ Name – only information kept in human-readable form
▪ Identifier – unique tag (number) identifies file within file system
▪ Type – needed for systems that support different types
▪ Location – pointer to file location on device
▪ Size – current file size
▪ Protection – controls who can do reading, writing, executing
▪ Time, date, and user identification – data for protection, security, and usage
monitoring
▪ Information about files are kept in the directory structure, which is maintained on the
disk
▪ Many variations, including extended file attributes such as file checksum
▪ Information kept in the directory structure
▪ File is an abstract data type, To define a file properly, we need to consider the
operations that can be performed on files.
Six basic operations:
1. Create
2. Write – at write pointer location
3. Read – at read pointer location
4. Reposition within file - seek
5. Delete: delete a file
6. Truncate: erase the contents of a file but keep its attributes
▪ Open(Fi) – search the directory structure on disk for entry Fi, and move the content of
entry to memory
▪ Close (Fi) – move the content of entry Fi in memory to directory structure on disk
▪ Several pieces of data are needed to manage open files:

▪ Open-file table: tracks open files

▪ File pointer: pointer to last read/write location, per process that has the file open

▪ File-open count: counter of number of times a file is open – to allow removal of data from

open-file table when last processes closes it

▪ Disk location of the file: cache of data access information

▪ Access rights: per-process access mode information


▪ File locks allow one process to lock a file and prevent other processes from gaining access to it
▪ File locks are useful for files that are shared by several processes—for example, a system log file
that can be accessed and modified by a number of processes in the system.
▪ Provided by some operating systems and file systems
▪ Similar to reader-writer locks
▪ Shared lock similar to reader lock – several processes can acquire concurrently
▪ Exclusive lock similar to writer lock

▪ Mediates access to a file

▪ Mandatory or advisory:
▪ Mandatory – If a lock is mandatory, then once a process acquires an exclusive lock, the operating
system will prevent any other process from accessing the locked file
▪ Advisory – processes can find status of locks and decide what to do
▪ A common technique for implementing file types is to include the type as part of
the file name.
▪ The name is split into two parts—
▪ name and
▪ Extension

▪ This two parts usually separated by a period

▪ The system uses the extension to indicate the type of the file and the type of
operations that can be done on that file.
▪ File types also can be used to indicate the internal structure of the file
▪ A File Structure should be according to a required format that the operating system
can understand.
▪ A file has a certain defined structure according to its type.
▪ A text file is a sequence of characters organized into lines.
▪ A source file is a sequence of procedures and functions.
▪ An object file is a sequence of bytes organized into blocks that are understandable
by the machine.
▪ When operating system defines different file structures, it also contains the code to
support these file structure. Unix, MS-DOS support minimum number of file
structure.
▪ A directory is a container that is used to contain folders and file. It organizes files
and folders into a hierarchical manner.
▪ The directory can be viewed as a symbol table that translates file names into their
directory entries
▪ Search for a file.

▪ Create a file

▪ Delete a file

▪ List a directory

▪ Rename a file

▪ Traverse the file system


▪ There are several logical structures of a directory, these are given below.
1. Single-level directory
2. Two-level directory
3. Tree-structured directory
4. Acyclic graph directory
5. General graph directory structure
▪ Single level directory is simplest directory structure.
▪ In it all files are contained in same directory which make it easy to support and
understand.
▪ A single level directory has a significant limitation, however, when the number of
files increases or when the system has more than one user.
▪ Since all the files are in the same directory, they must have the unique name .
▪ if two users call their dataset test, then the unique name rule violated.
▪ Advantages:
▪ Since it is a single directory, so its implementation is very easy.
▪ If the files are smaller in size, searching will become faster.
▪ The operations like file creation, searching, deletion, updating are very easy in
such a directory structure.
▪ Disadvantages:
▪ There may chance of name collision because two files can not have the same name.
▪ Searching will become time taking if the directory is large.
▪ In this can not group the same type of files together.
▪ As we have seen, a single level directory often leads to confusion of files names
among different users.
▪ the solution to this problem is to create a separate directory for each user.
▪ In the two-level directory structure, each user has there own user files directory
(UFD).
▪ The UFDs has similar structures, but each lists only the files of a single user.
▪ System’s master file directory (MFD) is searches whenever a new user ids logged in.
▪ The MFD is indexed by username or account number, and each entry points to the
UFD for that user.
▪ Advantages:
▪ We can give full path like /User-name/directory-name/.
▪ Different users can have same directory as well as file name.
▪ Searching of files become more easy due to path name and user-grouping.
▪ Disadvantages:
▪ A user is not allowed to share files with other users.
▪ Still it not very scalable, two files of the same type cannot be grouped together in
the same user.
▪ Once we have seen a two-level directory as a tree of height 2, the natural
generalization is to extend the directory structure to a tree of arbitrary height.
▪ This generalization allows the user to create there own subdirectories and to
organize on their files accordingly.
▪ A tree structure is the most common directory structure. The tree has a root
directory, and every file in the system have a unique path.
▪ A directory (or subdirectory) contains a set of files or subdirectories.
▪ A directory is simply another file, but it is treated in a special way. All directories
have the same internal format.
▪ One bit in each directory entry defines the entry as a file (0) or as a subdirectory
(1).
▪ Special system calls are used to create and delete directories.
▪ Advantages:
▪ Very generalize, since full path name can be given.
▪ Very scalable, the probability of name collision is less.
▪ Searching becomes very easy, we can use both absolute path as well as relative.

▪ Disadvantages:
▪ Every file does not fit into the hierarchical model, files may be saved into multiple
directories.
▪ We can not share files.
▪ It is inefficient, because accessing a file may go under multiple directories.
▪ An acyclic graph is a graph with no cycle and allows to share subdirectories and
files.
▪ The same file or subdirectories may be in two different directories.
▪ It is a natural generalization of the tree-structured directory. It is used in the
situation like when two programmers are working on a joint project and they need
to access files.
▪ The associated files are stored in a subdirectory, separating them from other
projects and files of other programmers, since they are working on a joint project
so they want the subdirectories to be into their own directories.
▪ The common subdirectories should be shared. So here we use Acyclic directories.
▪ It is the point to note that shared file is not the same as copy file . If any
programmer makes some changes in the subdirectory it will reflect in both
subdirectories.
▪ Advantages:
▪ We can share files.
▪ Searching is easy due to different-different paths.
▪ Disadvantages:
▪ We share the files via linking, in case of deleting it may create the problem,
▪ If the link is softlink then after deleting the file we left with a dangling pointer.
▪ In case of hardlink, to delete a file we have to delete all the reference associated
with it.
▪ In general graph directory structure, cycles are allowed within a directory structure
where multiple directories can be derived from more than one parent directory.
▪ The main problem with this kind of directory structure is to calculate total size or
space that has been taken by the files and directories.
▪ If cycles are allowed to exist in the directory, we likewise want to avoid searching
any component twice, for reasons of correctness as well as performance.
▪ A poorly designed algorithm might result in an infinite loop continually searching
through the cycle and never terminating
▪ Advantages:
▪ It allows cycles.
▪ It is more flexible than other directories structure.
▪ Disadvantages:
▪ It is more costly than others.
▪ It needs garbage collection.
▪ The way that files are accessed and read into memory is determined by Access
methods.

▪ Usually a single access method is supported by systems while there are OS's that
support multiple access methods.

▪ There are three ways to access a file into a computer system:

1. Sequential-Access,
2. Direct Access,
3. Index sequential Method.
▪ Data is accessed one record right after another is an order.
▪ Read command cause a pointer to be moved ahead by one.
▪ Write command allocate space for the record and move the pointer to the new End
Of File.
▪ Such a method is reasonable for tape.
▪ This method is useful for disks.
▪ The file is viewed as a numbered sequence of blocks or records.
▪ There are no restrictions on which blocks are read/written, it can be dobe in any
order.
▪ User now says "read n" rather than "read next".
▪ "n" is a number relative to the beginning of file, not relative to an absolute physical
disk location.
▪ It is the other method of accessing a file which is built on the top of the sequential
access method.
▪ These methods construct an index for the file.
▪ The index, like an index in the back of a book, contains the pointer to the various
blocks.
▪ To find a record in the file, we first search the index and then by the help of pointer
we access the file directly.
▪ It is built on top of Sequential access.
▪ It uses an Index to control the pointer while accessing files.
▪ To keep safe the data of the user from the improper access to the system.

▪ Protection can be provided in number of ways. For a single laptop system, we might
provide protection by locking the computer in a desk drawer or file cabinet.

▪ For multi-user systems, different mechanisms are used for the protection.

▪ The files which have direct access of the any user have the need of protection.

▪ The files which are not accessible to other users doesn’t require any kind of protection.

▪ The mechanism of the protection provide the facility of the controlled access by just
limiting the types of access to the file
▪ Types of Access :
▪ Read –
Reading from a file.
▪ Write –
Writing or rewriting the file.
▪ Execute –
Loading the file and after loading the execution process starts.
▪ Append –
Writing the new information to the already existing file, editing must be end at the end of the
existing file.
▪ Delete –
Deleting the file which is of no use and using its space for the another data.
▪ List –
List the name and attributes of the file.
▪ Operations like renaming, editing the existing file, copying; these can also be controlled.
▪ Access Control :
▪ There are different methods used by different users to access any file.
▪ The general way of protection is to associate identity-dependent access with all the
files and directories an list called access-control list (ACL) which specify the names
of the users and the types of access associate with each of the user.
▪ The main problem with the access list is their length. If we want to allow everyone
to read a file, we must list all the users with the read access.
▪ The access to any system is also controlled by the password. If the use of password
are is random and it is changed often, this may be result in limit the effective access
to a file.
The use of passwords has a few disadvantages:

▪ The number of passwords are very large so it is difficult to remember the large
passwords.

▪ If one password is used for all the files, then once it is discovered, all files are
accessible; protection is on all-or-none basis.

You might also like