file management in general slides

46
File Management

Upload: bombertest1

Post on 10-Apr-2015

131 views

Category:

Documents


5 download

DESCRIPTION

Z:\common\HJP\temp

TRANSCRIPT

Page 1: File Management in General Slides

File Management

Page 2: File Management in General Slides

File Manager System• Software responsible

– for creating, deleting, modifying a physical files– Controlling access to files– Managing the resources used by files– Provides support

• for libraries of programs• Data to on-line users• Spooling operations• Interactive computing

• Functions are performed in collaboration with the Device manager

• Has a complex job. In charge of the system’s physical components, its information resource, and the policies used to store and distribute the files.

Page 3: File Management in General Slides

File ManagementTo carry out these responsibilities it must perform four tasks

1. Keep track of where each file is stored.

2. Use a policy that will determine where and how the files will be stored, making sure to efficiently use the available storage space and provide efficient access to the files.

3. Allocate each file when a user has been cleared for access to it, then record its use.

4. De allocate the file when the file is to be returned to storage, and communicate its availability to others who may be waiting for it.

Page 4: File Management in General Slides

Files System is like a LIBRARY• File manager playing the part of the librarian who performs the

same four tasks

1. A librarian uses the card catalog to keep track of each item in the collection: the cards list the call number and the details that help the patrons find each book.

2. The library relies on a predetermined policy to store everything in the collection including oversized book, magazines, recording, maps etc. And they must be arranged so people can find what they need.

3. When it is required, the book is retrieved from its shelf and the borrower’s name is recorded in the circulation file.

4. When the book is returned, the librarian deletes the entry from the circulation file and re-shelves the item.

Page 5: File Management in General Slides

Basic Definition relate to File Manager• Field – is a group of related bytes that can be identified by

the user with name, type, and size.• Record – is a group of related fields.• File – is a group of related records that contains

information to be used by specific application program.• Database – appears to the file manager to be a type

of file, but are more complex because they’re actually groups of related files that are interconnected

• Program files – contains instructions• Data files – contain data• Directories – are listings of file names and their

attributes

Page 6: File Management in General Slides

Example

Nama umur sekolah Penjaga

Mohd Syakirin 19 KMK Rusdi

Syahida Husna 17 SMSA Rusdi

Syahirah Husna 14 SMSB Rusdi

Syazwina Husna 12 SKTR Rusdi

Mohd. Syazwan 12 SKTR Rusdi

Syafiqah Husna 10 SKTR Rusdi

Field

recordfile

Page 7: File Management in General Slides

Interacting With File Manager

• User communicates with the file manager via a specific commands that may be either– Embedded in the user’s program

• E.q OPEN, CLOSE, READ, WRITE, MODIFY– Submitted interactively by the user.

• E.q CREATE, DELETE, RENAME, COPY• Design to be simple and device

independent

Page 8: File Management in General Slides

Typical Volume Configuration• Normally the active files for a computer system reside on

secondary storage units.– Removable storage units

• such as tapes, floppy disks and removable disk pack

• Files not frequently used can be stored offline and mounted only when the user specifically request

– Integrated storage unit such as drums, hard disks and non removable disk packs

• Both is considered a volume– ‘multi-file volume’ – a volume contain several files– ‘multi-volume file’ – extremely large file contained in

several volumes.

Page 9: File Management in General Slides

Volume Configuration - continue

• As an analogy–We have many college

accommodation –Each college we can consider as a

volume

Page 10: File Management in General Slides

Volume Configuration - continue• Each volume is given a name• The File Manager writes the name and other

descriptive information on an easy-to-access place – at the beginning of the magnetic tape or – first sector of the outermost track of the disk pack– Example of volume descriptor:-

Creation Date

Pointer to Directory Area

Pointer to File Area

File System Code

Volume Name

Date When volume was created

Indicates first sector where directory is stored.

Indicates first sector where file is stored

Used to detect volumes with incorrect formats

User-allocated Name

Page 11: File Management in General Slides

Volume Configuration - continue• As an analogy

– We have many college accommodation – Each college we can consider as a

volume and given a name and college manager write a college descriptor as belowCreation

Date

Pointer to Directory Room

Pointer to student room

Volume Name

Date When volume(college) was created

Indicates first room where student directory is stored.

Indicates first room where student is stored

User-allocated college Name

Page 12: File Management in General Slides

Volume Configuration - continue• Master file directory (MFD)

– Stored immediately after the volume descriptor– It lists the names and characteristics of every file

contained in that volume– File name can refer to program files, data files, and/or

system files– And if the file manager supports subdirectories, then

they’re listed in the MFD as well.• Early OS supported only a single directory per

volume. ( see the disadvantages of single directory)

Page 13: File Management in General Slides

Volume Configuration - continue• As an analogy

– We have many college accommodation

– Each college we can consider as a volume and given a name and college manager write a college descriptor

– And now we have master students’ directory

– Imagine if we used single directory–It will take a long time to search for students in many of the blocks and levels

–What happened if we have students with same name? Etc….

Page 14: File Management in General Slides

Volume Configuration - continue

• Disadvantages of single directory1. It will take long time to search for an individual file.2. IF the user had many small files stored in the

volume, the directory space would fill up before the disk storage space file up.

3. Users couldn’t create subdirectories to group the files that were related.

4. Multiple users couldn’t safeguard their files from “browsers” because the entire directory was listed on request.

5. Each program in the entire directory needed a unique name, even those directories serving many users.

Page 15: File Management in General Slides

Sub directories

• Most modern system provide subdirectories– File Manager create MFD that contains entries to files

and for subdirectories.– Each users given a subdirectory and they are allowed

to create subdirectories to organize their files

Page 16: File Management in General Slides

About Subdirectories (continued)

Figure 8.2: File directory tree structure

Page 17: File Management in General Slides

File descriptor• Contains information describing the file.• Typically includes

– File name – usually represented in ASCII code– File type – dependent on the system e.q files and

directories– File size– File location – where the file is stored– Date and time of creation/modification– Owner– Protection information – access restrictions based on

who is allowed to access the file and what type of access is allowed.

– Record size – its fixed size or its maximum size, depending on the type of record.

Page 18: File Management in General Slides

File naming convention• Different OS has its own rule of naming convention.

Some of the rule are:-

– Character combination• E.q must start with character and then other

alphanumeric– Number of parts

• MSDOS has two parts, names and extension• UNIX has as many parts as the user need

– Length i.e number of character allows• MSDOS 6 characters• Windows 32 characters significant• Early UNIX 6 characters significant

Page 19: File Management in General Slides

File Naming Conventions

• Absolute filename (complete filename): Long name that includes all path info

• Relative filename: Short name seen in directory listings and selected by user when file is created

• Length of relative name and types of characters allowed is OS dependent

• Extension: Identifies type of file or its contents– e.g., BAT, COB, EXE, TXT, DOC

• Components required for a file’s complete name depend on the operating system

Page 20: File Management in General Slides

File Organization

• Referring to how records are arranged within a files?– Record format– Physical File Organization

• The way records are arranged and the characteristic of the medium used to store it.

Page 21: File Management in General Slides

File Organization: Record Format• All files composed of records that are of two types:

– Fixed-length records: Easiest to access directly• Ideal for data files• Record size critical

– Variable-length records: Difficult to access directly• Don’t leave empty storage space and don’t

truncate any characters• Used in files accessed sequentially (e.g., text

files, program files) or files using index to access records

• File descriptor stores record format

Page 22: File Management in General Slides

File Organization (continued)

Figure 8.4: When data is stored in fixed-length fields (a), data that extends beyond the fixed size is truncated. When data is stored in a variable length record format (b), the size expands to fit the contents, but it takes more time to access.

Page 23: File Management in General Slides

Physical File Organization• The way records are arranged and the characteristics of the

medium used to store them• On magnetic disks, files can be organized as: sequential,

direct, or indexed sequential• Considerations in selecting a file organization scheme:

– Volatility of the data – the frequency with which additions and deletions are made.

– Activity of the file – the percentage of records processed during a given run

– Size of the file– Response time

• time the user is willing to wait before the requested operation is completed.

• crucial when doing searches and retrieving information in an interactive environment.

Page 24: File Management in General Slides

Physical File Organization (continued)• Sequential record organization: Records are stored

and retrieved serially (one after the other)– Easiest to implement – File is searched from its beginning until the requested

record is found– Optimization features may be built into system to

speed search process• Select a key field from the record and sort by the

key – Complicates maintenance algorithms

• Original order must be preserved every time records are added or deleted

Page 25: File Management in General Slides

Physical File Organization (continued)

• Direct record organization: Uses direct access files; can be implemented only on direct access storage devices– Allows accessing of any record in any order without

having to begin search from beginning of file– Records are identified by their relative addresses

(addresses relative to beginning of file) • These logical addresses computed when records

are stored and again when records are retrieved– Use hashing algorithms

Page 26: File Management in General Slides

Physical File Organization (continued)

• Advantages of direct record organization: – Fast access to records– Can be accessed sequentially by starting at first

relative address and incrementing to get to next record– Can be updated more quickly than sequential files– No need to preserve order of the records, so adding or

deleting them takes very little time• Disadvantages of direct record organization:

– Collision in case of similar keys

Page 27: File Management in General Slides

Physical File Organization (continued)

• Indexed sequential record organization: generates index file for record retrieval– Combines best of sequential & direct access– Divides ordered sequential file into blocks of equal

size– Each entry in index file contains highest record key

and physical location of data block – Created and maintained through ISAM software– Advantage: Doesn’t create collisions

Page 28: File Management in General Slides

Physical Storage Allocation

• File Manager must work with files not just as whole units but also as logical units or records

• Records within a file must have the same format but they can vary in length

• Records are subdivided into fields• Record’s structure usually managed by application

programs and not OS• File storage actually refers to record storage

Page 29: File Management in General Slides

Physical Storage Allocation

• Contiguous Storage– Records/information are stored one after the other in

the disk• Noncontiguous Storage

– Records/information of one files are stored in many parts of the disk

Page 30: File Management in General Slides

Contiguous Storage

• Records stored one after another– Advantages:

• Any record can be found once starting address and size are known

• Direct access easy as every part of file is stored in same compact area

– Disadvantages:• Files can’t be expanded easily, and fragmentation

Figure 8.7: Contiguous storage

Page 31: File Management in General Slides

Contiguous Allocation

Block 1

F1/1

Block 2

F1/2

Block 3

F1/3

Block 4

F2/1

Block 5

F2/2

Block 6 Block 7

F3/1

Block 8

F3/2

Block 9

F5/1

Block 10

F5/2

Block 11

F5/3

Block 12

Block 13Block 14Block 15Block 16

Page 32: File Management in General Slides

Noncontiguous Storage

• Allows files to use any available disk storage space• File’s records are stored in a contiguous manner if

enough empty space• Any remaining records, and all other additions to file,

are stored in other sections of disk (extents) – Linked together with pointers– Physical size of each extent is determined by OS

(usually 256 bytes)

Page 33: File Management in General Slides

Noncontiguous Storage (continued)

• File extents are linked in following ways:• Linking at storage level:

– Each extent points to next one in sequence– Directory entry consists of filename, storage location

of first extent, location of last extent, and total number of extents, not counting first

• Linking at directory level: – Each extent listed with its physical address, size,

and pointer to next extent– A null pointer indicates that it's the last one

Page 34: File Management in General Slides

Noncontiguous storage : linking at the storage level

1

F1/1 F1/3 F2/2

F1/2 F2/1

Block 13Block 14Block 15Block 16

10

10 3

3 -

12 4

4 -

File no

Start

End No.extents

1 1 3 2

2 12 4 1

directory2 -

6 - 7 -5 - 8 -

9 - 11 -

Page 35: File Management in General Slides

Noncontiguous storage with linking at the directory level

1

F1/1

Block 2

F1/3 F2/1

Block 5 Block 6 Block 7 Block 8

Block 9

F1/2

Block 11

F2/2

Block 13Block 14Block 15Block 16

10

3

12

4File no

address

Size Next

1/1 1 512 10

2

1/3 3 512 -

2/1 4 512 12

.

1/2 10 512 3

11

2/2 12 512 -

directory

Page 36: File Management in General Slides

Noncontiguous Storage (continued)

Figure 8.9: Noncontiguous file storage with linking taking place at the directory level

Page 37: File Management in General Slides

Noncontiguous Storage (continued)

• Advantage of noncontiguous storage:– Eliminates external storage fragmentation and need

for compactionHowever:– Does not support direct access because no easy

way to determine exact location of specific record

Page 38: File Management in General Slides

Indexed Storage

• Allows direct record access by bringing pointers linking every extent of that file into index block

• Every file has its own index block – Consists of addresses of each disk sector that make

up the file– Lists each entry in the same order in which sectors

are linked• Supports both sequential and direct access• Doesn’t necessarily improve use of storage space• Larger files may have several levels of indexes

Page 39: File Management in General Slides

Indexed Storage (continued)

Figure 8.10: Indexed storage

Page 40: File Management in General Slides

Access Control Verification Module

• To support file sharing among users• Need someway to specify who and what can be done to

particular files• Each file management system has its own method to

control file access• Types:

– Access control matrix– Access control lists– Capability lists– Lockword control

Page 41: File Management in General Slides

Access Control Matrix• Easy to implement• Works well for systems with few files & few users• Results in space wastage because of null entries

Table 8.1: Access Control Matrix

Page 42: File Management in General Slides

Access Control Lists

Table 8.2: Access Control List

• Modification of access control matrix technique• Each file is entered in list & contains names of users who are allowed access to it and type of access permitted

Page 43: File Management in General Slides

Access Control Lists (continued)

• Contains the name of only those users who may use file; those denied any access are grouped under “WORLD”

• List is shortened by putting users into categories: – SYSTEM: personnel with unlimited access to all files– OWNER: Absolute control over all files created in

own account– GROUP: All users belonging to appropriate group

have access– WORLD: All other users in system

Page 44: File Management in General Slides

Capability Lists

• Lists every user and the files to which each has access• Can control access to devices as well as to files

Table 8.3: Capability Lists

Page 45: File Management in General Slides

Which is better?

• Access Control ListFile Access

File 1 USER1 (RWED), USER2 (R-E-), USER4 (RWE-)

USER5 (--E-), WORLD (----)

File 2 USER2 (R-E-), USER3 (R-E-)

File 3

File 4

File Access

User 1 FILE1 (RWED), FILE2 (R-E-), FILE4 (RWE-)

FILE5 (--E-)

User 2 FILE2 (R-E-), FILE3 (R-E-)

User 3

User 4

Capabilities List

Page 46: File Management in General Slides

Lockwords

• Lockword: similar to a password but protects a single file

• Advantages:– Requires smallest amount of storage for file

protection• Disadvantages:

– Can be guessed by hackers or passed on to unauthorized users

– Generally doesn’t control type of access to file• Anyone who knows lockword can read, write,

execute, or delete file