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

7chapter Seven - File Management BEST

Chapter 7 discusses file management in operating systems, covering file naming conventions, structures, types, and access methods. It explains the differences between sequential and random access, as well as various file operations like create, delete, open, and close. Additionally, it outlines directory structures, including single-level, two-level, and hierarchical systems, and their functionalities.

Uploaded by

jamsibro140
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)
21 views26 pages

7chapter Seven - File Management BEST

Chapter 7 discusses file management in operating systems, covering file naming conventions, structures, types, and access methods. It explains the differences between sequential and random access, as well as various file operations like create, delete, open, and close. Additionally, it outlines directory structures, including single-level, two-level, and hierarchical systems, and their functionalities.

Uploaded by

jamsibro140
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/ 26

Chapter 7

File Management

Operating System
1
Introduction

• File is an object on a computer that stores data, information, setting


or commands that are used with a program.

2
File Naming

• When a process creates a file, it gives the file a name. When the
process terminates, the file continues to exist and can be accessed by
other processes using its name.
• The exact rules for file naming vary somewhat from system to
system.
• But all current operating systems allow strings of one to eight letters
as legal file names.
• Frequently digits and special characters are also permitted, so names
like 2, urgent!, and Fig.2-14 are often valid as well.
• Many file systems support names as long as 255 characters.

3
File Naming (Cont.)

• Some file systems distinguish between upper- and lowercase letters,


whereas others do not. UNIX falls in the first category; the old MS-
DOS falls in the second.
• Thus, a UNIX system can have all of the following as three distinct
files: maria, Maria, and MARIA. In MS-DOS, all these names refer to
the same file.
• Many operating systems support two-part file names, with the two
parts separated by a period, as in prog.c.
• The part following the period is called the file extension and usually
indicates something about the file.
• In MS-DOS, for example, file names are 1 to 8 characters, plus an
optional extension of 1 to 3 characters.

4
File Naming (Cont.)

5
File Structure

• Files can be structured in any of several ways.

6
File Structure: Byte Sequence

• The file in Fig. 4-2(a) is an unstructured sequence of bytes.


• In effect, the operating system does not know or care what is in the
file. All it sees are bytes.
• Meaning on the bytes is imposed by user programs.
• Provides maximum flexibility but minimal support.
• User programs can put anything they want in their files and name
them any way that they find convenient
• Advantages to users who want to define their own semantics on files.
• Both UNIX and Windows use this approach.

7
File Structure: Record Sequence

• In this model, a file is a sequence of fixed-length records, each with


some internal structure.
• No current general-purpose system uses this model as its primary file
system any more, but back in the days of 80-column punched cards
and 132-character line printer paper this was a common model on
mainframe computers.

8
File Structure: Tree

• In this organization, a file consists of a tree of records, not necessarily


all the same length, each containing a key field in a fixed position in
the record.
• The tree is sorted on the key field, to allow rapid searching for a
particular key.
• Is used on some large mainframe computers for commercial data
processing.

9
File Types

• Many operating systems support several types of files.


• UNIX (again, including OS X) and Windows, for example, have regular
files and directories.
• UNIX also has character and block special files.
• Regular files are the ones that contain user information.
• Directories are system files for maintaining the structure of the file
system.
• Character special files are related to input/output and used to model
serial I/O devices, such as terminals, printers, and networks.
• Block special files are used to model disks.
• We will be primarily interested in regular files.

10
File Types (Cont.)

11
File Access

• Early operating systems provided only one kind of file access:


sequential access.
• In these systems, a process could read all the bytes or records in a file
in order, starting at the beginning, but could not skip around and
read them out of order.
• Sequential files could be rewound, however, so they could be read as
often as needed. Sequential files were convenient when the storage
medium was magnetic tape rather than disk.
• When disks came into use for storing files, it became possible to read
the bytes or records of a file out of order, or to access records by key
rather than by position.
• Files whose bytes or records can be read in any order are called
random-access files. They are required by many applications.

12
File Attribute

13
File Operations

• Create: The file is created with no data. The purpose of the call is to announce that the
file is coming and to set some of the attributes.
• Delete: When the file is no longer needed, it has to be deleted to free up disk space.
There is always a system call for this purpose.
• Open: Before using a file, a process must open it. The purpose of the open call is to allow
the system to fetch the attributes and list of disk addresses into main memory for rapid
access on latter caller.
• Close: When all the access are finished, the attributes and disk addresses are no longer
needed, so the file should be closed to free up internal table space. Many systems
encourage this by imposing a maximum number of open files on processes. A disk is
written in blocks, and closing a file forces writing of the file’s last block, even though that
block may not be entirely full not.
• Read: Data are read from file. Usually, the bytes come from the current position. The
caller must specify how much data are needed and must also provide a buffer to put
them in.
• Write: Data are written to the file again, usually at the current position. If the current
position is the end of the file, the file’s size increases. If the current position is in the
middle of the file, existing data are overwritten and lost forever.
14
File Operations (Cont.)

• Append: This call is a restricted in the form of write. It can only add data to the end of the file.
Systems that provide a minimal set of system calls do not generally have append, but many
systems provide multiple ways of doing the same thing, and these systems sometimes have
append.
• Seek: For random access files, a method is needed to specify from where to take the data. One
common approach is a system call, seek, that repositions the file pointer to a specific place in
the file. After this call has completed, data can be read from, or written to, that position.
• Get Attributes: Processes often need to read file attributes to do their work. For example, the
UNIX make program is commonly used to manage software development projects consisting
of many source files. When make is called, it examines the modification times of the entire
source and objects files and arranges for the minimum number of compilations required to
bringing everything up to date. To do its job, it must look at the attributes, namely the
modification times.
• Set Attributes: Some of the attributes are user settable and can be changed after the file has
been created. This system call makes that possible. The protection mode information is an
obvious example. Most of the flags also fall in this category.
• Rename: It frequently happens that a user needs to change the name of an existing file. This
system call makes that possible. It is not always strictly necessary, because the file can usually
be copied to a new file with the new name, and the old file then deleted.

15
• Sequential access
• Read all bytes/records from the beginning sequentially.
• Cannot jump around, could rewind or back up.
• Convenient when medium is magnetic tape, rather than disk.
• Random access
• Bytes/records read in any order.
• Essential for data base systems.
• Read can be (Move file marker (seek), then read or Read and then move file marker.) like
magnetic disk.
• Shared Files
• File system containing a shared file
• Sharing of files on multi-user systems is desirable.
• Sharing may be done through a protection scheme.
• On distributed systems, files may be shared across a network.
• Network File System (NFS) is a common distributed file-sharing method.
16
• DIRECTORY
• Directory Structure
• A collection of nodes containing information about all files.
• Both the directory structure and the files reside on disk.
• Backups of these two structures are kept on tapes.

17
• Information on Device Directory:
• Name
• Type
• Address
• Current length
• Maximum length
• Date last accessed (for archival)
• Date last updated (for dump)
• Owner ID (who pays)
• Protection information

18
• Operations Performed on a Directory
• Search for a file
• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system

• Types of Directory Structures
• Single Level Directory
• Two level Directory
• Tree structured Directory
• Acyclic graph Directory
• General Graph Directory
19
Single-Level Directory Systems

• A single level directory system contains 4 files

• Two-Level Directory Systems


• Letters indicate owners of the directories and files.
• Eliminates name confusion across users.
• May not be satisfactory if users have many files.

20
21
• Hierarchical Directory Systems
• Efficient searching
• Grouping Capability

22
• 4. Acyclic Graph Directories:
• The acyclic directory structure is an extension of the tree-structured
directory structure. In the tree-structured directory, files and
directories starting from some fixed directory are owned by one
particular user. In the acyclic structure, this prohibition is taken out
and thus a directory or file under directory can be owned by several
users.
• Have shared subdirectories and files.
• No cycles

23
24
5. 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.

25
Thank you

26

You might also like