Prerequisite – File Systems
Hierarchical Directory Systems –
Directory is maintained in the form of a tree.Each user can have as many directories as are needed so, that files can be grouped together in natural way.
Advantages of this structure:
- Searching is efficient
- Groping capability of files increase
When the file system is organized as a directory tree, some way is needed for specifying file names.
Two different methods are commonly used:
- Absolute Path name – In this method, each file is given an absolute path name consisting of the path from the root directory to the file. As an example, the path /usr/ast/mailbox means that the root directory contains a subdirectory usr, which in turn contains a subdirectory ast, which contains the file mailbox.
Absolute path names always start at the root directory and are unique.
In UNIX the components of the path are separated by /. In Windows the separator is \.
- Relative Path name – This is used in conjunction with the concept of the working directory (also called the current directory).A user can designate one directory as the current working directory, in which case all path names not beginning at the root directory are taken relative to the working directory.
For example, if the current working directory is /usr/ast, then the file whose absolute path is /usr/ast/mailbox can be referenced simply as mailbox.
In other words, the UNIX
command : cp /usr/ast/mailbox /usr/ast/mailbox.bak
and the command : cp mailbox mailbox.bak
do exactly the same thing if the working directory is /usr/ast.
When to use which approach ?
Some programs need to access a specific file without regard to what the working directory is. In that case, they should always use absolute path names. For example, a spelling checker might need to read /usr/lib/dictionary to do its work. It should use the full, absolute path name in this case because it does not know what the working directory will be when it is called. The absolute path name will always work, no matter what the working directory is.
Of course, if the spelling checker needs a large number of files from /usr/lib, an alternative approach is for it to issue a system call to change its working directory to /usr/lib, and then use just dictionary as the first parameter to open. By explicitly changing the working directory, it knows for sure where it is in the directory tree, so it can then use relative paths.
- Operating System | Free space management
- Operating System | Techniques to handle Thrashing
- Operating System | Secondary memory - Hard disk drive
- Types of computer memory (RAM and ROM)
- Different Types of RAM (Random Access Memory )
- Operating System | Reader-Writers solution using Monitors
- Operating System | Process Table and Process Control Block (PCB)
- Operating System | Unix File System
- Important Linux Commands (leave, diff, cal, ncal, locate and ln)
- File Allocation Methods
- File Systems | Operating System
- What exactly Spooling is all about?
- Disk Scheduling Algorithms
- Static and Dynamic Libraries | Set 1
- Mutex vs Semaphore
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.