FileStructure
A File Structure should be according to a required format that the operating system can
understand.
 A file has a certain defined structure according to its type.
 A text file is a sequence of characters organized into lines.
 A source file is a sequence of procedures and functions.
 An object file is a sequence of bytes organized into blocks that are understandable by
the machine.
 When operating system defines different file structures, it also contains the code to
support these file structure. Unix, MS-DOS support minimum number of file structure.
Access Methods of File
Files are used to store data. The information present in the file can be accessed by various methods.
Thus, the way of retrieving data from a file is known as access methods. Different systems use
different access methods. The various access methods used are:
 Sequential access
 Direct access
 Indexed access
Sequential access
A sequential access is that in which the records are accessed in some sequence, i.e., the
information in the file is processed in order, one record after the other. This access method is the
most primitive one. Example: Compilers usually access files in this fashion.
Direct/Random access
 Random access file organization provides, accessing the records directly.
 Each record has its own address on the file with by the help of which it can be directly
accessed for reading or writing.
 The records need not be in any sequence within the file and they need not be in
adjacent locations on the storage medium.
Indexed sequential access
 This mechanism is built up on base of sequential access.
 An index is created for each file which contains pointers to various blocks.
 Index is searched sequentially and its pointer is used to access the file directly.
DIRECTORY STRUCTURE
Directory is a symbol table of files that stores all the related information about the file it hold with
the contents. Directory is a list of files. Each entry of a directory define a file information like a
file name, type, its version number, size ,owner of file, access rights, date of creation and date of
last backup.
LOGICAL STRUCTURE OF DIRECTORY
The directories can be structured in the following ways:-
 Single level directory
 Two level directory
 Tree structured directory
 Acyclic graph directory
 General graph directory
l. Single level directory: In a single level directory system, all the files are placed in one directory.
This is very common on single-user OS's. A single-level directory has significant limitations,
however, when the number of files increases or when there is more than one user. Since all
files are in the same directory, they must have unique names.
2. Two level directory: In the two-level directory system, the system maintains a master block
that has one entry for each user. This master block contains the addresses of the directory of the
users. There are still problems with two level directory structure. This structure effectively isolates
one user from another. This is an advantage when the users are completely independent, but a
disadvantage when the users want to cooperate on some task and access files of other users.
3. Tree structured directory: In the tree-structured directory, the directory themselves are files.
This leads to the possibility of having sub-directories that can contain files and sub-subdirectories.
4. Acyclic graph directory: The acyclic directory structure is an extension of the tree-structured
directory structure. In the tree-structured directory, files and directories starting from some fixed
directory are owned by one particular user. In the acyclic structure, this prohibition is taken out
and thus a directory or file under directory can be owned by several users shown in fig 4.
5. General graph directory: The general graph directory is formed by adding links into an
existing tree structure. It overcomes the problem of acyclic graph by allows the cycles in a
directory. Thus it avoids the searching of a component twice in a subdirectory in fig 5.
File Protection
Files often contain information that is highly valuable to their users. One of the major functions of
the file system is to protect this information against unauthorized access and physical damage.
Physical damage may occur because of hardware problems, power failure, head crashes, dirt and
extreme temperatures. In order to prevent such damage some systems performs backup at regular
intervals. Protection is achieved by limiting the type of file access, which can be made.
File Protection through Access Control: Following are the file operations that can be controlled:
 Read: Read a file
 Write: Write the file
 Append: Append a file
 Delete: Delete a file
 List: List the name and attributes of a file
 Rename: Rename a file
 Edit: Changing the contents of a file
 Copy: Make a copy of a file
Access Control List: This list may contain the user name and the types of access allowed for each
user. The operating system checks this access control list (associate with a file) whenever a user
requests an access to a particular file.
Classify the users of a file into three types:
1. Owner: The user who created the file.
2. Group: A set of users who are sharing the file and need similar access.
3. Universe: All remaining users in the system constitute universe.
Problem with access control lists:
 Length of the list
 If every user need to be given read access to a file, we must list all users with read access
 Constructing such a list is tedious
 The directory entry needs to be of variable size, resulting in complicated space
management.
File Protection through Password: Files can be protected by a password. The owner of a file can
control its access by assigning a password. Thus, only those users who know the password, can
access a particular file.
Problem with password protection:
 If each file has a separate password, the number of passwords a user needs to remember
becomes large.
 If all files have same password, then once it is discovered al files are accessible.
 To deal with this problem, some systems allow a user to associate a password with a
subdirectory rather than with a single file.

File structure

  • 1.
    FileStructure A File Structureshould be according to a required format that the operating system can understand.  A file has a certain defined structure according to its type.  A text file is a sequence of characters organized into lines.  A source file is a sequence of procedures and functions.  An object file is a sequence of bytes organized into blocks that are understandable by the machine.  When operating system defines different file structures, it also contains the code to support these file structure. Unix, MS-DOS support minimum number of file structure. Access Methods of File Files are used to store data. The information present in the file can be accessed by various methods. Thus, the way of retrieving data from a file is known as access methods. Different systems use different access methods. The various access methods used are:  Sequential access  Direct access  Indexed access Sequential access A sequential access is that in which the records are accessed in some sequence, i.e., the information in the file is processed in order, one record after the other. This access method is the most primitive one. Example: Compilers usually access files in this fashion. Direct/Random access  Random access file organization provides, accessing the records directly.  Each record has its own address on the file with by the help of which it can be directly accessed for reading or writing.  The records need not be in any sequence within the file and they need not be in adjacent locations on the storage medium. Indexed sequential access  This mechanism is built up on base of sequential access.  An index is created for each file which contains pointers to various blocks.  Index is searched sequentially and its pointer is used to access the file directly. DIRECTORY STRUCTURE Directory is a symbol table of files that stores all the related information about the file it hold with the contents. Directory is a list of files. Each entry of a directory define a file information like a file name, type, its version number, size ,owner of file, access rights, date of creation and date of last backup.
  • 2.
    LOGICAL STRUCTURE OFDIRECTORY The directories can be structured in the following ways:-  Single level directory  Two level directory  Tree structured directory  Acyclic graph directory  General graph directory l. Single level directory: In a single level directory system, all the files are placed in one directory. This is very common on single-user OS's. A single-level directory has significant limitations, however, when the number of files increases or when there is more than one user. Since all files are in the same directory, they must have unique names. 2. Two level directory: In the two-level directory system, the system maintains a master block that has one entry for each user. This master block contains the addresses of the directory of the users. There are still problems with two level directory structure. This structure effectively isolates one user from another. This is an advantage when the users are completely independent, but a disadvantage when the users want to cooperate on some task and access files of other users. 3. Tree structured directory: In the tree-structured directory, the directory themselves are files. This leads to the possibility of having sub-directories that can contain files and sub-subdirectories.
  • 3.
    4. Acyclic graphdirectory: The acyclic directory structure is an extension of the tree-structured directory structure. In the tree-structured directory, files and directories starting from some fixed directory are owned by one particular user. In the acyclic structure, this prohibition is taken out and thus a directory or file under directory can be owned by several users shown in fig 4. 5. General graph directory: The general graph directory is formed by adding links into an existing tree structure. It overcomes the problem of acyclic graph by allows the cycles in a directory. Thus it avoids the searching of a component twice in a subdirectory in fig 5. File Protection Files often contain information that is highly valuable to their users. One of the major functions of the file system is to protect this information against unauthorized access and physical damage. Physical damage may occur because of hardware problems, power failure, head crashes, dirt and extreme temperatures. In order to prevent such damage some systems performs backup at regular intervals. Protection is achieved by limiting the type of file access, which can be made. File Protection through Access Control: Following are the file operations that can be controlled:  Read: Read a file  Write: Write the file  Append: Append a file  Delete: Delete a file  List: List the name and attributes of a file  Rename: Rename a file  Edit: Changing the contents of a file  Copy: Make a copy of a file
  • 4.
    Access Control List:This list may contain the user name and the types of access allowed for each user. The operating system checks this access control list (associate with a file) whenever a user requests an access to a particular file. Classify the users of a file into three types: 1. Owner: The user who created the file. 2. Group: A set of users who are sharing the file and need similar access. 3. Universe: All remaining users in the system constitute universe. Problem with access control lists:  Length of the list  If every user need to be given read access to a file, we must list all users with read access  Constructing such a list is tedious  The directory entry needs to be of variable size, resulting in complicated space management. File Protection through Password: Files can be protected by a password. The owner of a file can control its access by assigning a password. Thus, only those users who know the password, can access a particular file. Problem with password protection:  If each file has a separate password, the number of passwords a user needs to remember becomes large.  If all files have same password, then once it is discovered al files are accessible.  To deal with this problem, some systems allow a user to associate a password with a subdirectory rather than with a single file.