Write a program that uses a filename as argument and checks


Problem

1. Write a program that removes the read, write, and execute permissions for others for all files in the current directory that are owned by the user running the program. (Hint: Use getuid to obtain your own UID.)

2. Write a program to create a file foo1 with the same permissions, modification time, and access time as another file, foo2.

3. Write a program that uses a filename as argument and checks each of the 12 permission bits. The program should display a message if the bit is set. For instance, if the user has read permission, then it should display User-readable. Develop the code in a modular manner using two separate functions, A and B:

(i) A will populate a stat structure with the attributes of the file and print its permissions in octal format as a four-character string.

(ii) B will extract each permission bit from stat.st_mode and then print a message like User-readable if the respective bit is set.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that uses a filename as argument and checks
Reference No:- TGS02672073

Expected delivery within 24 Hours