A simplified shared document system similar to Google Docs, implemented in C with support for concurrency and access control.
- ✅ View files with flags (
-a,-l,-al) - ✅ Read file content
- ✅ Create new files
- ✅ Write to files with sentence-level locking
- ✅ Undo last changes
- ✅ Get file metadata and information
- ✅ Delete files
- ✅ Stream content word-by-word
- ✅ List all users
- ✅ Access control (add/remove read/write permissions)
- ✅ Execute file content as shell commands
- ✅ Data persistence across server restarts
- ✅ Access control enforcement
- ✅ Comprehensive logging system
- ✅ Error handling with clear error codes
- ✅ Efficient search using Trie data structure (O(m) complexity)
- ✅ LRU caching for recent file lookups
- Name Server (NM) – Central coordinator managing file metadata and routing
- Storage Servers (SS) – Handle actual file storage and operations
- Clients – User interface for file operations
makeThis will compile three executables:
name_serverstorage_serverclient
./name_serverThe Name Server will start on port 8080.
# Terminal 2
./storage_server 127.0.0.1 9001 10001
# Terminal 3
./storage_server 127.0.0.1 9002 10002# Terminal 4
./clientEnter your username when prompted, then use the available commands.
| Command | Description | Example |
|---|---|---|
VIEW |
List accessible files | VIEW |
VIEW -a |
List all files | VIEW -a |
VIEW -l |
List files with details | VIEW -l |
VIEW -al |
List all files with details | VIEW -al |
READ <filename> |
Read file content | READ test.txt |
CREATE <filename> |
Create new file | CREATE newfile.txt |
WRITE <filename> <sent_idx> |
Write to a specific sentence index | WRITE test.txt 0 |
DELETE <filename> |
Delete file | DELETE oldfile.txt |
INFO <filename> |
Get file information | INFO test.txt |
STREAM <filename> |
Stream file word-by-word | STREAM test.txt |
LIST |
List all users | LIST |
ADDACCESS -R <file> <user> |
Add read access | ADDACCESS -R test.txt user2 |
ADDACCESS -W <file> <user> |
Add write access | ADDACCESS -W test.txt user2 |
REMACCESS <file> <user> |
Remove access | REMACCESS test.txt user2 |
EXEC <filename> |
Execute file as shell script | EXEC script.txt |
UNDO <filename> |
Undo last change | UNDO test.txt |
HELP |
Show help | HELP |
EXIT |
Exit client | EXIT |
Run the automated test suite:
chmod +x test.sh
./test.shThe test script will:
- Compile the project
- Start all necessary servers
- Run 15+ automated tests
- Display results with pass/fail status
- Clean up processes and files
- Trie data structure for O(m) file lookups (m = filename length)
- LRU cache (100-entry capacity) for recent searches
- Hash-based fallback for edge cases
- Multi-threading using
pthreadsfor handling multiple clients - Mutex locks for protecting shared data structures
- Sentence-level locking for concurrent file editing
- Owner always has read/write access
- Read access allows viewing content
- Write access includes read permissions
- Access lists stored in file metadata
- Files stored in
./storage/ - Undo history in
./storage/.undo/ - Metadata maintained by Name Server
| Error Code | Meaning |
|---|---|
ERR_FILE_NOT_FOUND |
File doesn't exist |
ERR_ACCESS_DENIED |
Insufficient permissions |
ERR_FILE_EXISTS |
File already exists |
ERR_SENTENCE_LOCKED |
Sentence being edited by another user |
ERR_INDEX_OUT_OF_RANGE |
Invalid sentence/word index |
ERR_SS_NOT_AVAILABLE |
Storage server unavailable |
Client(s) <--TCP--> Name Server <--TCP--> Storage Server(s)
| |
+--------------- Direct TCP ---------------+
(for READ, WRITE, STREAM ops)
docs_plus_plus/
├── common.h # Shared data structures and constants
├── common.c # Common utility functions
├── name_server.c # Name Server implementation
├── storage_server.c # Storage Server implementation
├── client.c # Client implementation
├── Makefile # Build configuration
├── test.sh # Automated testing script
└── README.md # Project documentation
- Single undo per file (no multi-level undo)
- No folder hierarchy (bonus feature not implemented)
- No fault tolerance or replication (bonus feature)
- Name Server failure means system failure
- Maximum: 100 clients, 10 storage servers
- Hierarchical folder structure
- Multi-level undo with checkpoints
- Fault tolerance with replication
- Request-access mechanism
- Name Server redundancy
Implemented as part of the Operating Systems and Networks (OSN) course project at IIIT Hyderabad.
Educational use only.
make# Terminal 1
./name_server
# Terminal 2
./storage_server 127.0.0.1 9001 10001
# Terminal 3
./storage_server 127.0.0.1 9002 10002
# Terminal 4
./clientchmod +x test.sh
./test.sh