Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

change mode in c chmod.c xv6 chmod test program: Need help completing the code specified in comments. Output should be shown as: //Types.h typedef unsigned

change mode in c

chmod.c

xv6

chmod test program:

image text in transcribed

Need help completing the code specified in comments.

Output should be shown as:

image text in transcribed

image text in transcribed

//Types.h

typedef unsigned int uint; typedef unsigned short ushort; typedef unsigned char uchar; typedef uint pde_t;

//user.h

struct stat; struct rtcdate;

// system calls int fork(void); int exit(void) __attribute__((noreturn)); int wait(void); int pipe(int*); int write(int, const void*, int); int read(int, void*, int); int close(int); int kill(int); int exec(char*, char**); int open(const char*, int); int mknod(const char*, short, short); int unlink(const char*); int fstat(int fd, struct stat*); int link(const char*, const char*); int mkdir(const char*); int chdir(const char*); int dup(int); int getpid(void); char* sbrk(int); int sleep(int); int uptime(void); int chmod(char*, int); // chmod : (path,mode) int time(void);

// ulib.c int stat(const char*, struct stat*); char* strcpy(char*, const char*); void *memmove(void*, const void*, int); char* strchr(const char*, char c); int strcmp(const char*, const char*); void printf(int, const char*, ...); char* gets(char*, int max); uint strlen(const char*); void* memset(void*, int, uint); void* malloc(uint); void free(void*); int atoi(const char*);

//stat.h

#define T_DIR 1 // Directory #define T_FILE 2 // File #define T_DEV 3 // Device

struct stat { short type; // Type of file int dev; // File system's disk device uint ino; // Inode number short nlink; // Number of links to file uint size; // Size of file in bytes uint mode; //mode of file };

2 I/ chmod program 3 #include "types.h" #include "stat.h" #include 5 -user.h" // Notes: 9 // mode will be implemented as chmod #(6-7) path/ file 10 // 4# read 11 // 2# write 12 // 1#execute 13 // #no permission 14 1/ combinations of these numbers will show multiple permissions (ex. 6read +write) 15 16 int 17 main(int argc, char argvIl) 18 19 20 // 1) get path and mode arguments // 2) check argument count. If error, print correct format and exit. 21 3) execute chmod &display errors if operation fails (ex. format error, path invalid, etc) // Example: // f 23 24 25 26 27 28 ((iError chmod(path, mode))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

WHAT IS AUTOMATION TESTING?

Answered: 1 week ago

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago