300 likes | 433 Views
Device Management. Part 2: File Management. Overview File Manager controls every file in the system. The efficiency of the File Manager depends on how the system’s files are organized, how they are stored, how each file’s records are structured and how access to these files is controlled.
E N D
Device Management Part 2: File Management
Overview • File Manager controls every file in the system. • The efficiency of the File Manager depends on how the system’s files are organized, how they are stored, how each file’s records are structured and how access to these files is controlled. • Responsibilites of File Manager: • Keep track of where each file is stored • Use a policy that will determine where and how the files are stored • Allocate each file when a user has been cleared for access to it and record its use • Deallocate the file when the file is to be returned to storage and communicate its availability to others who may be waiting for it.
Interacting With File Manager • Users communicates with File Manager via specific commands that may be either embedded in user’s program or submitted interactively by user. • Embedded commands: • OPEN & CLOSE pertain to availability of file for program invoking it. • READ & WRITE are I/O commands. • MODIFY – specialized WRITE command for existing data files that allows for appending/rewriting records.
File Operations • Create • Delete • Open • Close • Read • Write
Creation Date Date when volume was created Pointer to Directory Area Indicates first sector where directory is stored Pointer to File Area Indicates first sector where file is stored File System Code Used to detect volumes with incorrect formats Volume News User-allocated name Volume Descriptor
Terms Used with Files • Field • Basic element of data • Contains a single value • Characterized by its length and data type • Record • Collection of related fields • Treated as a unit • Example: employee record • File • Collection of similar records • Treated as a single entity • Have file names • May restrict access
Terms Used with Files (continued) • Database • Collection of related data • Relationships exist among elements
Criteria for File Organization • Short access time • Needed when accessing a single record • Not needed for batch mode • Ease of update • File on CD-ROM will not be updated, so this is not a concern • Economy of storage • Should be minimum redundancy in the data • Redundancy can be used to speed access such as an index • Simple maintenance • Reliability
File Organization : Record Format • When we discuss file organization, we are talking about the arrangement of records within a file because all files are composed of records. • Within each file, the records are presumed to have the same format – they can be fixed length or variable length. • Fixed-length records – easiest to access directly. • Most common type & ideal for data files. • Variable-length records -- difficult to access directly because hard to calculate exactly where record is located.
Physical File Organization • Concerned with how records are arranged & characteristics of medium used to store it. • On magnetic disks, files can be organized as: • Sequential • Direct • Indexed sequential.
Physical File Storage The physical storage model describes what happens on the disks and in the circuits when files are stored Storage media must be formatted before it can store files Formatting utilities divide the disk into tracks and sectors Chapter 4: Operating Systems and File Management 11
Physical File Storage • CDs and DVDs can be created using mastering or packet-writing techniques. • Mastering creates disks that can be used more reliably on a wide variety of computers and stand alone players. • Packet writing is more flexible for disks that you plan to use only on your own computer. Chapter 4: Operating Systems and File Management 12
Physical File Storage Fragmented files are stored in noncontiguous clusters and decrease performance Defragmentation utilities rearrange files so that they are stored in contiguous clusters Chapter 4: Operating Systems and File Management 13
Sequential Record Organization • Easiest to implement because records are stored & retrieved serially, one after other. • To speed process some optimization features may be built into system. • E.g., select a key field from record & then sort records by that field before storing them. • Aids search process. • Complicates maintenance algorithms because original order must be preserved every time records added or deleted.
Direct Record Organization (Random Organization) • Uses direct access files which can be implemented only on direct access storage devices. • Give users flexibility of accessing any record in any order without having to begin search from beginning of file. • Records are identified by their relative addresses (their addresses relative to beginning of file). • Logical addresses computed when records are stored & again when records are retrieved.
Indexed Sequential Record Organization • Combines best of sequential & direct access. • Created & maintained through Indexed Sequential Access Method (ISAM) software package. • Divides ordered sequential file into blocks of equal size. • Size determined by File Manager to take advantage of physical storage devices & to optimize retrieval strategies. • To access any record in file, system begins by searching index file & then goes to physical location indicated at that entry. • Allows both direct access to a few requested records & sequential access to many records for most dynamic files.
Physical Storage Allocation • File Manager must work with files not just as whole units but also as logical units or records. • Records within file must have same format but can vary in length. • Records are subdivided into fields. • Structure usually managed by application programs, not OS. • When we talk about file storage, we’re actually referring to record storage .
Contiguous Storage • Records stored one after other. • Any record can be found & read once starting address & size are known, so directory is very streamlined. • Direct access easy – every part of file is stored in same compact area. • Files can’t be expanded unless there’s empty space available immediately following it. • Room for expansion must be provided when file is created. • Fragmentation occurs (slivers of unused storage space). • Can compact & rearrange files. • Files can’t be accessed while compaction is taking place.
Non-contiguous Storage • Allows files to use any storage space available on disk. • File’s records are stored in a contiguous manner if enough empty space. • Any remaining records, & 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 (e.g., 256 bytes).
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 (addresses of each disk sector that make up the file) • Lists each entry in same order in which sectors linked . • When a file is created, pointers in index block set to null. • As each sector is filled, pointer set to appropriate sector address. • Address is removed from empty space list & copied into its position in index block.
Access Methods • Access methods dictated by a file’s organization • Most flexibility is allowed with indexed sequential files and least with sequential. • File organized in sequential fashion can support only sequential access to its records, and these records can be of fixed or variable length. • File Manager uses the address of last byte read to access the next sequential record. • Current byte address (CBA) must be updated every time a record is accessed.
File Access Control Methods • Each file management system has own file access control method. • Access control matrix • Access control lists • Capability lists • Lockword control. Most Common Methods
Access Control Matrix • Easy to implement. • Works well only for systems with few files & few users. • In matrix each column identifies a user & each row identifies a file. • Intersection of row & column has access rights for that user to that file.
Access Control Lists • Modification of access control matrix technique. • Each file is entered in list & contains names of users allowed to access it & type of access permitted. • To shorten list, only those who may use file are named; those denied any access are grouped under global heading such as WORLD. • Or shorten by putting every user into a category: • SYSTEM – 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; default access types given by File Manager.
Capability Lists • Lists every user and files to which each has access. • Requires less storage space than an access control matrix. • Easier to maintain than an access control list when users are added or deleted from system.
Lockword Control • Lockwordis similar to a password but protects a single file. • When file created, owner protects it via lockword • Stored in directory but isn’t revealed with directory listing. • User must provide correct lockword to access protected file. • Require smallest amount of storage for file protection. • 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.