File concept

Download Report

Transcript File concept

It consists of two parts:
collection of files – stores related data
directory structure – organizes & provides information
Some file systems may have third part:
partitions – used to separate physically & logically large
collection of directories
File protection – multiple users access the file






File Concept
Access Methods
Directory Structure
File-System Mounting
File Sharing
Protection




To explain the function of file systems
To describe the interfaces to file systems
To discuss file-system design tradeoffs, including access methods,
file sharing, file locking, and directory structures
To explore file-system protection







Storage media : magnetic disk, magnetic tapes , optical disks….
Os provides logical view of information storage
It abstracts from the physical properties of its storage devices to
define a logical unit (file)
Files are mapped by os onto physical devices
Storage devices are non volatile – persistent through power failures
File – a named collection of related information that is recorded on
the secondary storage
User s perspective – smallest allotment of logical storage


Contiguous logical address space
Types:
◦ Data files
 numeric
 Character
 alphanumeric
 binary
◦ Program files
◦ Text files (free forms)





Information in the file is defined by its creator
sequence of words, bytes, bits, lines & records (source, object, pay
roll, text, graphics)
Simple record structure
◦ Lines
◦ Fixed length
◦ Variable length
Complex Structures
◦ Formatted document
◦ Relocatable load file
Can simulate last two with first method by inserting appropriate
control characters




Text files – sequence of characters organized into lines
Source files – sequence of subroutines & lines , further organized
into executable statements
Object file – sequence of bytes organized into blocks
understandable by system linker\
Executable file – series of code sections that the loader can bring
into memory & execute








Name – only information kept in human-readable form
Identifier – unique tag (number) identifies file within file 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
Information about files are kept in the directory structure, which is
maintained on the disk











File is an abstract data type
Operations on file:
Create – space in file system & entry for new file
Write – name of the file & information to be written on the file
Read – name of the file & read pointer
Reposition within file – file seek (repositioning within a directory)
Delete – name of the file
Truncate – erasing the contents but keeping the attributes
File table:
Open(Fi) – search the directory structure on disk for entry Fi, and
move the content of entry to memory
Close (Fi) – move the content of entry Fi in memory to directory
structure on disk

Several pieces of data are needed to manage open files:
◦ File pointer: pointer to last read/write location, per process that
has the file open
◦ File-open count: counter of number of times a file is open – to
allow removal of data from open-file table when last processes
closes it
◦ Disk location of the file: cache of data access information
◦ Access rights: per-process access mode information



Provided by some operating systems and file systems
Mediates access to a file
Mandatory or advisory:
◦ Mandatory – access is denied depending on locks held and
requested
◦ Advisory – processes can find status of locks and decide what to
do
Macintosh os- supports a minimal no of file structure
It expects files to contain 2 parts: resource fork – information of interest
to user
data fork – program code or data
Physical record size will exactly match the length of the desired logical record
Logical records may even vary in length
Packing – no .of logical records into physical blocks
Example – unix
files – stream of bytes
file system automatically packs & unpacks bytes into physical disk
blocks – 512 bytes per block
Conversion of physical to logical is a simple sw problem
disk space – always allocated in blocks
some portion of last block – generally wasted
wasted bytes allocated to keep everything in units of blocks is internal
fragmentation
Block size is directly proportional to internal fragmentation