• There are many directory structure schemes to implement the behavior of directories. Some common implementation schemes are as follow:

Single Level Directory Structure

  • This is the simplest directory structure to implement.
  • All files are contained in the same directory.
  • Limitation of single level directory structure is that when number of files increase or when the system has more than one user, it becomes unmanageable.
  • Since all files are in this same directory, the name must be unique.
  • File names are generally selected to reflect the contents of the file, they are often limited in length.
  • Dos allows only 11 character file name and UNIX allows 255 characters.

Single level directory structure

Two Level Directory Structure

  • A single level directory has file names collision between different users.
  • One solution is to create a separate directory for each user.
  • In the 2 level directory structure each user has its own user file directory (UFD).
  • Each UFD has similar structure but list only the files of a single user.
  • When a user job start or user logs in, the system master file directory (MFD) is searched.
  • When a user refers to any specific file only his won UFD is searched.
  • Thus different users will have files with the same name.
  • Although the 2 level directory structure solves the name collision problem but it has still disadvantages.
  • This structure effectively isolated one user from another.
  • This isolation is an advantage when the users are completely independent.
  • But it is a disadvantage when the users want to cooperate on some task and want to excess each other’s files.
  • If excess is to be permitted, one user must have the ability to name a file in another user directory.
  • To name a particular file uniquely in a 2 level directory, we must give both the user name and file name.
  • A 2 level directory can be thought of as a tree and as an inverted tree the height of it is 2.
  • The root of the tree is MFD.
  • Its direct descendants is one of the UFD’s.
  • The descendants of the UFD are the files and files are leaves of the trees.

Two-Level Directory Structure

  • Thus a user name and a file name define a path name.
  • Every file in this system has path name.
  • To name a uniquely user must known the path name of the file desired.
  • System files are part of the system loader, assembler, compilers, utility, routines, libraries and so on. They are generally defined as files.
  • When the appropriate commands are given to the o/s then these files are read and execute.

Tree Structure Directory

  • It allows user to create their own sub-directories and to organize their files accordingly.
  • This is the natural and most common directory structure organization.
  • It has no any fixed height, it can be extended.
  • The Ms Dos system is structured as a tree.
  • The tree has a root directory.
  • Every file in this system has unique path name.
  • A path name is the path from the root through all the sub-directories to a specified file.
  • A directory contains a set of files or sub directories.
  • A directory is simply another file but it is treated in a special way.
  • All directories have the same internal format.
  • One bit in each directory defines the entry as a file (0) or as a sub directory (1).
  • Special system calls are used to create and delete directories.

Tree Level Directory Structure

  • There are two ways to specify a file path:

 Absolute Path

  • In this path we can reach to a specified file from the main or root directory.
  • In this case current directory is not involved; file path is specified starting from the root directory.

 Relative Path

  • The user working in any directory that directory is called current directory.
  • To reach to a specified file we have to search from the current directory.