...

Wednesday, February 23, 2011

CAOS 06

Systems can store a lot of files. To cope with these files, disks are first split into partitions.
Partitions can be known as:
-Minidisks - IBM
-Volumes - PC

Each disk contains at least one partition. A file system (such as FAT32/NTFS/EXT4 is overlaid on it).

In partitions, another level of organization is the Device Directory. There are many different implementations of Device Directories which would be discussed later. The Device Directory records information for all files on that partition.

The Directory looks like this in a partition:

(Image courtesy of recommended text)

Like files, there are many operations that can be applied to a Directory. This is a summary:
Search for a file - Match files by a specified pattern
Create a file - Add a file to the directory listings
List a directory - List all files in a directory
Rename a file - Change the name representing a file in a directory
Traverse the file system - Perform a recursive operation, such as for a backup

As mentioned, directories can be implemented in many ways. The simplest way is the Single-Level directory. The advantage is that it is easy to support and understand.

However, when the number of files increases or when the system, has more than one user, these problems arise:
-Files must have unique names, and therefore if two users have the same file, they cannot name it the same
-Files become increasingly difficult to remember and manage

A Single-Level directory looks like this:

(Image taken from Recommended Text)

The Two-Level Directory on the other hand provisions a separate directory for each user. Each user has a UFD (User File Directory) which lists only the files belonging to one user. The UFD is obtained upon logon from the MFD (Master File Directory) which is indexed typically by User Name.

The good thing about a Two-Level Directory structure is that it solves the name collision problem, so all users can have a file named "Assignment5.txt".

However, as each user can only access their UFD, they cannot access the files located in another user's UFD. Depending on how strict a system is, it may totally prohibit cooperation. Access of the other user's files also must be absolute. For example, /user2/folder/file.txt, or C:\user2\folder\file.txt where C is the partition identifier.

Access of system files become a problem. One solution can be to copy all system files to each UFD. However that would be an administrative nightmare and results in inefficient use of space.

Another solution is to include the search paths. Search paths, such as the one implemented by windows using the PATH variable, allows the system to search for a particular file in the PATH variable if it is not found in the current directory. This allows a special directory to be put aside for special purposes such as storing system files.

This is how the Two-Level Directory looks like:

(Taken from Recommended Text)

A directory or subdirectory contains a set of files or subdirectories. A directory is simply a file flagged with the directory bit. A Tree-Structured Directory is similar to the Single- and Two-Level directory in that it has a root, but allows more than 2 levels of directories. This allows the users to create and organize their files accordingly.

The current directory is the directory that the user is currently at. When specifying a file or location, you can either use relative or absolute paths.

A relative path is a path that is relative to the current directory. For example, if you are in /etc/fish/ and you attempt to perform this command "nano toilet.txt", which specifies a relative path, you would be equivalent accessing the absolute:
nano /etc/fish/toilet.txt

Where /etc/fish is the value obtained in the "pwd" command.

In this case, this is equivalent:
nano `pwd`/toilet.txt

On the other hand, to access a file that is not relative to the current directory (e.g. we are currently in /etc/fish/ and we wish to access something in /etc/fish2/), we use an absolute path:
nano /etc/fish2/toilet.txt

If a directory is not empty, it cannot be deleted. To delete the directory, we must either manually delete all files and subdirectories (and all files within the subdirectories) before we can delete the directory.

In UNIX systems, we can use the -r parameter for the "rm" command to do a recursive deletion of a directory and all files/subdirectories in them.

We now come to the Acyclic Graph Directory. Like the Tree-Structured directory is a natural generalization to the Single- and Two-Level directory scheme, the Acyclic Graph Directory is a natural generalization of the Tree-Structured directory scheme.

In an Acyclic Graph Directory, files and folders can be shared. They can exist in multiple places at the same time. This is similar to the symbolic link (symlinks/softlinks/hardlinks) used in Linux. A Link is simply a pointer to another file.

Let's see how the Acyclic Graph looks like:

(Taken from the recommended textbook)

A good use of this is for cooperation. If a group of users wish to work on the same project, they can simply create symbolic links of the folder at other locations (such as in another user's UFD).

To prevent cycles, the OS ignores all Links when doing traversal operations so as not to end up cycling.

There are many ways to delete Links. Deleting a Link is like deleting a shortcut. Deleting the linked file would leave the Links dangling. This is the cheap method.

Upon deletion, the system can search for, and delete all Links. However, unless there exists a maintained list of Links associated with the file, the search can be expensive.

Finally, we can restrict deletion of the file until all references to it are deleted.

No comments :

Post a Comment

<