Professional Documents
Culture Documents
Module 6
File Concept - Definition
vTypes:
vData
vNumeric
vCharacter
vBinary
vProgram
vContents defined by file’s creator
vMany types
vtext file,
vsource file,
vexecutable file
File Concept - Attributes
vSize. The current size of the file (in bytes, words, or blocks)
and possibly the maximum allowed size are included in this
attribute.
vProtection. Access-control information determines who can do
reading, writing, executing, and so on.
vTimestamps and user identification . This information may be
kept for creation, last modification, and last use. These data
can be useful for protection, security, and usage monitoring.
File Concept - Operations
v Create()
v Use create() system call.
v When called:
vSpace in the file system must be found and allocated for the file.
v An entry for the new file must be made in a directory.
v Open()
v Use Open() system call
vWhen called
v Checks of the file availability in the directory and if present it is opened.
File Concept - Operations
vFile pointer: pointer to last read/write location, per process that has the file
open
vFile-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
vDisk location of the file: cache of data access information
vAccess rights: per-process access mode information
File Concept - Operations
v close()
v Use close() system call.
v When called:
vCloses the file.
v write()
v Use write() system call
vFirst open the file using open() system call and in write mode.
vkeeps a write pointer to the location in the file where the next write is
to take place if it is sequential. The write pointer must be updated
whenever a write occurs.
File Concept - Operations
v read()
v Open the file in read mode
v use read() system call.
v specifies the file handle and where (in memory)(variable) the next
block of the file should be put.
v The system needs to keep a read pointer to the location in the file
where the next read is to take place, if sequential.
v Once the read has taken place, the read pointer is updated.
v the current operation location can be kept as a per-process current-
file-position pointer.
File Concept - Operations
v Delete()
v Release all file space, so that it can be reused by other files, and
erase or mark as free the directory entry.
v File attributes and contents deleted.
File Concept - Operations
v Truncate()
v File contents will only be deleted, and File attributes and directory
entry remain. Size of the file is zero.
v Append()
v Add contents to end of the file.
v Copy ()
vRename()
File Concept -Types
File Concept – Access Methods
v Disk or partition can be used raw – without a file system, or formatted with a file system
v Each volume containing a file system also tracks that file system’s info in device directory or
volume table of contents
v In addition to general-purpose file systems there are many special-purpose file systems,
frequently all within the same operating system or computer
Disk Structure
Types of File System
v We mostly talk of general-purpose file systems
v But systems frequently have may file systems, some general- and some special- purpose
v objfs – interface into kernel memory to get kernel symbols for debugging
v Naming problem
v Grouping problem
Directory – Structure Types – Two Level Directory Structure
v Path name
vCan have the same file name for different user
vEfficient searching
vNo grouping capability
Directory – Structure Types – Tree-Structured Directories
v
Directory – Structure Types – Acyclic-Graph Directories