Due Date: August 6, 2017 23:59 hours
The project developed in Lab
#2 will be extended by this one. Using stat you will need to open each file within a child process and determine the following: the user ID and the group ID and then compare these to the current user. The 3 cases are: if the user is the owner, the user is in the same group as the owner, or if the owner is outside of the user group. After that information is printed, then print the combination of file permissions that apply to this file: read, write, execute. Sample code: man stat, man 2 stat, man getpwuid,
man readdir, and fileaccess.c
Program requirements:
- The program should take either filenames or wildcards (*.c
for example) as input.
- Create as many child processes as there are files on the
command line.
- The parent process should wait for all the children to finish and then print “ps -H”
- For each child process:
- Print if you have owner, group, or general permissions. Hint:
getuid(); & getgid();
- For the appropriate type, print what type
of permissions you have: read, write, execute
- 5% Extra
Credit: instead of Canvas, submit your assignment via https://education.github.com/ (MUST
be private, invite swirsz) I will use Github’s last modified date as the
submission date. Make sure to put your full name in the header of your
file.
(example below)
Last Revised: July 12, 2017
$ gcc Lab3.c -o Lab3 && ./Lab3 .. Lab3.c
File: ..
You have general permissions: read execute
File: Lab3.c
You have owner permissions: read write execute