C语言Linux | Rutgers ECE 434 LINUX OS Processes and Inter Process Communication

本次北美C语言Linux主要是要求学生在Linux上进行各种文件系统的操作,最后是属于操作系统OS的范畴,主要是使用C语言实现进程管理树。
Problem 1 (Introduction) (18 points)
Part 1: File Vanished (3 points):
Let’s assume that you have worked for many days now on a program named myfunc.c. While still working on it, you have accidentally issued some wrong commands or pressed certain combination of keys and you find that your file myfunc.c is lost. By looking into the history of your shell though, you find that the last command issued was: gcc –Wall –o foll.c foo.c Can you explain what has happened
Part 2: Concatenating to files into a third one (12 points):
You are asked to write a program that generates an output file, the context of which is derived by concatenating the contexts of two input files. Your program will be labeled myfiles and will take two or three arguments. The first and second arguments must be the input files, while the third argument must be the output file. The default name for the output file is myfile.out
Note 1 (6 pts): If your program is run without the proper arguments, you must make sure that the proper message appears on screen that guides the user into how many and what sort of arguments are required. If one of the input files provided in the arguments does not exist, then the program must print on screen the corresponding error message.
Note 2 (3 pts): Execute your program using OS instruction strace (research on how this works). Copy the output of strace that is produced from your code.
Note 3 (3 pts): Modify your initial code to support indefinite number of input files. The last argument though is always the output file.
For your implementation you are expected to use the following functions:
—- void WriteInFile (int fd, const char *buff, int len): writes data to file descriptor fd. —- void CopyFile (int fd, const char *file_in): writes the contexts from file named file_in to file descriptor fd. WriteInFile is called from within CopyFile.
Below we provide one example of similar execution:
$ ./myfiles A1
Usage: ./myfiles file_in_1 file_in_2 [file_out (default:myfile.out)]