Question: Design and implement a C program to simulate the Unix / Linux file system tree. The program should work as follows. ( a ) .
Design and implement a C program to simulate the UnixLinux file system tree. The
program should work as follows.
a Start with a node, which is also the Current Working Directory CWD
b Prompt the user for a command. Valid commands are:
mkdir, rmdir, cd ls pwd creat, rm save, reload, menu, quit
c Execute the command, with appropriate tracing messages.
d Repeat until the "quit" command, which terminates the program.
The following outlines the suggested organization of the program.
NODE type: Define a C structure for the NODE type containing
chars: name string of the node;
char: node type: D for directory or F for file
node pointers: childPtrsiblingPtrparentPtr;
#include
int main
int a b c;
a ; b ;
c Addab;
Add the remaining code
Global Variables:
NODE rootcwd; root and CWD pointers
char line; user input command line
char command pathname; command and pathname strings
char dname bname;
others as needed
The main function
int main
initialize; initialize root noode of the file system tree
while
get user input line command pathname;
identify the command;
execute the command;
break if command quit;
Get user inputs: Assume that each user input line contains a command with an optional
pathname. The reader may use scanf to read user inputs from stdin. A better technique is as
follows
fgetsline stdin; get at most chars from stdin
linestrlenline; kill
at the end of line
sscanflines s command, pathname;
Identify command:
Ifstrcmpcommandmkdir
mkdirpathname;
else if strcmpcommandrmdir
rmdirpathname;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
