0% found this document useful (0 votes)
30 views52 pages

Unit 5

Unit 5 covers file concepts, mass storage structures, and system protection in computer systems. It discusses file attributes, operations, types, and access methods, as well as directory structures and disk management techniques. Additionally, it addresses system protection mechanisms, including access control and the importance of safeguarding user data from unauthorized access.

Uploaded by

24f2002721
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)
30 views52 pages

Unit 5

Unit 5 covers file concepts, mass storage structures, and system protection in computer systems. It discusses file attributes, operations, types, and access methods, as well as directory structures and disk management techniques. Additionally, it addresses system protection mechanisms, including access control and the importance of safeguarding user data from unauthorized access.

Uploaded by

24f2002721
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
You are on page 1/ 52

Unit 5 :File concepts,Mass Storage Structure,

System Protection
Dr B.Soujanya
Assistant Professor
Department of Computer Science and Technology
GITAM Institute of Technology (GIT)
Visakhapatnam – 530045
Email: [email protected]
UNIT-5

File Concepts: File concept, access Methods, directory and disk


structure, protection.
Mass-storage structure: Disk management, disk scheduling, Swap
space management

System Protection: Goals of protection, principles of protection, Domain of


protection, Access matrix.
File
Concepts
File
A file is a named collection of related information that is recorded on
secondary storage such as magnetic disks, magnetic tapes and optical disks.
In general, a file is a sequence of bits, bytes, lines or records whose meaning is
defined by the file’s creator and user.

A file is a collection of correlated information which is recorded on secondary or


non-volatile storage like magnetic disks, optical disks, and tapes.

It is a method of data collection that is used as a medium for giving input and
receiving output from that program.
File
Concepts
Different Components are

1. File Attributes

2. File Operations

3. File Types

4. File Structure

5. Internal File structure


1. File Attributes
A File’s attribute vary from one operating system to another but typically consists of these:

➔ Name – The symbolic file name is the only information kept in human-readable form.

➔ Identifier – A unique tag (i.e., an internal number) that identifies the file

within the file system.

➔ Type – Needed for systems that support different types.

➔ Location – A pointer to file location on device

➔ Size – Current file size. (in bytes,words or blocks)

➔ Protection – Controls who can do reading, writing, executing.

➔ Time, date, and user identification – This information may be kept for creation,last

modification, and last use.These data can be useful for protection,security and

usage monitoring.
2. File Operations
A File is an abstract data type..

I. Creating a File
II. Writing a File -To write a file,we make a system call specifying both the name of
file and the information to be written to the file.
III. Reading a File: To read from a file, we use a system call specifying both the
name of the file and where the next block of the file should be kept.
IV. Repositioning within a file: The directory is searched for the appropriate entry,
and the current-file-position pointer is repositioned to a given value.
V. Deleting a File
VI. Truncating a file- The user may want to erase the contents of a file but keep its attributes.
3. File Types
4. File Structure

● Some files contain an internal structure, which may or may not be known to the OS.

● For the OS to support particular file formats increases the size and complexity of the OS.

● UNIX treats all files as sequences of bytes, with no further consideration of the internal structure.

( With the exception of executable binary programs, which it must know how to load

and find the first executable statement, etc. )

● Macintosh files have two forks - a resource fork, and a data fork. The resource fork

contains information relating to the UI, such as icons and button images, and can

be modified independently of the data fork, which contains the code or data as

appropriate
5. Internal File Structure
● Disk files are accessed in units of physical blocks, typically 512 bytes or some

power-of-two multiple thereof. ( Larger physical disks use larger block sizes, to

keep the range of block numbers within the range of a 32-bit integer. )

● Internally files are organized in units of logical units, which may be as small as a

single byte, or may be a larger size corresponding to some data record or

structure size.

● The number of logical units which fit into one physical block determines its

packing, and has an impact on the amount of internal fragmentation ( wasted

space ) that occurs.


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.

Sequential-access file.
Access
Methods
2. Direct Access
● Jump to any record and read that record. Operations supported include:
○ read n - read record number n.
○ write n - write record number n.
○ 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.

Simulation of sequential access on a direct-access file.


Directory and Disk
1 Storage Structure
Structure
● A disk can be used in its entirety for a file system.
● Alternatively a physical disk can be broken up into multiple partitions, slices, or mini-disks,
each of which becomes a virtual disk and can have its own filesystem. ( or be used for raw
storage, swap space, etc. )
● Or, multiple physical disks can be combined into one volume, i.e. a larger virtual disk,
with its own file system spanning the physical disks.

A typical file-system organization.


Directory and Disk
Structure
Consider Solaris has

1. tmpfs – memory-based volatile FS for fast, temporary I/O

2. objfs – interface into kernel memory to get kernel symbols for debugging

3. ctfs – contract file system for managing daemons

4. lofs – loopback file system allows one FS to be accessed in place of another

5. procfs – kernel interface to process structures

6. ufs, zfs – general purpose file systems


Directory and Disk
Structure
Directory and Disk
Structure
2 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


Directory and Disk
Structure
3. Single-Level Directory

● Simple to implement, but each file must have a unique name.


Directory and Disk
Structure
1 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.
Directory and Disk
Structure
Two-level directory structure.
Directory and Disk
Structure
2 Tree-Structured Directories

● 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 path names ( 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.
Directory and Disk
Structure
Tree-structured directory structure.
Directory and Disk
Structure
3 Acyclic-Graph Directories

● When the same files need to be accessed in more than one place in the
directory structure ( e.g. because they are being shared by more than one
user / process ), it can be useful to provide an acyclic-graph structure. ( Note
the directed arcs from parent to child. )
● 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 filesystem.
○ 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 filesystems, as well as ordinary files in the current
filesystem.
Directory and Disk
Structure
Acyclic-graph directory structure.
Directory and Disk
Structure
4 General Graph Directory
Protection
● In computer systems, a lot of user’s information is stored, the

objective of the operating system is 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.
Protectio
1 Types of Access
n
● The following low-level operations are often controlled:
○ Read - View the contents of the file
○ Write - Change the contents of the file.
○ Execute - Load the file onto the CPU and follow the instructions
contained therein.
○ Append - Add to the end of an existing file.
○ Delete - Remove a file from the system.
○ List -View the name and other attributes of files on the system.
Protectio
2 Access Control
n
● The most common approach to the protection problem is to make access
dependent on the identity of the user.
● Different users may need different types of access to a file or directory.
● The most general scheme to implement identity dependent access is to
associate with each file and directory an access-control list(ACL)
specifying user names and types of access allowed for each user.
The ACL may have three classifications of users of connection

A. OWNER- The user who created the file is the owner


B. GROUP- A set of users who are using sharing the file and need similar
access is a group,or work group.
C. UNIVERSE- All other users in the system constitute the universe.
3 Other Protection Approaches and Issues

● Some systems can apply passwords, either to individual files, or to specific sub-
directories, or to the entire system. There is a trade-off between the number of
passwords that must be maintained ( and remembered by the users ) and the
amount of information that is vulnerable to a lost or forgotten password.
● Older systems which did not originally have multi-user file access permissions
( DOS and older versions of Mac ) must now be retrofitted if they are to share
files on a network.
● Access to a file requires access to all the files along its path as well. In a cyclic
directory structure, users may have different access to the same file accessed
through different paths.
● Sometimes just the knowledge of the existence of a file of a certain name is a
security ( or privacy ) concern. Hence the distinction between the R and X bits
on UNIX directories.
Overview of Mass-Storage Structure
Traditional magnetic disks have the following basic structure:

● One or more platters in the form of disks covered with magnetic media. Hard disk

platters are made of rigid metal, while "floppy" disks are made of more flexible plastic.

● Each platter has two working surfaces. Older hard disk drives would sometimes

not use the very top or bottom surface of a stack of platters, as these surfaces

were more susceptible to potential damage.

● Each working surface is divided into a number of concentric rings called tracks.

The collection of all tracks that are the same distance from the edge of the

platter, is called a cylinder.


Moving-head disk mechanism.
Overview of Mass-Storage Structure

● Each track is further divided into sectors, traditionally containing 512 bytes of

data each, although some modern disks occasionally use larger sector sizes.

( Sectors also include a header and a trailer, including checksum information

among other things. )

● The data on a hard drive is read by read-write heads. The standard configuration

uses one head per surface, each on a separate arm, and controlled by a common

arm assembly which moves all heads simultaneously from one cylinder to another.
Mass-Storage Structure-Disk
Scheduling

1 FCFS Scheduling

.2 SSTF Scheduling(Shortest Seek Time First)

3 SCAN Scheduling

4 C-SCAN Scheduling

5 LOOK Scheduling
Mass-Storage Structure-Disk
Scheduling
1 FCFS
. intrinsically fair, but not very efficient.
First-Come First-Serve is simple and

The total movement are 640(45+85+146+85+108+110+59+2)


2.SSTF
● Shortest Seek Time First scheduling is more efficient, but may lead to
starvation if a constant stream of requests arrives for the same general
area of the disk.

SSTF reduces the total head movement to 236(12+2+30+23+84+24+2+59)


3.SCAN Scheduling
The SCAN algorithm, also called as the elevator algorithm moves back and forth from
one end of the disk to the other, similarly to an elevator processing requests in a tall
building

Under the SCAN algorithm, If a request arrives just ahead of the moving head then it
will be processed right away, but if it arrives just after the head has passed, then it will
have to wait for the head to pass going the other way on the return trip. This leads to a
fairly wide variation in access times which can be improved upon .
4.C-SCAN Scheduling
● The Circular-SCAN algorithm improves upon SCAN by treating all requests in
a circular queue fashion - Once the head reaches the end of the disk, it
returns to the other end without processing any requests, and then starts
again from the beginning of the disk:
5.LOOK Scheduling
LOOK scheduling improves upon SCAN by looking ahead at the queue of pending requests,
and not moving the heads any farther towards the end of the disk than is necessary.
Mass-Storage Structure-Swap-Space
Management
1 Swap-Space Use

● The amount of swap space needed by an OS varies greatly according to how it is


used. Some systems require an amount equal to physical RAM; some want a
multiple of that; some want an amount equal to the amount by which virtual
memory exceeds physical RAM, and some systems use little or none at all!
● Some systems support multiple swap spaces on separate disks in order to speed
up the virtual memory system.

2 Swap-Space Location

Swap space can be physically located in one of two locations:

● As a large file which is part of the regular filesystem. This is easy to


implement, but inefficient.
● As a raw partition, possibly on a separate or little-used disk. This allows
the OS more control over swap space management, which is usually
faster and more efficient.
Mass-Storage Structure-Swap-Space
Management
3 Swap-Space Management: An Example

● Historically Operating system swapped out entire processes as needed. Modern


systems swap out only individual pages, and only as needed. ( For example process
code blocks and other blocks that have not been changed since they were originally
loaded are normally just freed from the virtual memory system rather than copying
them to swap space, because it is faster to go find them again in the filesystem and
read them back in from there than to write them out to swap space and then read
them back. )

The data structures for swapping on Linux systems


System Protection

Protection refers to a mechanism which controls the access of programs, processes, or


users to the resources defined by a computer system

Need of Protection:
● To prevent the access of unauthorized users and
● To ensure that each active programs or processes in the system uses
resources only as the stated policy,
● To improve reliability by detecting latent error

The main components are:-

1. Goals of Protection
2. Principles of Protection
3. Domain of Protection
4. Access Matrix
1.Goals of Protection
● In one protection model, computer consists of a collection of objects, hardware or software

● Each object has a unique name and can be accessed through a well-

defined set of operations

● Protection problem - ensure that each object is accessed correctly and only

by those processes that are allowed to do so


2.Principles of
Protection
● Guiding principle – principle of least privilege

● Programs, users and systems should be given just enough privileges to


perform their tasks
● Limits damage if entity has a bug, gets abused

● Can be static (during life of system, during life of process)

● Or dynamic (changed by process as needed) – domain switching, privilege escalation

● Need to know” a similar concept regarding access to data


3.Domain of
Protection
● A computer can be viewed as a collection of processes and objects ( both HW & SW ).
● The need to know principle states that a process should only have access to
those objects it needs to accomplish its task, and furthermore only in the modes
for which it needs access and only during the time frame when it needs access.
● The modes available for a particular object may depend upon its type.

3.1 Domain Structure

● A protection domain specifies the resources that a process may access.


● Each domain defines a set of objects and the types of operations that may be
invoked on each object.
● An access right is the ability to execute an operation on an object.
● A domain is defined as a set of < object, { access right set } > pairs,
● . Note that some domains may be disjoint while others overlap
3.Domain of
Protection
● The association between a process and a domain may be static or dynamic.
○ If the association is static, then the need-to-know principle requires a way of
changing the contents of the domain dynamically.
○ If the association is dynamic, then there needs to be a mechanism for domain switching.
● Domains may be realized in different fashions - as users, or as processes, or as
procedures. E.g. if each user corresponds to a domain, then that domain defines the
access of that user, and changing domains involves changing user ID.

System with three protection domains.


3.Domain of
Protection
A domain can be realized in a variety of ways:

● Each user may be a domain.In this case,the set of objects that can be accessed

depends on the identity of the user.Domain switching occurs when the user is

changed-generally when one user logs out and another user logs in.

● Each process may be a domain.In this case, the set of objects that can be accessed

depends on the identity of the process.Domain switching occurs when one process

sends a message to another process and then waits for a response.

● Each procedure may be a domain.In this case,the set of objects that can be

accessed corresponds to the local variables defined within the procedure.Domain

switching occurs when a procedure call is made.


4. Access
Matrix
● The model of protection can be viewed as an access matrix, in which
columns represent different system resources and rows represent different
protection domains. Entries within the matrix indicate what access that
domain has to that resource.
● View protection as a matrix (access matrix)
● Rows represent domains
● Columns represent objects
● nAccess(i, j) is the set of operations that a process executing in Domain i
can invoke on Objectj
4. Access
Matrix
In the shown example of access matrix,
Access matrix
There are four domains and four objects-
three files(F1,F2,F3) and one laser printer.

A process executing in domain D1 can read files


F1 and F3.

A process executing in domain D4, has the same


privilege as one executing in domain D1,but in
addition it can also write onto files F1 and F3.

The laser printer can be accessed only by a


process executing in domain D2.
4. Access
Matrix
● Domain switching can be easily supported under this model, simply
by providing "switch" access to other domains:
4. Access
Matrix
The ability to copy rights is denoted by an asterisk, indicating that processes in that

domain have the right to copy that access within the same column, i.e. for the same

object. There are two important variations:

● If the asterisk is removed from the original access right, then the right is

transferred, rather than being copied. This may be termed a transfer right as

opposed to a copy right.

● If only the right and not the asterisk is copied, then the access right is added to

the new domain, but it may not be propagated further. That is the new domain

does not also receive the right to copy the access.


4. Access
Matrix
Access matrix with copy rights. Access matrix with owner rights.
4. Access
Matrix
● Copy and owner rights only Modified access matrix
allow the modification of
rights within a column.
● The addition of control rights,
which only apply to domain
objects, allow a process
operating in one domain to
affect the rights available in
other domains.
● For example in the table
below, a process operating in
domain D2 has the right to
control any of the rights in
domain D4.

You might also like