Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c language Prog2.c: Modify the template program, lookout.c on p. 56-57 with the following additional capabilities a. Repeat the following steps 100 times x. Wait

image text in transcribed
c language
image text in transcribed
image text in transcribed
Prog2.c: Modify the template program, "lookout.c on p. 56-57 with the following additional capabilities a. Repeat the following steps 100 times x. Wait 1 seconds using "sleep" call xi. Call "stat system call to extract the file attributes against "test.txt" xii. If you find any changes in any of the attributes, 1. Print the information on which attribute is changed. Make sure to print the previous value and the new value (i.e., the changed attribute value). There may exist more than 1 attribute values changed. 56 The file in context /display file information printf(" File is : ", pathname); printf("Size Uld bytesin", statbuf.st Sizel: printf("User-id id, Group-id d ", statbuf.st_uid, statbuf.st.gid); printf("Permissions: Is ", descrip); return (0) The following program lookout is a more useful tool. Given a list of filenames, it checks once a minute to see if any file in the list has changed. It does This by monitoring the modification time of each file (stuntine). It is a utility intended to be run as a background process. lookout - print message when file changes #include include #include #define MFILE 10 void cmp(const char struct stat sb; tine_t); main(int arge, char **argv) int i; time_t last time IMBILE+11; if(argc MFILE) fprintf(stderr, "lookout: too many filenames "); exit (1) 1* initialization / for(j=1; jc-arge; j++) if (stat (argvlj), sb) == -1) fprintf(stderr, "lookout: couldn't stat Isin", argvlj)); exit(); last_tine 13) -sb.st_ntime; Obtaining file information: stat and fstat 57 /* loop until file changes */ for(;;) for (-1; j include #include #define MFILE 10 void cmp(const char struct stat sb; tine_t); main(int arge, char **argv) int i; time_t last time IMBILE+11; if(argc MFILE) fprintf(stderr, "lookout: too many filenames "); exit (1) 1* initialization / for(j=1; jc-arge; j++) if (stat (argvlj), sb) == -1) fprintf(stderr, "lookout: couldn't stat Isin", argvlj)); exit(); last_tine 13) -sb.st_ntime; Obtaining file information: stat and fstat 57 /* loop until file changes */ for(;;) for (-1; j

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions