Skip to content

Visheshs3/network-file-system-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Network File System (DNFS)

This project implements a Distributed Network File System (DNFS) with three main components: a Naming Server, multiple Storage Servers, and Clients. DNFS supports distributed file storage, access control, replication for fault tolerance, and advanced file operations such as streaming and sentence-level editing.


Architecture

  • Naming Server (NM): Central directory and controller. Manages file indexing (hash maps), client authentication, ACLs, storage server heartbeats, and replication logic.
  • Storage Server (SS): Handles file storage and data operations. Manages local file parsing, lazy-loading, and synchronization with the NM.
  • Client: User interface for interacting with the file system. Communicates with the NM for file locations and connects to SS for file operations.

Key Features

  • Distributed File Operations: Create, read, delete, and list files across servers.
  • Sentence-Level Editing: Update specific sentences in a file with WRITE and revert with UNDO.
  • Streaming: Stream file content with controlled delays.
  • Access Control:
    • Ownership and ACL-based permissions (Read/Write).
    • Request-approval workflow for access to non-owned files.
  • Fault Tolerance & Replication:
    • Automatic file replication to backup servers.
    • Primary-backup failover with automatic client redirection.
    • Heartbeat monitoring for server failure detection.
  • Recycle Bin: Soft-delete with garbage collection after a configurable timeout (default 60 seconds).
  • Checkpoints: Create and revert to file snapshots.
  • Remote Execution: Execute shell scripts on storage servers.

Prerequisites

  • GCC (C99 or later)
  • POSIX Threads (pthreads)
  • Linux/Unix environment (uses system calls like mkdir, remove, popen)

Installation

Compile the project using the provided Makefile:

make all

This generates three executables: nameserver_exe, storageserver_exe, and client_exe.


Usage

1. Start the Naming Server

The Naming Server listens for clients on port 8080 and Storage Servers on port 8081.

./nameserver_exe

2. Start Storage Servers

Each Storage Server requires specific arguments:

./storageserver_exe <nm_ip> <nm_port> <advertise_ip> <client_port> <storage_dir> <is_primary>
  • nm_port: Use 8081.
  • is_primary: 1 for primary, 0 for backup.

3. Start the Client

./client_exe

Follow prompts to enter the Naming Server IP and your username.


Client Commands

Command Description
VIEW [-a] [-l] View all files (optionally list all/detailed info)
CREATE <filename> Create a new file
READ <filename> Read file content
WRITE <filename> <sentence_no> Edit or append a sentence
UNDO <filename> Revert the last write
STREAM <filename> Stream file content
DELETE [-F] <filename> Soft delete (use -F for hard delete)
RESTORE <filename> Restore from Recycle Bin
VIEWTRASH List files in Recycle Bin
CHECKPOINT <file> <tag> Create a named snapshot
REVERT <file> <tag> Revert to a checkpoint
REQACCESS <file> <R/W> Request file access
APPROVE <file> <user> Approve access request (Owner only)
EXEC <filename> Execute a shell script on server
exit Disconnect from the system

Configuration

System limits and constants are defined in networking.h:

  • PAYLOAD_SIZE: 4096 bytes
  • MAX_CLIENTS: 100
  • MAX_SS: 10
  • MAX_REPLICAS: 1

License

This project is licensed under the MIT License.

About

A Distributed Network File System (DNFS) in C for the OSN course. Features Naming Servers, Storage Servers and concurrent client handling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors