This homework focuses on system programming and pipe.
Part 1:
- Write, compile, and run a program named hostinfo that prints out system information in the following format. Sample output:
- Write, compile, and run a program named mydate that prints out the day and time in the following format. Sample output:
- Write a program called printdir that prints the current directory. Determine what size buffer to pass to getcwd() for dynamic allocation.(Do not use pwd().) Sample output:
- Write a program called mycat that is a simple version of the program cat. The program takes exactly one file name as argument; you should open it for reading and display its contents to the screen. Check that there is exactly one argument
(argc == 2) and if not, display the usage message Usage: mycat filename. Sample output:
- Write pipe_ls to practice using pipe() and dup(). Have your process start ls (using fork() and exec()) but read the output from ls over a pipe. The ls program writes output on descriptor 1, so some work has to be done to get the pipe connected.
Write what you read on the pipe to stdout.
Sample output:
Part 2:
- Edit the c file to recognize cd, pwd, id, hostname and builtin. Write functions implementing these commands, and compile then into your shell. The builtin command lists the functions built into your shell.
Files provided:
builtin.c, parse.c, shell.c, shell.h Sample output:
- Modify the c file to recognize standard input and redirect_out.c file to recognize standard output. Add code to the pipe_present.c file to check for the pipe symbol. Add code to the pipe_command.c file to create a process to execute each of the pipe. Modify is_background.c to check the & symbol. Alter the run_command.c file to call these functions.
Files provided: redirect_in.c, redirect_out.c, run_command.c, pipe_present.c, pipe_command.c, is_background.c Sample output:
Part 3:
- The first look up project lab familiarizes you with the format of the dictionary by completing the c program that creates the dictionary of fixed-length records (fixrec) from a file of variable-length entries (dict). Add code to convert.c to change an editable file into a fixed-length record format.
File provided:
convert.c, dict.h, dict Sample output:
- Add code to the c file to do a simple linear search through a file of fixed length records. Link with main.c, the user interface module.
File provided: lookup1.c, main.c Sample output:
Reviews
There are no reviews yet.