Back
CS 456 Home
Assignment h4: Filetypes, but improved
Due Date: Apr 10 @ 8AM EDT
We're going to take what we've already done in Assignment h3 and improve on it.
I've cleaned up a few things here and there, and moved some stuff over to an
extras.h file. You will make some additional immprovements to this program.
If the file is a regular file, you're going to do the following:
- check if the owner of the file has execute permission then based on
that value do the following:
- if the owner DOES have execute permission try to execute the
program, but if this very program gets passed in, do NOT let it
execute, as fork can be dangerous in the wrong hands.
- otherwise, just open the file and print its contents to stdout
Then in the case where it's something other than a directory or regular file:
- I've started writing a function in extras.h that just prints a
message that indicates what type of file it is, you will finish that
function.
In short, yes, you will be making modifications to both files this time around.
There are programs in the in-class code that will help you out, as well as some
prewritten functions in extras.h that will help you. Check out the forkexec
directory for a program that looks similar to what you will do here. I ask that
you not depend on Generative AI (like ChatGPT, etc) to do this assignment. You
should be able to do this assignment based on the examples given in the book and
in the In-class code.
To pick up this assignment, copy the h4 folder into your cs456 directory by running:
cp -R /home/cs456/h4/ ~/cs456/
OR: hw_get.py cs456 h4
Then use a text editor (like vi, nano, emacs) to open it and make the necessary
edits to accomplish these objectives.
Once finished, leave it in that directory. I will run a script to collect the
files when the due date approaches.