Operating Systems 635-321


 McGill Conted

 



Advanced Search

animated computer crash by Denton






Corbis Images FALL 2000
Lecture Notes 3: File Management Click here to download the course notes in zipped format.



FILE MANAGER

RESPONSIBILITIES

  • Keep track of where each file is stored
  • Use a policy that will determine where and how the files will be stored, making sure to use the available storage efficiently and to provide efficient access.
  • Allocate each file when a user has been cleared for access to it, then record its use.
  • Deallocate the file when the file is to be returned to storage, and communicate its availability to other resources that may be waiting for it.

As well, the File Manager often determines who will have access to what material. Access should be as flexible as possible without compromising security.

Some basic definitions:

Field: a group of related bytes identified by the user with a name, type and size.

Record: a group of related fields.

File: a group of related records that contain information to be used by specific application programs. Often called a "flat" file because it has no connection to other files.

Database: groups of related files that are Interconnected to give flexibility of access. File Manager must be able to support it.

Although program files contain instructions and data files contain data, File Manager treats them the same way.

Directories are listings of file names and their attributes. Treated in the same way as files.

INTERACTING WITH THE FILE MANAGER

Can interact directly or from inside a program.

Eg READ, WRITE, OPEN, CLOSE, APPEND from a program

CREATE, DELETE, RENAME, COPY etc would be direct.

The action of saving a file from an application results in its creation. OPEN FOR WRITE command usually results in creation of file.

These commands must be designed to be as simple as possible and devoid of any instructions required to run the device where the file may be stored i.e. device independent. User needs to know nothing about how the file is stored.

VOLUME CONFIGURATION

Volume: a storage unit, whether removable or not.

Volume can contain many files and large files may span many volumes.

First part of volume always reserved for volume descriptor, which contains:

  • Date volume was created.
  • Location of directory
  • Location of files
  • How volume is formatted
  • Volume name

Master File Directory is stored immediately after volume description and lists names and characteristics of every file contained in the volume. Can contain program files, data file, system files, and subdirectories.

Older operating systems support only a single directory. Many problems:

  • Long search for particular files
  • Many small files would cause directory area to fill up before disk storage space.
  • Couldn’t relate files
  • Had to give unique name
  • Problems with security in multi-user situation.

Subdirectories often used to handle multi-user situation. Subdirectory a file that contains records that contain same information as Master File Directory.

Users (or subdirectories) are allowed to have sub-directories.

Regardless of the complexity of directory system, each directory entry typically may contain:

  • File name
  • File type (eg file vs subdirectory)
  • File size (could be computed but stored in directory)
  • File location - usually starting point
  • Date and time of creation
  • Owner
  • Access information
  • Record size

FILE NAMING CONVENTIONS

Files have relative file names and absolute file names.

Often have an extension.

Relative file name: Selected by the user when file is created. Every operating system has specific rules that affect the length and allowable characters of the relative file name.

Users should try to choose appropriate names.

Some extensions may be recognised by operating system eg .exe or .cob. Be careful!

Absolute file names: This is the complete name, which may include the path to the file in the directory system, the particular disk drive, the node in the network that holds the user and even a version number if the file has had multiple revisions.

User rarely uses absolute file name because File Manager often sets a starting directory when user logs onto system and from then on files are presumed to be in current or working directory.

FILE ORGANISATION

Record format can be:

  • Fixed length - if record length is too small, large records are truncated if too large space is wasted.
  • Variable length- avoids waste and truncation but cause problems for direct access. Good for sequential files.

Physical file organisation can be:

  • Sequential: Easiest to implement. File is searched from the beginning until requested record is found. Can use keys or ordered search to streamline process. Because file is ordered must be completely rewritten when updated.
  • Direct access: Only available on direct access device. Records addressed by computing logical address, often via "hashing". Uses key field to calculate hash value. Can be a problem with collisions, so another hashing function may be used to resolve collisions. Direct access files easy to update.
  • Indexed sequential files: Combines best of sequential and direst access. Doesn’t use hashing. Instead, generates index file. Each entry in index file contains highest record key of blocks of records as well as physical location on the device. The index file acts as a pointer to the data file. There can be overflow areas. Software manages this type of file.

 

DOS FILE MANAGER

Supports sequential, direct and indexed sequential files.

Can have either variable or fixed length records for sequential files. However, fixed length for direct and indexed sequential.

File name rules:

  • No spaces allowed.
  • Consisted of drive, directory, subdirectory, primary name and optional extension.
  • Not case sensitive.
  • Directories and subdirectories preceded by a back slash.
  • Primary file name can be up to 8 letters long.
  • Primary name and extension separated by a period.
  • File extension can have special meaning, e.g. exe,com and bat.
  • If no directories or subdirectories included in the path, assumes current directory. If no drive is designated, assumes current.

Version 2.0 and up permits subdirectories.

Formatting lays down sectors of 512 bytes each. Sectors are grouped into clusters or allocation units. The number of sectors per cluster depends on the particular storage device. Formatting also creates the boot sector, the root directory and the FAT (file allocation table).

Boot sector is designed to start DOS if it is a bootable disk (otherwise give error "Non-system disk"). Identifies version of DOS that disk was formatted with, identifies size of FAT.

In the root directory is stored:

  • File name and optional extension.
  • File size in bytes
  • Date and time of last modification
  • The starting cluster
  • The attribute byte.

Sample directory listing

Volume in drive C is A;

Volume Serial Number is 14F6-7366

Directory of C:\

05/03/00
08/17/99
05/11/98
08/17/99
01/08/00
08/20/00
02/13/00
02/13/00
02/13/00
02/13/00
02/13/00
03/28/00
03/28/00
09/04/00
05:14p
07:22a
09:01p
07:22a
01:44a
02:38p
11:19a
11:34a
12:17p
07:09p
07:09p
07:35p
08:08a
04:53p
<DIR>
0
5,239
0
<DIR>
48,640
556
395
232
30
425
<DIR>
30,720
<DIR>
Acrobat3
AUTOEXEC.BAT
CHOICE.COM
CONFIG.SYS
DOWNLD
dsobj.doc
EX1.BAT
EX2.BAT
EX3.BAT
ex4
EX4.BAT
Games
MillerMemo.doc
MTIII

The number of entries is root directory is fixed, but unlimited in sub-directories.

File attributes

A
A
A
A H
A H
A H
A H
A SHR
A
A SHR
C:\EX3.BAT
C:\ex4
C:\EX4.BAT
C:\ffastun.ffa
C:\ffastun.ffl
C:\ffastun.ffo
C:\ffastun0.ffx
C:\IO.SYS
C:\MillerMemo.doc
C:\MSDOS.SYS

FAT indicates status of all clusters on the disk – which have been allocated, which are free and which can’t be allocated.

Following starting cluster from directory listing, all successive clusters are located by following a chain. Last entry in the chain is FF hex. Which indicated end of file. A file’s sectors do not have to be contiguous. However, fragmentation may ensue.

 

 

 

 







All content © 2000-2001 Ann Logan - Web Site © 2000-2001 Carol Busato
Please address your comments and inquiries to lbusato@videotron.ca

Last updated April 7, 2001