Q1. Explain directory structure in detail.
ANS. Directory Structure in Operating Systems
A directory structure in an operating system refers to the way in which files are
organized and stored in a hierarchical manner within directories (also called folders).
This structure is crucial for organizing data and managing files effectively. It provides
an efficient way to store, retrieve, and manage files while ensuring that users and
processes can access files without conflicts.
Components of Directory Structure
1. Root Directory:
The root directory is the topmost directory in the hierarchy, represented by a
single slash (/) in Unix-like systems or C:\ in Windows. All other directories
and files branch out from the root.
2. Subdirectories:
Subdirectories are directories that exist within other directories. These can be
nested to any depth, providing a hierarchical structure to organize files.
3. Files:
Files are stored in directories and subdirectories. Files contain data or
instructions for the system, applications, or users. Files are the leaf nodes in a
directory tree (i.e., directories that do not contain other directories).
Types of Directories:
Single-Level Directory
Two-Level Directory
Tree Structure/ Hierarchical Structure
1) Single-Level Directory
The single-level directory is the simplest directory structure. In it, all files are
contained in the same directory which makes it easy to support and understand.
2) Two-Level Directory
As we have seen, a single level directory often leads to confusion of files names
among different users. The solution to this problem is to create a separate directory
for each user.
3) Tree Structure/ Hierarchical Structure
Tree directory structure of operating system is most commonly used in our personal
computers. User can create files and subdirectories too, which was a disadvantage
in the previous directory structures.
Q2. Compare and Contrast between contiguous and linked file
allocation methods in table?
ANS.
Q3. What do you understand by File protection? Explain its
methods.
ANS. File Protection in Operating Systems
File protection refers to mechanisms that ensure the integrity, confidentiality, and
proper access control of files in a computer system. It ensures that files are
safeguarded against unauthorized access, accidental deletion, corruption, or
modification. File protection is crucial for maintaining data security and privacy,
especially in multi-user and multi-tasking environments. The operating system
provides several ways to enforce file protection through various methods.
Methods of File Protection
1. Access Control Lists (ACLs):
o Definition: An Access Control List is a table that defines which users or
groups have permissions for a particular file or directory.
2. File Permissions:
Definition: File permissions are used to specify the operations that
users or groups of users are allowed to perform on files or directories.
3. Password Protection:
Definition: A password is required to access a file, adding a layer of
authentication before granting access to the file.
4. Encryption:
Definition: Encryption involves converting the content of a file into a
coded format that can only be read with a specific decryption key or
password.
5. Backup and Redundancy:
Definition: Files are regularly backed up to ensure that even if they
are accidentally deleted or corrupted, they can be restored from
backup copies.
6. File Integrity Checks:
Definition: Ensuring that the contents of a file are not altered without
authorization, usually by verifying its hash value (checksum).
Q4. Illustrate Layered design of file system with diagram.
ANS.
Application Programs: This is the topmost
layer where users interact with files through
applications. It provides the user interface for
file operations like creating, deleting, reading,
writing, and modifying files. Examples include
text editors, file browsers, and command-line
interfaces.
Logical File system – It manages metadata
information about a file i.e includes all details
about a file except the actual contents of the
file. It also maintains via file control
blocks. File control block (FCB) has
information about a file – owner, size,
permissions, and location of file contents.
File Organization Module – It has
information about files, the location of files
and their logical and physical blocks. Physical
blocks do not match with logical numbers of
logical blocks numbered from 0 to N. It also
has a free space that tracks unallocated blocks.
Basic File system – It Issues general commands to the device driver to read
and write physical blocks on disk. It manages the memory buffers and caches.
A block in the buffer can hold the contents of the disk block and the cache
stores frequently used file system metadata.
I/O Control level – Device drivers act as an interface between devices and
OS, they help to transfer data between disk and main memory. It takes block
number as input and as output, it gives low-level hardware-specific instruction.
Devices Layer: The bottommost layer, consisting of the actual hardware
devices. It performs the actual reading and writing of data to the physical
storage medium. This includes hard drives, SSDs, optical disks, and other
storage devices.
Q5. What are File Permisions? What are the two ways to change file
permission. Explain with example.
ANS. File Permissions in Operating Systems
File permissions define who can access a file and what operations they can
perform on it. In multi-user systems, managing file permissions ensures the security
and proper use of files and directories. File permissions allow users to control access
to their files, restricting who can read, write, or execute them.
There are generally three types of file permissions:
1. Read (r): Allows a user to view the contents of a file.
2. Write (w): Allows a user to modify the contents of a file.
3. Execute (x): Allows a user to execute the file as a program or script (for
executable files).
Two Ways to Change File Permissions
There are two common ways to change file permissions:
1. Using the chmod Command (Symbolic Method):
o The chmod command allows users to change file permissions using
symbolic notation (e.g., r, w, x).
o Syntax: chmod [who][operation][permissions] filename
who: Specifies which user to apply the change to (owner, group,
others).
operation: Defines what to do with the permissions (+ for
adding, - for removing, = for setting exactly).
permissions: The permissions to modify (e.g., r, w, x).
2. Using Numeric Notation (Octal Method):
This method uses numbers to set file permissions. Each permission (read,
write, execute) is represented by a number (r=4, w=2, x=1), and these
numbers are added up to set the desired permission for owner, group, and
others.
Syntax: chmod [numeric permission] filename