Write short notes on:
(i) File sharing
(ii) File directories
Short Notes: File Sharing and File Directories (Operating System)
(i) File Sharing
File sharing in an operating system allows multiple users, processes, or machines to access the same file. It supports collaboration, reduces data duplication, and enables centralized management of information.
Why file sharing is important
- Collaboration: Multiple users can read or update common documents, code, or datasets.
- Resource efficiency: Shared libraries and media avoid redundant copies.
- Centralized control: Admins can manage permissions and backups in one place.
- Networked access: Files can be shared across systems over a LAN or the internet.
Access modes and sharing modes
- Access modes: read, write, append, execute.
- Sharing modes: exclusive (only one writer), shared read (multiple readers), read–write with locks to prevent conflicts.
Permissions and access control
- Permission models: owner/group/others with rwx bits, or more detailed Access Control Lists (ACLs).
- Authentication: users and groups verify identity before access is granted.
- Authorization: the OS checks permissions against the requested operation.
Concurrent access and consistency
- File locking: whole-file locks or byte-range locks to coordinate readers and writers.
- Readers–writers policy: multiple readers allowed; writers get exclusive access.
- Caching and consistency: clients may cache file data; the system must maintain up-to-date views (e.g., close-to-open consistency or version checks).
Network file sharing
- Remote file systems mount shared folders over the network, letting them appear as local directories.
- Protocols provide features like authentication, locking, and recovery from disconnections.
Security and reliability
- Encryption: protect data at rest and in transit.
- Auditing: logs track who accessed or modified files.
- Backups and snapshots: restore shared data after errors or accidental deletion.
Common issues and good practices
- Avoid conflicts: use locks or version control for concurrent edits.
- Least privilege: grant only required permissions.
- Clear naming: use consistent file and folder names for team workflows.
(ii) File Directories
A file directory is a special file that organizes and indexes other files and subdirectories. It provides a hierarchical structure for naming, searching, and managing data in an operating system.
Roles of a directory
- Naming: maps human-friendly names to file metadata (like inodes or file IDs).
- Grouping: organizes related files into folders and subfolders.
- Navigation: supports paths to locate items quickly.
- Protection: stores permissions and ownership info.
Basic directory operations
- Create and delete: make or remove files/folders.
- List: view contents of a directory.
- Search: locate a file by name or attribute.
- Rename and move: change names or relocate items within the tree.
Paths and naming
- Absolute path: starts from the root (e.g., /home/alice/docs/report.pdf).
- Relative path: starts from the current directory (e.g., docs/report.pdf).
- Separators vary by OS (e.g., “/” on UNIX-like systems, “\” on some others).
Directory structures (types)
- Single-level directory: all files in one directory; simple but causes name conflicts.
- Two-level directory: separate directory per user; reduces conflicts, limited sharing.
- Tree-structured directory: hierarchical folders and subfolders; most common and scalable.
- Acyclic graph directory: allows shared subdirectories or files via links without cycles; enables safe sharing.
- General graph directory: links may create cycles; requires special handling (like reference counts) to prevent orphaned files.
Directory contents and metadata
- Each entry typically stores: name, pointer to file metadata, type (file/folder), size, timestamps, and permissions.
- Mount points: a directory can serve as the attachment point for another storage device or filesystem.
Implementation overview
- Entry organization: linear lists (simple), hashed tables (fast lookups), or indexed trees (good for large directories).
- Path resolution: the OS traverses directories component by component to reach the target file.
Example (illustrative directory listing)
drwxr-xr-x alice projects/ -rw-r--r-- alice notes.txt drwxr-x--- alice reports/ -rw------- alice secret.doc
Benefits of a good directory design
- Fast access and organized storage for users and programs.
- Clear separation of data by purpose, project, or user.
- Simpler backup, security policy application, and maintenance.
