Homework 2 - Description

Title

Date Posted

Date Due

Sys-yphus

2 / 13 / 18

3 / 2 / 18

The legend of Sisyphus is a tale of "a king being punished for his self-aggrandizing craftiness and deceitfulness by being forced to roll an immense boulder up a hill only for it to roll down when they near the top, repeating this action for eternity."

This assignment is called Sys(call)yphus, because you are damned to repeat the implementations of some common bash commands -- using system calls in C!



Specifications

Because certain bash commands are... well... easier to implement than others, you can shop for which ones you'd like to implement below.

Here are the rules:

  • To receive full credit, you must implement commands worth a total of 8 Forney Points (FP) from the Bash-zaar.

  • There are three rankings of command difficulties: easy (worth 1 FP), medium (2 FP), and hard (3 FP), any one of which may be enhanced by +1 for implementing one of its parameters (e.g., ls gets you 1 FP, but supporting ls -i as well gets you 2).

  • You may implement:

    • A maximum of 2 commands from each category

    • 1 command from each set of similar commands in a category (e.g., choose 1 from {cp, mv}, not both cp and mv)

Here are the commands to choose from:

Difficulty

Forney Points

Commands

Easy

1

*cd, ls, ln, {mkdir, touch}

Medium

2

cat, wc, sort

Hard

3

{cp, mv}, diff**, find (need not parse patterns, full filenames are fine)

* for cd, it should only change the working directory of your process, so to show that it's working, just print the cwd at the end.

** for diff, you may implement a "dumb diff" that does not perform edit-distance, but instead, simply prints out which lines are different in each file.

You may request an appraisal of a command you are interested in implementing that is not listed above, but may not do so without first consulting me.

For each program you write, name it my_<cmd>.c, where <cmd> is the bash command you are re-implementing. For example, if I implemented ls, I would name my program my_ls.c


Implementation Details


Behavior

  • Your implementations should take any expected arguments via the program's command line arguments (i.e., via argc, argv in main).

  • Your implementations should mimic the basic behavior of the commands of your choosing, but need not fully implement it (e.g., need not implement any parameters unless you want to challenge yourself!)

  • If a command takes variant number of arguments (e.g., ls vs. ls <path>), you should implement at least 2 argument formats.


Restrictions / Allowances

Read the following restrictions carefully, multiple times if you must!

  • To standardize implementations, design your programs for Linux systems.

  • You *may* make System Calls using either the general syscall(...) syntax, or the C-specific syntax from the Linux Programmer's Manual, i.e., the versions from clicking on the links from here:
    Linux Syscalls

    For example, as opposed to saying syscall(SYS_getcwd, buffer, size) you may use getcwd(buffer, size).

  • You may *not* use any of the specific syscalls that generate a deprecated warning.

  • If any syscalls return dynamically allocated memory (the documentation will tell you if it does), you *must* free it appropriately.

  • You *may* use normal C libraries to help you parse certain intermediaries, like the convenience functions from string.h.

  • Apropos, if a syscall expects a path, you *must* support both relative and absolute paths (Hint: you may use the realpath function for this purpose)

  • You *may* assume your commands are fed only valid arguments (e.g., no malformed paths), and are allowed to segfault when handed malformed inputs, though you can add validity checking if you please.

  • Although I hope it need not be said, your implementations should not simply be calls to executables of the existing implementations!


Report


At the end of it all, submit a report (PDF or Word doc please) containig:

  • Each implemented command, as well as any argument formats and parameters supported.

  • An example of its usage, with screenshots demonstrating it in practice.



Submission

What

Zip all of your custom bash commands, plus your report, and submit the .zip.


How

We will (unfortunately) be using Brightspace to submit this assignment, though you should always be using version control to organize your assignments (even text)!

To submit your assignment:

  1. Find this assignment listing on Brightspace.

  2. Upload the .zip file containing your submission.

  3. Make sure to click "submit" after the upload is complete!



  PDF / Print