Unit 5 File Management PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Unit-V

File Management

Prepared By :
Konica Soni
Basics of File
• A file is a collection of related information that is recorded on secondary
storage. Or file is a collection of logically related entities.
The name of the file is divided into two parts as shown below:
• name
• extension, separated by a period.
Basics of File
File Operations

• Create :- This operation is responsible for creating a file.


• Write:- This operation is responsible to write content in file.
• Read:- This operation is responsible to read the content from file.
• Re-position or Seek operation: The seek system call re-positions the file pointers from the
current position to a specific place in the file i.e. forward or backward depending upon the
user's requirement. This operation is generally performed with those file management systems
that support direct access files.
• Delete :- This operation delete the file from the system along with it’s attributes.
• Truncate:- This operation delete the content of file but keep attribute if the file.
Basics of File
• Attributes of file
• Name – only information kept in human-readable form
• Identifier – unique tag (number) identifies file within file system which is given by operating
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
• Types of file
File Type Extensions Usage
Used for compressing multiple files or folders into a single archive for easier
Compressed Files .zip, .rar, .7z, .tar, .gz
storage and transfer.
Executable Files .exe, .bat, .sh Used for executable programs and scripts that run on a computer system.

Database Files .db, .sqlite, .accdb, .mdb Used for storing structured data in databases.

Web Files .html, .htm, .css, .js, .php, .asp Used for web pages and associated scripts and styles.
used to automate repetitive tasks, streamline processes, and manage system
Batch file .bat, .sh
operations.
System Files .sys, .dll, .ini, .log, .cfg Used for operating system configuration, logs, and other system-related data.
Backup Files .bak, .iso, .tar, .bkf Used for storing backups of files, disks, or system states.
Source Code Files .c, .cpp, .java, .py Used for storing programming source code in various languages.

Text Files .txt, .doc Plain text files, used for simple text documents without any formatting.
collections of precompiled routines or resources that software
Library file .lib, .dll programs can use to perform specific functions. These files are used to
share common code and functionalities across multiple programs
Basics of File - Access Methods
Files store information. When it is used, this information must be accessed and read into
computer memory. The information in the file can be accessed in several ways.

• Access Methods
1) Sequential Access:-
• The most simplest access method is sequential access. Information in the file is processed
in order, one record after the other. Editors and compilers are usually access files in this
fashion.
• A process can read all the data in a file in order starting from beginning but can’t skip & read
arbitrarily from any location.
• E.g. : A file consisting of 100 records, the current position of read/write head is 40th
record, suppose we want to read the 75th record then, it access sequentially from 40, 41, 42
…….. 74, 75. So the read/write head traverse all the records between 40 to 75.
Basics of File - Access Methods
(2) Direct Access:-
• A file is made up of fixed length logical records that allow programs to read and write
records rapidly in no particular order. Direct access files are of great use for immediate access
to large amount of information. Databases are often of this type.

• This method can be used when disk are used for storing files. This method is used in many
applications e.g. database systems.

• In a direct access file, there is no restriction in the order of reading or writing. For example,
we can read block 14, then read block 50 & then write block 7 etc. Direct access files are
very useful for immediate access to large amount of information
Types of Records in File
In file management, records are structured units of data stored within a file. Different types of
records are used based on how data needs to be stored, retrieved, and managed.

1) Fixed-length records –
All the records are exactly the same length. The size of each field within the
record is also fixed. This allows for easy calculation of the record's position
within the file, making retrieval straightforward.
• Example:
• Employee Database: An HR system might store employee records with
fixed fields like Employee ID, Name, and Department. Even if a name is
shorter than the allocated space, the record still occupies the full fixed length.
Types of Records in File
2) Variable-length records –
• Records in the file can vary in size depending on the amount of data they contain.
The fields within the records can also vary in length.
• This flexibility allows records to expand or contract as needed, saving space and
accommodating diverse data types.
• there is no predefined size for each record
• Example:
• Email Storage: Email systems store messages as variable-length records since the size of
each email (and its attachments) can vary significantly
• Customer Feedback: A customer service database might store feedback with variable
lengths, depending on the content of the customer's message.
Types of Records in File
• Differences Between Fixed-Length and Variable-Length Records:
• Fixed-Length:
• Simpler to access, but less efficient in storage.
• Records have uniform sizes.
• Requires padding for smaller records.
• Variable-Length:
• More efficient in terms of storage, but more complex access.
• Records can vary in size.
• No padding is necessary, but locating records can require additional indexing or metadata.
Padding is extra space added to files or memory to ensure proper alignment.
File Management
• File management is formally defined as manipulating files in a computer
system, which includes creating, modifying, and deleting files.
• The operating system's file management function entails software that
handles or maintains files (binary, text, PDF, docs, audio, video, etc.) included
in computer software.
• The operating system's file system has the ability to manage both single files
and groups of files that are present in a computer system. All of the files on
the computer system with different extensions(such as .exe, .pdf, .txt, .docx,
etc.) are managed by the operating system's file management.
Functions of File Management System in
Operating System
• It is responsible for creating new files in the computer system and placing in
specific locations.

• It is responsible for locating the existing files in the computer system.

• It facilitates keeping the files in separate folders known as directories. These


directories allow users to quickly search for files or organize files based on their
types of uses.

• It enables users to change the data of files or the name of files in directories.
Components of File Management
• File Attribute
• File Operations
• File Access Permissions
• File Systems
Components of File Management
• File Attribute
• It specifies file characteristics such as type, date of last modification, size, location on
disk, and so on. File attributes assist the user in comprehending the value and location
of files. It is used to describe all of the information about a specific file.
• File Operations
• It defines the actions that can be taken on a file, such as creating, reading, writing,
deleting, truncating etc.
Components of File Management
• File Access Permissions
• It specifies a file's access permissions, such as read and writes. Without permission, a
file cannot be accessed.
• File Systems
• A file system is a method an operating system uses to store, organize, and manage files
and directories on a storage device.
• File systems are a crucial part of any operating system, providing a structured way to
store, organize, and manage data on storage devices such as hard drives, SSDs, and USB
drives.
Components of File Management
• File Systems
• Essentially, a file system acts as a bridge between the operating system and the physical
storage hardware, allowing users and applications to create, read, update, and delete files in an
organized and efficient manner. Some common types of file systems include:

• FAT (File Allocation Table): An older file system used by older versions of Windows and other
operating systems.
• NTFS (New Technology File System): A modern file system used by Windows. It supports features
such as file and folder permissions, compression, and encryption.
• ext (Extended File System): A file system commonly used on Linux and Unix -based operating systems.
• HFS (Hierarchical File System): A file system used by macOS.
• APFS (Apple File System): A new file system introduced by Apple for their Macs and iOS devices.
File System
• The advantages of using a file system include the:
• Organization: A file system allows files to be organized into directories and
subdirectories, making it easier to manage and locate files.
• Data protection: File systems often include features such as file and folder
permissions, backup and restore, and error detection and correction, to protect data
from loss or corruption.
• Improved performance: A well-designed file system can improve the performance of
reading and writing data by organizing it efficiently on disk.
Layers of File System
• A file system is a critical component of an operating system that manages
how data is stored, organized, and retrieved on storage devices. The
architecture of a file system is typically divided into several layers, each
responsible for different aspects of file management.
Layers of File System
Layers of File System
• Application Programs: This is the topmost layer where users interact with
files through applications. It provides the user interface for file operations
like creating, deleting, reading, writing, and modifying files. Examples include
text editors, file browsers, and command-line interfaces.
• Logical File system – It manages metadata information about a file i.e
includes all details about a file except the actual contents of the file. It also
maintains via file control blocks.File Control Block(FCB) has information
about a file – owner, size, permissions, and location of file contents.
Layers of File System
• File Organization Module –
• It has information about files, the location of files and their logical and
physical blocks.
• Physical blocks do not match with logical numbers of logical blocks
numbered from 0 to N.
• It also has a free space that tracks unallocated blocks.
Layers of File System
• Basic File System:- It issue a generic command to appropriate device driver
to read and write physical blocks on the disk.
• I/O Control: -
• It consists of device drivers and interrupt handlers to transfer information between the
main memory and the disk system.
• Device drivers act as an interface between devices and OS, they help to transfer data
between disk and main memory.It takes block number as input and as output.
• This layer is responsible for managing the input/output (I/O) operations between the
file system and the storage devices.
Layers of File System
• Devices Layer:
• The bottommost layer, consisting of the actual hardware devices.
• It performs the actual reading and writing of data to the physical storage
medium.
• This includes hard drives, optical disks, and other storage devices.
Layers of File System

•When an application program asks for a file, the first request is directed to the logical file
system. The logical file system contains the Meta data of the file and directory structure. If the
application program doesn't have the required permissions of the file then this layer will throw an error.
Logical file systems also verify the path to the file.

•Generally, files are divided into various logical blocks. Files are to be stored in the hard disk and to be
retrieved from the hard disk. Hard disk is divided into various tracks and sectors. Therefore, in order to
store and retrieve the files, the logical blocks need to be mapped to physical blocks. This
mapping is done by File organization module. It is also responsible for free space management.

•Once File organization module decided which physical block the application program needs, it passes
this information to basic file system. The basic file system is responsible for issuing the
commands to I/O control in order to fetch those blocks.

•I/O controls contain the codes by using which it can access hard disk. These codes are known as
device drivers. I/O controls are also responsible for handling interrupts.
FILE Allocation Methods
The allocation methods define how the files are stored in the disk blocks. There are two types of blocks.
1) Logical Blocks :
• A logical block in a file system is an abstraction that simplifies the management of data on a storage device.

2) Physical Blocks :
• Physical blocks on a hard disk are the fundamental units of data storage located within the sectors of tracks
on the disk's platters. The file system manages these blocks, mapping them to logical data structures that
applications use.
• When a file is written to the disk, the file system divides the file into blocks. Each block is then mapped to a
physical block on the disk.
• Physical blocks are located on the surface of the platters, within the sectors of tracks. Each block
corresponds to a specific sector or a group of sectors.

• Logical Block: This is the file system’s unit of storage (like 4KB) and is where the file is stored conceptually.
• Physical Block: This is the actual storage unit on the hardware (like 512 bytes or 4KB).
• Mapping: The file system maps logical blocks to one or more physical blocks. The file system maintains a record
of where each logical block is physically stored on the disk.
FILE Allocation Methods
FILE Allocation Methods

Purpose of File Allocation:

1) Efficient disk utilization


2) Access of data should be faster.
FILE Allocation Methods

[1] Contiguous allocation


• Single set of blocks is allocated to a file at
the time of creation.
• Placing the data in contiguous way in the
storage.
• Only a single entry in the file allocation table
( Starting block and length of the file )
FILE Allocation Methods
[1] Contiguous allocation
Advantages:
• Easy to implement. : As the file comes, it is allocated to the hard disk In sequence.
• Excellent read performance : If all the instructions are placed on a hard disk in a contagious manner, it will
be effortless for the compiler to read them.
Disadvantages:
• Disk will become fragmented.
Internal fragmentation occurs when allocated memory or storage is larger than the amount of data
actually being stored.
If a file system allocates space in 4 KB blocks, but a file only needs 2 KB, the remaining 2 KB in that
block is wasted. This unused space within the allocated block is internal fragmentation.
External fragmentation occurs when free space is scattered throughout the storage medium in small,
non-contiguous blocks.
• Difficult to grow a file : Increasing file size is difficult because it depends on the availability of contiguous
memory at a particular instance.
FILE Allocation Methods
[2] Non Contiguous allocation

• Non-contiguous allocation is a method used in file systems and memory


management where data is stored in scattered or non-adjacent blocks.
1. Linked List Allocation
• According to Linked List allocation, a file does not need to be contiguous on the
disk because any file block may exist on any available hard disk location.
• But each disk block on the hard disk contains data and a pointer. The pointer points
to the next file block hard disk in the same file.
FILE Allocation Methods
[2] Non Contiguous allocation

1. Linked List Allocation


FILE Allocation Methods
[2] Non Contiguous allocation
1. Linked List Allocation

• Advantages :
• No external Fragmentation.
• File Size can increase.
• Disadvantages :
• Large seek Time. : more movement of read write
head which was not there in the contiguous
• Direct access difficult.
• Overhead of pointer. : Pointer required additional
space in the disk.
FILE Allocation Methods
[2] Non Contiguous allocation

[2]Indexed allocation

• The data could not be accessed randomly in linked list allocation, but this issue has been
resolved through the index allocation scheme.
• According to the index allocation scheme, the Directory contains an index block address for
each file.
• This Indexed block does not have the file data, but it just includes the pointers to all blocks
allocated to that particular file in the hard disk.
FILE Allocation Methods
[2]Indexed allocation
FILE Allocation Methods
[2] Non Contiguous allocation
2. Index Allocation

• Advantages :
• Support Direct Access.
• No external Fragmentation.
• Disadvantages :
• Overhead of pointer. : Pointer required additional space in the disk.
• Multilevel Index
FILE Control Matrix

• A file control matrix is a security tool used in the management of file access
permissions within an organization or a computer system.
• It provides a structured way to define and document who (users or groups) has
what type of access (read, write, execute, etc.) to which files or directories.
• The matrix helps in ensuring that only authorized individuals have access to
certain files, thereby maintaining the security and integrity of the data.
FILE Control Matrix
Key Components of a File Control Matrix:

• Users/Groups:
• The rows of the matrix typically represent individual users or groups of users.
• Files/Directories:
• The columns represent the files or directories that need to be protected or managed.
• Permissions:
• The cells within the matrix indicate the type of access each user or group has to a specific file or directory. Common
permissions include:
• Read: Permission to view or read the contents of the file.
• Write: Permission to modify or delete the file.
• Execute: Permission to run the file if it is an executable program or script.
• None: No access is granted.
FILE Control Matrix
Key Components of a File Control Matrix:
File Compression

• File compression is a process used to reduce the size of a file or a group of files by
encoding the data in a more efficient way.
• This is typically done to save storage space, reduce the time needed to transfer files over a
network, or make files easier to manage and share.
• File compression is widely used to save storage space, speed up file transfers, and make files
easier to manage and share.
File Compression

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy