0% found this document useful (0 votes)
19 views28 pages

14 File System Interface 26-06-2023

A file is a named collection of related information recorded on secondary storage. It contains records with fields of data. A file has attributes like its name, size, location, and permissions that determine how it can be accessed. Files can be operated on through functions like create, open, read, write, delete and more. They can be accessed sequentially or randomly via their index or location. Directories organize files in a logical structure and allow efficient searching and naming of files. Common directory structures include single level, two level, tree structures, and acyclic graphs.

Uploaded by

Kanishak Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views28 pages

14 File System Interface 26-06-2023

A file is a named collection of related information recorded on secondary storage. It contains records with fields of data. A file has attributes like its name, size, location, and permissions that determine how it can be accessed. Files can be operated on through functions like create, open, read, write, delete and more. They can be accessed sequentially or randomly via their index or location. Directories organize files in a logical structure and allow efficient searching and naming of files. Common directory structures include single level, two level, tree structures, and acyclic graphs.

Uploaded by

Kanishak Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

File System Interface

Module 6
File Concept - Definition

v A file is a named collection of related information that is


recorded on secondary storage.
v A file is a collection of records where each record contains
some field and where each field represents some data.
v Eg. Student name, Student Reg No., Student Avg Marks.

v A file is a sequence of bits, bytes, lines, or records, the


meaning of which is defined by the file’s creator and user.
File Concept – Content & Types
vContiguous logical address space

vTypes:
vData
vNumeric
vCharacter
vBinary
vProgram
vContents defined by file’s creator

vMany types
vtext file,
vsource file,
vexecutable file
File Concept - Attributes

vName. The symbolic file name is the only information kept in


human- readable form.
vIdentifier. This unique tag, usually a number, identifies the
file within the file system; it is the non-human-readable name
for the file.
vType. This information is needed for systems that support
different types of files.
vLocation. This information is a pointer to a device and to the
location of the file on that device.
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

vSeveral pieces of data are needed to manage open files:


vOpen-file table: tracks open files

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 repositioning() within file or seek()


v The current-file-position pointer of the open file is repositioned to a
given value.
vRepositioning within a file need not involve any actual I/O.
vThis file operation is also known as a file seek.

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 Sequential Access Method


v Information in the file is processed in order, one record after the
other.
vOperations
v read next()—reads the next portion of the file and automatically advances a file
pointer, which tracks the I/O location write next
v write next()—appends to the end of the file and advances to the end of the newly
written material (the new end of file).
v Reset - a file can be reset to the beginning
v editors and compilers
vno read after last write (rewrite)
Ex.
File Concept – Access Methods

v Direct/Relative Access Method


v Allow programs to read and write records rapidly in no particular
order.
v Based on a disk model of a file.
v The file is viewed as a numbered sequence of blocks or records.
v Databases are often of this type
v Operations:
v Read n ( n is block number)
v write n
v seek or position n.
File Concept – Access Methods

v Index based Access Method


v Involve the construction of an index for the file.
v The index, like an index in the back of a book, contains pointers to
the various blocks.
vTo find a record in the file, we first search the index and then use the
pointer to access the file directly and to find the desired record.
File Concept – Access Methods
Disk Structure
v Disk can be subdivided into partitions

v Disks or partitions can be RAID protected against failure

v Disk or partition can be used raw – without a file system, or formatted with a file system

v Partitions also known as minidisks, slices

v Entity containing file system is known as a volume

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 Consider Solaris has

v tmpfs – memory-based volatile FS for fast, temporary I/O

v objfs – interface into kernel memory to get kernel symbols for debugging

v ctfs – contract file system for managing daemons

v lofs – loopback file system allows one FS to be accessed in place of another

v procfs – kernel interface to process structures

v ufs, zfs – general purpose file systems


Directory

v A collection of nodes containing information about all files.


v Both the directory structure and the files reside on disk
Directory - Operations

v Search for a file


v Create a file
v Delete a file
v List a directory
v Rename a file
v Traverse the file system
Directory - Organization

v The directory is organized logically to obtain


v Efficiency – locating a file quickly
v Naming – convenient to users
vTwo users can have same name for different files
v The same file can have several different names

v Grouping – logical grouping of files by properties, (e.g., all Java


programs, all games, …)
Directory – Structure Types – Single Level Directory Structure

v A Single directory for all Users.

v Naming problem
v Grouping problem
Directory – Structure Types – Two Level Directory Structure

vSeparate directory for each user

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

v Have shared subdirectories and files


Directory – Structure Types – Acyclic-Graph Directories

vTwo different names (aliasing)


vIf dict deletes w/list = dangling pointer
v Solutions:
vBackpointers, so we can delete all pointers.
vVariable size records a problem

vBackpointers using a daisy chain organization


vEntry-hold-count solution

vNew directory entry type


vLink – another name (pointer) to an existing file
vResolve the link – follow pointer to locate the file
Directory – Structure Types – General Graph Directory

v How do we guarantee no cycles?


vAllow only links to files not subdirectories
vGarbage collection
vEvery time a new link is added use a cycle detection algorithm to
determine whether it is OK

You might also like