0% found this document useful (0 votes)
21 views34 pages

Chapter 7

Uploaded by

Ayano Boresa
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)
21 views34 pages

Chapter 7

Uploaded by

Ayano Boresa
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/ 34

Chapter 7: File Management

• 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, file is a sequence of bits, bytes, lines or records whose meaning is
defined by the files creator and user.
• Commonly, files represent programs (both source and object forms) and data.
Metadata
• Metadata is "data that provides information about other data" like
o Means of creation of the data
o Purpose of the data
o Time and date of creation
o Creator or author of the data
o Location on a computer network where the data was created
February, 2024 1
Cont…
 Three distinct types of metadata exist: descriptive metadata, structural
metadata, and administrative metadata.
– Descriptive metadata- describes a resource for purposes such as discovery
and identification. It can include elements such as title, abstract, author, and
keywords.
– Structural metadata is metadata about containers of data and indicates how
compound objects are put together.
o It describes the types, versions, relationships and other characteristics of
digital materials.
– Administrative metadata provides information to help manage a resource,
such as when and how it was created, file type and other technical
information, and who can access it.

2
Cont…
Objectives for a file management system:
• To meet the data management needs and requirements of the user.
• To optimize performance, both from the system point of view in terms of
over-all throughput and from the user’s point of view in terms of response
time.
• To provide I/O support for a variety of storage device types
• To minimize or eliminate the potential for lost or destroyed data.
• To provide a standardized set of I/O interface routines to user processes.
• To provide I/O support for multiple users, in the case of multiple-user
systems.

4
Cont…
 OS does the following activities in file management.
• Creating and deleting of files

• Creating and deleting of directories

• Mapping files into secondary storage

• Backing up files on stable storage media

• Transmission of files elements b/n main and secondary storage.

 The operating system is also hide the details of the disks and other
I/O devices and present the programmer with a nice, clean abstract
model. 5
File directories
• A directory is a container that is used to contain folders and files.
• It organizes files and folders in a hierarchical manner.
• The directory can be viewed as a symbol table that translates file names into
their directory entries.
• If we take such a view, we see that the directory itself can be organized in
many ways.
• In this section, we examine several schemes for defining the logical structure
of the directory system.
• The operations that are to be performed on a directory:

6
Cont…
Directory Operations

• Create file • Readdir


• Delete • Rename
• Opendir • Link
• Closedir • Unlink
• Search file

7
Table1 Information Elements of a File Directory
Cont…

8
Cont…
 The most common schemes for defining the logical structure of a directory:-
Single-Level Directory

Fig Single-level directory

9
Cont…
Two-Level Directory
• As we have seen, a single-level directory often leads to confusion of file names
among different users. The standard solution is to create a separate directory for each
user.
• In the two-level directory structure, each user has his own user file directory (UFD).
• The UFDs have similar structures, but each list only the files of a single user. When a
user job starts or a user logs in, the system’s master file directory (MFD) is searched.
• The MFD is indexed by user name or account number, and each entry points to the
UFD for that user (Figure below).

Fig: Two-level directory structure 10


Cont…
Tree-Structured Directories
• Once we have seen how to view a two-level directory as a two-level tree, the
natural generalization is to extend the directory structure to a tree of arbitrary
height (fig).
• This generalization allows users to create their own subdirectories and to
organize their files accordingly.
• A tree is the most common directory structure.
• The tree has a root directory, and every file in the system has a unique path
name.
• 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.

11
Cont…
• Path names can be of two types:- absolute and relative:-
– An absolute path name begins at the root and follows a path down to the
specified file, giving the directory names on the path.
– A relative path name defines a path from the current directory.

Fig. Tree-structured directory structure 12


File systems: partitioning, mount/unmount, and virtual
file systems
Partition
• Partition is a logical division of a hard disk that is treated as a separate unit by
OS and file systems.
• The OS and file systems can manage information on each partition as if it were
a distinct hard drive.
• This allows the drive to operate as several smaller sections to improve
efficiency, although it reduces usable space on the hard disk because of
additional overhead from multiple OS.
• A disk partition manager allows system administrators to create, resize, delete
and manipulate partitions, while a partition table logs the location and size of
the partition.
• Each partition appears to the OS as a distinct logical disk, and the OS reads the
partition table before any other part of the disk.
13
Cont…

Fig. Disk partitioning

15
Cont….
• Disk partitioning or disk slicing is the creation of one or more regions on
secondary storage, so that each region can be managed separately.
• The disk stores the information about the partitions’ locations and sizes in an area
known as the partition table.
• Each partition then appears to the OS as a distinct “logical” disk that uses part of
the actual disk.
• System administrators use a program called a partition editor to create, resize,
delete, and manipulate the partitions.
• Partitioning allows the use of different file systems to be installed for different
kinds of files.
• Partitioning can also make backing up easier.

16
Cont…
• A disadvantage is that it can be difficult to properly size partitions,
resulting in having one partition with too much free space and
another nearly totally allocated.
• Once a partition is created, it is formatted with a file system such as:
– NTFS (New Technology File System) on Windows drives;
– FAT32 (File Allocation Table) and exFAT for removable drives;
– HFS Plus (HFS+) on Mac computers; or
– Ext4 (extended file system) on Linux

17
Cont…
Mounting and Unmounting File Systems
• Before you can access the files on a file system, you need to mount the file system.
• Mounting is a process by which the OS makes files and directories on a storage
device available for user to access via the computer's file system.
• In general, the process of mounting consists OS acquiring access to the storage
medium; recognizing, reading, processing file system structure and metadata on it;
before registering them to the virtual file system component.
• When you mount a file system, any files or directories in the underlying mount
point directory are unavailable as long as the file system is mounted.
• These files are not permanently affected by the mounting process, and they become
available again when the file system is unmounted.
• However, mount directories are typically empty, because you usually do not want
to obscure existing files.

18
Cont…
Virtual File System
• An OS can have multiple file systems in it.
• Virtual File Systems are used to integrate multiple file systems into an
orderly structure.
• The key idea is to abstract out that part of the file system that is common
to all file systems and put that code in a separate layer that calls the
underlying concrete file system to actually manage the data.
• Structure of Virtual File Systems in UNIX system:

19
Standard implementation techniques
• File system implementation defines

– how files and directories are stored,

– how disk space is managed, and

– how to make everything work efficiently and reliably.

21
Cont…
.

Fig: File system layout 22


Cont..
 File Systems are stored on disks. The above figure depicts a possible File-
System Layout.
• MBR: Master Boot Record is used to boot the computer
• Partition Table: Partition table is present at the end of MBR. This table gives
the starting and ending addresses of each partition.
• Boot Block: When the computer is booted, the BIOS reads in and executes the
MBR.
– The first thing the MBR program does is locate the active partition, read in its first
block, which is called the boot block, and execute it.
– The program in the boot block loads the operating system contained in that
partition.
– Every partition contains a boot block at the beginning though it does not contain a
bootable operating system.
• Super Block: It contains all the key parameters about the file system and is read
into memory when the computer is booted or the file system is first touched
23
File Allocation Methods
• The direct-access nature of disk gives us flexibility in the
implementation of files.
• Almost every case, many files are stored on the same disk.
• The main problem is how to allocate space to these files so that disk
space is utilized effectively and files can be accessed quickly.
• Files have allocated disk spaces by OS.
• Three major methods of allocating disk space are:
o Contiguous Allocation
o Linked Allocation
o Indexed Allocation

24
Cont…
Contiguous Allocation
• Each file occupies a contiguous address space on disk.
• Assigned disk address is in linear order.
• Easy to implement.
• External fragmentation is a major issue with this type of allocation technique.
Linked Allocation
• Each file carries a list of links to disk blocks.
• Directory contains link / pointer to first block of a file. No external fragmentation
• Effectively used in sequential access file. Inefficient in case of direct access file
Indexed Allocation
• Provide solutions to problems of contiguous and linked allocation.
• An index block is created having all pointers to files.
• Each file has its own index block which stores the addresses of disk space occupied
by the file.
25
• Directory contains the addresses of index blocks of files.
Memory-mapped files
• A memory-mapped file contains the contents of a file in virtual
memory.
• This mapping between a file and memory space enables an
application, including multiple processes, to modify the file by
reading and writing directly to the memory.
• You can use managed code to access memory-mapped files in the
same way that native Windows functions access memory-mapped
files, as described in Managing Memory-Mapped Files.
• There are two types of memory-mapped files:

26
Cont..
• Persisted memory-mapped files:
– Persisted files are memory-mapped files that are associated with a source file
on a disk.
– When the last process has finished working with the file, the data is saved to
the source file on the disk.
– These memory-mapped files are suitable for working with extremely large
source files.
• Non-persisted memory:
– Non-persisted files are memory-mapped files that are not associated with a
file on a disk.
– When the last process has finished working with the file, the data is lost and
the file is reclaimed/saved by garbage collection.
– These files are suitable for creating shared memory for inter-process
communications.

27
Naming, searching, access, backups
Naming
• Users need to be able to refer to a file by a symbolic name.
• Clearly, each file in the system must have a unique name in order that
file references be unambiguous.
• The use of a tree-structured directory minimizes the difficulty in
assigning unique names.
• Any file in the system can be located by following a path from the root
or master directory down various branches until the file is reached.
• The series of directory names, ends in the file name itself, constitutes a
pathname for the file.

29
Cont…
File Access Methods
• Files store information, when it is used, this information must be accessed
and read into computer memory.
• File access mechanism refers to the manner in which the records of a file
may be accessed.
• There are several ways to access files but the most file access methods are:-
– Sequential access
– Direct/Random access
Sequential file access
• It is that in which the records are accessed in some sequence, i.e., the
information in the file is processed in order, one record after the other.
• Information in the file is processed in order, one record after the other.
• This mode of access is by far the most common; for example, editors and
compilers usually access files in this fashion.
• Reads and writes make up the bulk of the operations on a file. 30
Cont…
• In this type of file, a fixed format is used for records.
• All records are of the same length, consisting of the same number of fixed length
fields in a particular order. Because the length and position of each field are
known, only the values of fields need to be stored; the field name and length for
each field are attributes of the file structure.
• One particular field, usually the first field in each record, is referred to as the key
field .
• The key field uniquely identifies the record; thus key values for different records
are always different.
• Further, the records are stored in key sequence: alphabetical order for a text key,
and numerical order for a numerical key.
– read all bytes/records from the beginning
– cannot jump around, could rewind or back up
– convenient when medium was magnetic tape
31
Cont…
Random access
• Random access file organization provides, accessing the records directly.
• Each record has its own address on the file with by the help of which it can be
directly accessed for reading or writing and the records need not be in any sequence
within the file.
• Here, a file is made up of fixed-length logical records that allow programs to read
and write records rapidly in no particular order.
• The direct-access method is based on a disk model of a file, since disks allow
random access to any file block.
• For direct access, the file is viewed as a numbered sequence of blocks or records and
there are no restrictions on the order of reading or writing for a direct-access file.
• Direct-access files are of great use for immediate access to large amounts of
information.
• Databases are often of this type. When a query concerning a particular subject
arrives, we compute which block contains the answer and then read that block
32
directly to provide the desired information.
Cont…
File Attributes
• Every file has a name, its data, the date and time the file was created and the file’s
size. We will call these items the file’s attributes.
• A file’s attributes vary from one OS to another but typically consist of these:
– Name – only information kept in human-readable form
– Identifier – unique tag usually a number identifies file within file system; it is
the non-human-readable name for the file.
– Type – the information is needed for systems that support different types of files.
– Location – pointer to file location on device and to the location of the file on that
device
– Size – current file size and possibly the maximum allowed size
– Protection – controls who can do reading, writing, executing and so on.
– 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.

33
Cont…
File Operations
• A file is an abstract data type the to define a file properly, we need to consider
the operations that can be performed on files.
• The operating system can provide system calls to create, write, read, reposition,
delete, and truncate files.
• Let's examine what the OS must do to perform each of these six basic file
operations.
– Create: A new file is defined and positioned within the structure of files.
– Delete: A file is removed from the file structure and destroyed.
– Open: An existing file is declared to be “opened” by a process, allowing the process to
perform functions on the file.
– Close: The file is closed with respect to a process, so that the process no longer may perform
functions on the file, until the process opens the file again.
– Read: A process reads all or a portion of the data in a file.
– Write: A process updates a file, either by adding new data that expands the size of the file or
by changing the values of existing data items in the file. 34
Cont…
Backup
• Backup is a process in which the state, files and data of a computer system are
duplicated to be used as a backup or data substitute when the primary system
data is corrupted, deleted or lost.
• A system backup is the process of backing up the OS, files and system specific
useful data.
• System backup primarily ensures that not only the user data in a system is
saved, but also the system’s state or operational condition.
• This helps in restoring the system to the last saved state along with all the
selected backup data.
• Generally, the system backup is performed through backup software and the end
file generated through this process.
• There are mainly three types of backups are there: Full backup, differential
backup, and incremental backup. 35
Cont…
• Types of Backups:-
– Full backup
– Differential backup Reading assignment about the 3
types of Backup
– Incremental backup

36
Cont….
SEARCHING
– As the number of files in your folders increases, browsing through folders
becomes a cumbersome way of looking for files. However, you can find the
file you need from among thousands of photos, texts and other files by using
the search function of your OS.
– The search function allows you to look for files and folders based on file
properties such as the file name, save date or size.
– In Windows, you can search for files quickly by clicking the Start button at
the bottom left of the screen.
– Also note that the search results are grouped by file type.
– If you are unable to find the file you are looking for by using the quick
search, you can narrow the search results by file type by clicking the icons
above the search term.
– You can narrow down your search results to: apps, settings, documents,
folders, photos, videos and music.

37
.

38

You might also like