Question: How could you modify 3000test.c so it can report on whether two device files are equal without actually accessing the underlying devices? Specify the changes

How could you modify 3000test.c so it can report on whether two device files are equal without actually accessing the underlying devices? Specify the changes you would make to 3000test.c rather than doing this from scratch.

/* 3000test.c */ /* v1 Oct. 1, 2017 */ /* Licenced under the GPLv3, copyright Anil Somayaji */ /* You really shouldn't be incorporating parts of this in any other code, it is meant for teaching, not production */ #include  #include  #include  #include  #include  #include  #include  #include  #include  void report_error(char *error) { fprintf(stderr, "Error: %s ", error); exit(-1); } int main(int argc, char *argv[]) { struct stat statbuf; char *fn; int fd; size_t len, i, count; char *data; if (argc < 2) { if (argc < 1) { report_error("no command line"); fprintf(stderr, "Usage: %s  ", argv[0]); } else { report_error("Not enough arguments"); fprintf(stderr, "Usage: %s  ", argv[0]); } } fn = argv[1]; if (stat(fn, &statbuf)) { report_error(strerror(errno)); } len = statbuf.st_size; printf("File %s: ", fn); printf(" inode %ld ", statbuf.st_ino); printf(" length %ld ", len); if (S_ISREG(statbuf.st_mode)) { fd = open(fn, O_RDONLY); if (fd == -1) { report_error(strerror(errno)); } data = (char *) mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); if (data == MAP_FAILED) { report_error(strerror(errno)); } count = 0; for (i=0; i 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!