Assignment 2: chicken, a file archiver

version: 1.2 last updated: 2021-11-1216:00:00

Contents

Aims

The Task

A file archive is a single file which can contain the contents, names and other metadata of multiple files. These can make backup and transport of files more convenient, and can often make compression more efficient. We often refer to tools that can create or manipulate these as file archivers.

There are a vast number of archive formats: on *nix-like systems, tar(5) is common; whereas on Windows, Zip is common. Wikipedia's list of archive formats is a marvellous rabbit-hole to explore.

In this assignment, you will be implementing chicken, a file archiver for the egg format.

The egg format is made up of one or more egglets; where an egglet records one file system object; This format is described in more detail below.

A complete implementation of chicken can

Getting Started

Create a new directory for this assignment, change to this directory, and fetch the provided code by running

mkdir -m 700 chicken
cd chicken
1521 fetch chicken

If you're not working at CSE, you can download the provided files as a zip file or a tar file.

This will give you the following files:

chicken.c
is the only file you need to change: it contains partial definitions of four functions, list_egg, check_egg, extract_egg, and create_egg, to which you need to add code to complete the assignment. You can also add your own functions to this file.
chicken_main.c
contains a main, which has code to parse the command line arguments, and which then calls one of list_egg, extract_egg, create_egg, or check_egg, depending on the command line arguments given to chicken. Do not change this file.
chicken.h
contains shared function declarations and some useful constant definitions. Do not change this file.
chicken_hash.c
contains the egglet_hash function; you should call this function to calculate hashes for subset 1. Do not change this file.
chicken_6_bit.c
contains the egglet_to_6_bit and egglet_from_6_bit functions. You should call these to implement the 6-bit format for subset 3. Do not change this file.
chicken.mk
contains a Makefile fragment for chicken.

You can run make(1) to compile the provided code; and you should be able to run the result.

make
dcc    -c -o chicken.o chicken.c
dcc    -c -o chicken_main.o chicken_main.c
dcc    -c -o chicken_hash.o chicken_hash.c
dcc    -c -o chicken_6_bit.o chicken_6_bit.c
dcc   chicken.o chicken_main.o chicken_hash.o chicken_6_bit.o   -o chicken
./chicken -l a.egg
list_egg called to list egg: 'a.egg'

If you are running make(1) without dcc available you can compile like this:

make CC=gcc
gcc    -c -o chicken.o chicken.c
gcc    -c -o chicken_main.o chicken_main.c
gcc    -c -o chicken_hash.o chicken_hash.c
gcc    -c -o chicken_6_bit.o chicken_6_bit.c
gcc   chicken.o chicken_main.o chicken_hash.o chicken_6_bit.o   -o chicken
./chicken -l a.egg
list_egg called to list egg: 'a.egg'

If you don't have make(1) available you can compile like this:

dcc chicken.c chicken_main.c chicken_hash.c chicken_6_bit.c -o chicken
./chicken -C b.egg
check_egg called to check egg: 'a.egg'

If you don't have make(1) or dcc available you can compile like this:

gcc -Wall chicken.c chicken_main.c chicken_hash.c chicken_6_bit.c -o chicken
./chicken -C b.egg
check_egg called to check egg: 'a.egg'

You may optionally create extra .c or .h files.

You should run unzip(1) to get a directory called examples/ full of .egg files to test your program against.

unzip examples.zip

Subset 0

To complete subset 0, you need to implement code that can

Subset 0: Print a list of the contents of an egg

Given the -l command-line argument, chicken should print the path names of the files/directories in an egg.

For example:

List each item in the egg called text_file.egg, which is in the examples directory
./chicken -l examples/text_file.egg
hello.txt
List each item in the egg called 4_files.egg, which is in the examples directory
./chicken -l examples/4_files.egg
256.bin
hello.txt
last_goodbye.txt
these_days.txt
List each item in the egg called hello_world.egg, which is in the examples directory
./chicken -l examples/hello_world.egg
hello.c
hello.cpp
hello.d
hello.go
hello.hs
hello.java
hello.js
hello.pl
hello.py
hello.rs
hello.s
hello.sh
hello.sql

Subset 0: Print a detailed list of the contents of an egg

Given the -L command-line argument, chicken should, for each file in the specified egg, print:

  1. the file/directory permissions,
  2. the egglet format which will be one of 6, 7 or 8 (the default),
  3. the file/directory size in bytes, and
  4. the file/directory path name.
./chicken -L examples/text_file.egg
-rw-r--r--  8     56  hello.txt
List the details of each item in the egg called 4_files.egg, which is in the examples directory
./chicken -L examples/4_files.egg
-rw-r--r--  8    256  256.bin
-rw-r--r--  8     56  hello.txt
-r--r--r--  8    166  last_goodbye.txt
-r--rw-r--  8    148  these_days.txt
List the details of each item in the egg called hello_world.egg, which is in the examples directory
./chicken -L examples/hello_world.egg
-rw-r--r--  8     93  hello.c
-rw-r--r--  8     82  hello.cpp
-rw-r--r--  8     65  hello.d
-rw-r--r--  8     77  hello.go
-rw-r--r--  8     32  hello.hs
-rw-r--r--  8    117  hello.java
-rw-r--r--  8     30  hello.js
-rwxr-xr-x  8     47  hello.pl
-rwxr-xr-x  8    103  hello.py
-rw-r--r--  8     45  hello.rs
-rw-r--r--  8    123  hello.s
-rwxr-xr-x  8     41  hello.sh
-rw-r--r--  8     24  hello.sql

Subset 1

To complete subset 1, you need to implement code that can

Subset 1: Check the contents of an egg

Given the -C command-line argument, chicken should check the hashes in the specified egg. For example:

Check the egg called 4_files.egg, which is in the examples directory
./chicken -C examples/4_files.egg
256.bin - correct hash
hello.txt - correct hash
last_goodbye.txt - correct hash
these_days.txt - correct hash
Check the egg called examples/hello_world.bad_hash.egg, which is in the examples directory
./chicken -C examples/hello_world.bad_hash.egg
hello.c - correct hash
hello.cpp - correct hash
hello.d - correct hash
hello.go - correct hash
hello.hs - correct hash
hello.java - correct hash
hello.js - correct hash
hello.pl - correct hash
hello.py - correct hash
hello.rs - correct hash
hello.s - correct hash
hello.sh - correct hash
hello.sql - incorrect hash 0x19 should be 0x43

It should also check the egglet magic number (first byte) of each egglet, and emit an error if it is incorrect.

Check the egg called text_file.bad_magic.egg, which is in the examples directory
./chicken -C examples/text_file.bad_magic.egg
error: incorrect first egglet byte: 0x39 should be 0x63

Subset 1: Extract files from an egg

Given the -x command-line argument, chicken should extract the files in the specified egg.

It should set file permissions for extracted files to the permissions specified in the egg.

chicken will extract files into the current working directory.
So as not to clutter your assignment directory, you should create a
temporary directory, 'tmp', and change to it.  Once in that directory,
both your chicken program and 'examples/' will be in its parent
directory --- hence the use of '..' in these path names.

Make a directory called tmp.
mkdir -p tmp/
Change into the tmp directory.
cd tmp/
Forcibly remove all files inside the tmp directory.
rm -f * .*
Use your program to extract the contents of text_file.egg.
../chicken -x ../examples/text_file.egg
Extracting: hello.txt
Show the contents of hello.txt in the terminal.
You can manually open it in your text editor too, if you like.
cat hello.txt
Hello COMP1521
I hope you are enjoying this assignment.
Forcibly remove all files inside the tmp directory.
rm -f * .*
Use your program to extract the contents of hello_world.egg.
../chicken -x ../examples/hello_world.egg
Extracting: hello.c
Extracting: hello.cpp
Extracting: hello.d
Extracting: hello.go
Extracting: hello.hs
Extracting: hello.java
Extracting: hello.js
Extracting: hello.pl
Extracting: hello.py
Extracting: hello.rs
Extracting: hello.s
Extracting: hello.sh
Extracting: hello.sql
Show the first 25 lines from the extracted files to confirm the extraction was successful.
cat $(echo * | sort) | head -n 25
extern int puts(const char *s);

int main(void)
{
    puts("Hello, World!");
    return 0;
}
#include <iostream>

int main () {
  std::cout << "Hello, world!" << std::endl;
}
import std.stdio;

void main() {
    writeln("Hello, world!");
}
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
main = putStrLn "Hello, World!"
Forcibly remove all files inside the tmp directory
rm -f * .*
Use your program to extract the contents of meta.egg.
../chicken -x ../examples/meta.egg
Extracting: 1_file.subdirectory.7-bit.egg
Extracting: 1_file.subdirectory.egg
Extracting: 2_files.7-bit.egg
Extracting: 2_files.egg
Extracting: 3_files.7-bit.egg
Extracting: 3_files.bad_hash.egg
Extracting: 3_files.bad_magic.egg
Extracting: 3_files.egg
Extracting: 3_files.subdirectory.7-bit.egg
Extracting: 3_files.subdirectory.bad_hash.egg
Extracting: 3_files.subdirectory.bad_magic.egg
Extracting: 3_files.subdirectory.egg
Extracting: 4_files.egg
Extracting: all_the_modes.subdirectory.7-bit.egg
Extracting: all_the_modes.subdirectory.egg
Extracting: all_three_formats.6-bit.egg
Extracting: binary_file.egg
Extracting: hello_world.7-bit.egg
Extracting: hello_world.bad_hash.egg
Extracting: hello_world.bad_magic.egg
Extracting: hello_world.egg
Extracting: lecture_code.subdirectory.7-bit.egg
Extracting: lecture_code.subdirectory.egg
Extracting: small.6-bit.egg
Extracting: small.7-bit.egg
Extracting: small.egg
Extracting: text_file.7-bit.egg
Extracting: text_file.bad_hash.egg
Extracting: text_file.bad_magic.egg
Extracting: text_file.egg
Extracting: tiny.6-bit.egg
Extracting: tiny.7-bit.egg
Extracting: tiny.egg
Show the first 10 items in this directory alphabetically to check extraction was successful.
ls -1 $(echo * | sort) | head
1_file.subdirectory.egg
1_file.subdirectory.compressed.egg
2_files.egg
2_files.compressed.egg
3_files.bad_hash.egg
3_files.bad_magic.egg
3_files.egg
3_files.compressed.egg
3_files.subdirectory.bad_hash.egg
3_files.subdirectory.bad_magic.egg
Go back into the directory with your code.
cd ../
Remove the tmp directory and everything inside it.
rm -rf tmp/

Subset 2

To complete subset 2, you need to implement code that can

Subset 2: Create an egg from a list of files

Given the -c command-line argument, chicken should create an egg containing the specified files.

These "echo" lines show you how to create these test files and what their contents are.

Create a file called hello.txt with the contents "hello".
echo hello >hello.txt
Create a file called hola.txt with the contents "hola".
echo hola >hola.txt
Create a file called hi.txt with the contents "hi".
echo hi >hi.txt
Set the permissions of these files to 644 (octal permission string (equivalent to rw-r--r--)).
When you list the contents of the egg, the permissions should match this.
chmod 644 hello.txt hola.txt hi.txt
Create a egg called selamat.egg with the files hello.txt, hola.txt, and hi.txt.
./chicken -c selamat.egg hello.txt hola.txt hi.txt
Adding: hello.txt
Adding: hola.txt
Adding: hi.txt
List the contents of selamat.egg.
./chicken -L selamat.egg
-rw-r--r--  8      6  hello.txt
-rw-r--r--  8      5  hola.txt
-rw-r--r--  8      3  hi.txt
Make a directory called tmp.
mkdir -p tmp/
Change into the tmp directory.
cd tmp/
Forcibly remove all files inside the tmp directory.
rm -f * .*
Use your program to extract the contents of selamat.egg.
../chicken -x ../selamat.egg
Extracting: hello.txt
Extracting: hola.txt
Extracting: hi.txt
Check that the extracted file hello.txt is the same as the source file ../hello.txt.
diff -s ../hello.txt hello.txt
Files ../hello.txt and hello.txt are identical
Check that the extracted file hola.txt is the same as the source file ../hola.txt.
diff -s ../hola.txt hola.txt
Files ../hola.txt and hola.txt are identical
Check that the extracted file hi.txt is the same as the source file ../hi.txt.
diff -s ../hi.txt hi.txt
Files ../hi.txt and hi.txt are identical
Go back into the directory with your code.
cd ../
Remove the tmp directory and everything inside it.
rm -rf tmp/

It is also possible to append egglets to an existing egg file using the -a command-line option. For example:

./chicken -a bonjour.egg hello.txt
Adding: hello.txt
./chicken -L bonjour.egg
-rw-r--r--  8      6  hello.txt
./chicken -a bonjour.egg hola.txt hi.txt
Adding: hola.txt
Adding: hi.txt
./chicken -L bonjour.egg
-rw-r--r--  8      6  hello.txt
-rw-r--r--  8      5  hola.txt
-rw-r--r--  8      3  hi.txt

Subset 3

To complete subset 3, you need to implement code that can

Subset 3: Create an egg from a list of files and directories

Given the -c command-line argument, chicken should be able to add files in sub-directories. For example:

Create a egg called a.egg with the file "hello.txt" that is contained within 2 levels of directories.
./chicken -c a.egg examples/2_files.d/hello.txt 
Adding: examples
Adding: examples/2_files.d
Adding: examples/2_files.d/hello.txt

If a directory is specified when creating an egg, chicken should add the entire directory tree to the egg.

Create an egg called a.egg with *all* the contents within the directory "3_files.subdirectory.d"
which is in the "examples" directory.
./chicken -c a.egg examples/3_files.subdirectory.d
Adding: examples
Adding: examples/3_files.subdirectory.d
Adding: examples/3_files.subdirectory.d/goodbye
Adding: examples/3_files.subdirectory.d/goodbye/last_goodbye.txt
Adding: examples/3_files.subdirectory.d/hello
Adding: examples/3_files.subdirectory.d/hello/hello.txt
Adding: examples/3_files.subdirectory.d/these_days.txt

Given the -L command-line argument and an egg containing directories, chicken should be able to list files and directories. For example:

./chicken -L examples/1_file.subdirectory.egg 
drwxr-xr-x  8      0  hello
-rw-r--r--  8     56  hello/hello.txt

Subset 3: Extract directories from an egg

Given the -x command-line argument, and an egg containing directories, chicken should be able to extract files and directories. For example:

./chicken -x examples/3_files.subdirectory.egg 
Creating directory: goodbye
Extracting: goodbye/last_goodbye.txt
Creating directory: hello
Extracting: hello/hello.txt
Extracting: these_days.txt

Subset 3: Manipulate 6-bit and 7-bit storage formats

The -7 and -6 options allow egglets to be created in 7-bit and 6-bit format. For example:

./chicken -7 -c seven.egg hello.txt
Adding: hello.txt
./chicken -L seven.egg
-rw-r--r--  7      6  hello.txt
./chicken -6 -c six.egg hola.txt hi.txt
Adding: hola.txt
Adding: hi.txt
./chicken -L six.egg
-rw-r--r--  6      5  hola.txt
-rw-r--r--  6      3  hi.txt

It is possible for eggs to contain egglets in multiple formats. For example:

./chicken -a mixed.egg hello.txt
Adding: hello.txt
./chicken -L mixed.egg
-rw-r--r--  8      6  hello.txt
./chicken -7 -a mixed.egg hi.txt
Adding: hi.txt
./chicken -L mixed.egg
-rw-r--r--  8      6  hello.txt
-rw-r--r--  7      3  hi.txt
./chicken -6 -a mixed.egg hola.txt
Adding: hola.txt
./chicken -L mixed.egg
-rw-r--r--  8      6  hello.txt
-rw-r--r--  7      3  hi.txt
-rw-r--r--  6      5  hola.txt

Your code should handle creating, listing, checking, and extracting eggs in 7-bit and 6-bit format.

Your code should produce an error if asked to create an egglet containing bytes which can be encoded in the specified format. For example:

 echo Hello >Hello.txt
./chicken -6 -c broken.egg Hello.txt
error: byte 0x48 can not be represented in 6-bit format

Handling Errors

Error checking is an important part of this assignment. Automarking will test error handling.

Error messages should be one line (only) and be written to stderr (not stdout).

chicken should exit with status 1 after an error.

chicken should check all file operations for errors.

As much as possible match the reference implementation error messages exactly.

The reference implementation uses perror(3) to report errors from file operations and other system calls.

It is not necessary to remove files and directories already created or partially created when an error occurs.

You may extract a file or directory from egglet before determining if the egglet hash is correct.

You may not extract the file or directory from an egglet before determining if the egglet magic number is correct.

You can extract previous file or directory from an egglet.

Where multiple errors messages could be produced, for example, if two non-existent files are specified to be added to an egg, chicken may produce any one of the error messages.

Reference implementation

A reference implementation is a common, efficient, and effective method to provide or define an operational specification; and it's something you will likely work with after you leave UNSW.

We've provided a reference implementation, 1521 chicken, which you can use to find the correct outputs and behaviours for any input:

1521 chicken -L examples/tiny.6-bit.egg
-rw-r--r--  6      0  a

Every concrete example shown below is runnable using the reference implementation; run 1521 chicken instead of ./chicken.

Where any aspect of this assignment is undefined in this specification, you should match the behaviour exhibited by the reference implementation. Discovering and matching the reference implementation's behaviour is deliberately a part of this assignment.

If you discover what you believe to be a bug in the reference implementation, please report it in the class forum. If it is a bug, we may fix the bug; or otherwise indicate that you do not need to match the reference implementation's behaviour in that specific case.

The egg and egglet format

eggs must follow exactly the format produced by the reference implementation.

An egg consists of a sequence of one or more egglets. Each egglet contains the information about one file or directory.

The first byte of an egg file is the first byte of the first egglet. That egglet is immediately followed by either another egglet, or by the end of the egg file.

name length type description
magic number B unsigned, 8-bit, little-endian byte 0 in every egglet must be 0x63 (ASCII 'c')
egglet format B unsigned, 8-bit, little-endian byte 1 in every egglet must be one of 0x36, 0x37, 0x38 (ASCII '6', '7', '8')
permissions 10 B characters bytes 2—11 are the type and permissions as a ls(1)-like character array; e.g., "-rwxr-xr-x"
pathname length B unsigned, 16-bit, little-endian bytes 12—13 are an unsigned 2-byte (16-bit) little-endian integer, giving the length of
pathname pathname-length characters the filename of the object in this egglet.
content length B unsigned, 48-bit, little-endian the next bytes are an unsigned 6-byte (48-bit) little-endian integer giving the length of the file that was encoded to give
content content-length for 8-bit format, see below for other formats bytes the data of the object in this egglet.
hash B unsigned, 8-bit, little-endian the last byte of an egglet is an egglet-hash of all bytes of this egglet except this byte.

egglet content encodings (Subset 3 only)

6-bit format is used only in subset 3.

Packed n-bit encoding (Subset 3 only)

We often store smaller values inside larger types. For example, the integer 42 only needs six bits; but we often will store it in a full thirty-two-bit integer, wasting many bits of zeroes. Assuming we know how many bits the value needs, we could only store the relevant bits.

For example, let's say we have three seven-bit values a, b, c, made up of arbitrary bit-strings, and stored in eight-bit variables

then a packed seven-bit encoding of these values in order would be:
    0bAAAA_AAAB_BBBB_BBCC_CCCC_C???

However, we have a problem: what happens to the trailing bits, which don't have a value? Note that we've defined all trailing bits to be zero above, which would here give:

    0bAAAA_AAAB_BBBB_BBCC_CCCC_C000

Inspecting eggs and egglets

The hexdump(1) utility can show the individual bytes of a file. We can use this to inspect eggs and egglets.

For example, here is an egg, made up of two egglets.

hexdump -vC greetings.egg
00000000  63 38 2d 72 77 2d 72 2d  2d 72 2d 2d 0c 00 68 65  |c8-rw-r--r--..he|
00000010  6c 6c 6f 2e 30 2e 74 78  74 00 11 00 00 00 00 00  |llo.0.txt.......|
00000020  68 65 6c 6c 6f 2c 20 43  4f 4d 50 31 35 32 31 21  |hello, COMP1521!|
00000030  0a 1a 63 38 2d 72 77 2d  72 2d 2d 72 2d 2d 0c 00  |..c8-rw-r--r--..|
00000040  68 65 6c 6c 6f 2e 31 2e  74 78 74 00 29 00 00 00  |hello.1.txt.)...|
00000050  00 00 77 65 20 68 6f 70  65 20 79 6f 75 27 72 65  |..we hope you're|
00000060  20 65 6e 6a 6f 79 69 6e  67 20 74 68 69 73 20 61  | enjoying this a|
00000070  73 73 69 67 6e 6d 65 6e  74 2e 0a a5              |ssignment...|
0000007c

Each line of hexdump(1) output is in three groups:

You could also use the hd(1), od(1), or xxd(1) utilities.

6-bit format (Subset 3 only)

egglet 6-bit format defines a subset of 64 8-bit values (bytes) to have a six-bit encoding; those six bits are then stored packed.

The remaining 192 8-bit values can not be encoded in 6-bit format.

The functions egglet_to_6_bit and egglet_from_6_bit in chicken_6_bit.c to convert 8-bit values to and from 6-bit format.

You can find the mapping by reading the code in chicken_6_bit.c.

The egglet hash (Subsets 1, 2, 3)

Each egglet ends with a hash (sometimes referred to as a digest) which calculated from the other values of the egglet. This allows us to detect if any bytes of the egg have changed, for example by disk or network errors.

The egglet_hash() function makes one step of computation of the hash of a sequence of bytes:

uint8_t egglet_hash(uint8_t current_hash_value, uint8_t byte_value) {
    return ((current_hash_value * 33) & 0xff) ^ byte_value;
}

Given the hash value of the sequence up to this byte, and the value of this byte it calculates the new hash value.

If we create an egg of a single one-byte file, like this:

echo >a
1521 chicken -c a.egg a

We can then inspect the egg, and see its hash is 0x15.

hexdump -Cv a.egg
00000000  63 38 2d 72 77 2d 72 2d  2d 72 2d 2d 01 00 61 01  |c8-rw-r--r--..a.|
00000010  00 00 00 00 00 0a 15                              |.......|
00000017

Here's the sequence of calls that calculated that value:

egglet_hash(0x00, 0x63) = 0x63
egglet_hash(0x63, 0x38) = 0xfb
egglet_hash(0xfb, 0x2d) = 0x76
egglet_hash(0x76, 0x72) = 0x44
egglet_hash(0x44, 0x77) = 0xb3
egglet_hash(0xb3, 0x2d) = 0x3e
egglet_hash(0x3e, 0x72) = 0x8c
egglet_hash(0x8c, 0x2d) = 0x21
egglet_hash(0x21, 0x2d) = 0x6c
egglet_hash(0x6c, 0x72) = 0x9e
egglet_hash(0x9e, 0x2d) = 0x73
egglet_hash(0x73, 0x2d) = 0xfe
egglet_hash(0xfe, 0x01) = 0xbf
egglet_hash(0xbf, 0x00) = 0x9f
egglet_hash(0x9f, 0x61) = 0x1e
egglet_hash(0x1e, 0x01) = 0xdf
egglet_hash(0xdf, 0x00) = 0xbf
egglet_hash(0xbf, 0x00) = 0x9f
egglet_hash(0x9f, 0x00) = 0x7f
egglet_hash(0x7f, 0x00) = 0x5f
egglet_hash(0x5f, 0x00) = 0x3f
egglet_hash(0x3f, 0x0a) = 0x15

Assumptions and Clarifications

Like all good programmers, you should make as few assumptions as possible. If in doubt, match the output of the reference implementation.

If you need clarification on what you can and cannot use or do for this assignment, ask in the class forum.

You are required to submit intermediate versions of your assignment. See below for details.

Assessment

Testing

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest chicken chicken.c [any other .c or .h files]

To run tests specific to a subset, you can specify a filter:

1521 autotest chicken subset? chicken.c [any other .c or .h files]

1521 autotest will not test everything.
Always do your own testing.

Automarking will be run by the lecturer after the submission deadline, using a superset of tests to those autotest runs for you.

Submission

When you are finished working on the assignment, you must submit your work by running give:

give cs1521 ass2_chicken chicken.c [other .c or .h files] 

You must run give before Week 11 Monday 09:00:00 to obtain the marks for this assignment. Note that this is an individual exercise, the work you submit with give must be entirely your own.

You can run give multiple times.
Only your last submission will be marked.

If you are working at home, you may find it more convenient to upload your work via give's web interface.

You cannot obtain marks by emailing your code to tutors or lecturers.

You can check your latest submission on CSE servers with:

1521 classrun check ass2_chicken

You can check the files you have submitted here.

Manual marking will be done by your tutor, who will mark for style and readability, as described in the Assessment section below. After your tutor has assessed your work, you can view your results here; The resulting mark will also be available via give's web interface.

Due Date

This assignment is due Week 11 Monday 09:00:00.

If your assignment is submitted after this date, each hour it is late reduces the maximum mark it can achieve by 2%. For example, if an assignment worth 74% was submitted 10 hours late, the late submission would have no effect. If the same assignment was submitted 15 hours late, it would be awarded 70%, the maximum mark it can achieve at that time.

Assessment Scheme

This assignment will contribute 15 marks to your final COMP1521 mark.

80% of the marks for assignment 2 will come from the performance of your code on a large series of tests.

20% of the marks for assignment 2 will come from hand marking. These marks will be awarded on the basis of clarity, commenting, elegance and style. In other words, you will be assessed on how easy it is for a human to read and understand your program.

An indicative assessment scheme follows. The lecturer may vary the assessment scheme after inspecting the assignment submissions, but it is likely to be broadly similar to the following:

HD (90+%) well documented code,
very readable code,
subsets 0-3 working for all eggs.
DN (80+%) some documentation in code,
readable code,
subsets 0-2 working for all eggs.
CR (70%) some documentation in code,
readable code,
subset 0-1 working for all eggs.
PS (60%) subset 0 working for all eggs.
0% knowingly providing your work to anyone
and it is subsequently submitted (by anyone).
0 FL for
COMP1521
submitting any other person's work;
this includes joint work.
academic
misconduct
submitting another person's work without their consent;
paying another person to do work for you.

Intermediate Versions of Work

You are required to submit intermediate versions of your assignment.

Every time you work on the assignment and make some progress you should copy your work to your CSE account and submit it using the give command below. It is fine if intermediate versions do not compile or otherwise fail submission tests. Only the final submitted version of your assignment will be marked.

All these intermediate versions of your work will be placed in a Git repository and made available to you via a web interface at https://gitlab.cse.unsw.edu.au/z5555555/21T3-comp1521-ass2_chicken (replacing z5555555 with your own zID). This will allow you to retrieve earlier versions of your code if needed.

Assignment Conditions

Violation of any of the above conditions may result in an academic integrity investigation, with possible penalties up to and including a mark of 0 in COMP1521, and exclusion from future studies at UNSW. For more information, read the UNSW Student Code, or contact the course account.

Change Log

Version 1.0
(2021-11-05 16:00:00)
  • Initial release.
Version 1.1
(2021-11-08 10:00:00)
  • Specfication changed to clarify magic numbers and hashs do not need to be checked with -l, -L & -x
Version 1.2
(2021-11-08 16:00:00)
  • Reference implemntation updated to handle handling paths containing directories correctly
Version 1.2
(2021-11-1216:00:00)
  • Reference implemntation updated to fix broken error message regarding invalid permission strings