Project 1: minitar - A Posix-Compatible Archive Utility
Source
This project was taken from CSCI 4061 Intro to Operating Systems at the University of Minnesota - Twin Cities [Fall 2024], taught by Jack Kolb.
π¦ Starter Code
You can download the starter code here: proj1-code.zip
Save the starter code under your csci4061
directory, which should now look like this:
csci4061/
βββ labs/
β βββ lab01-code/
β βββ ...
βββ projects/
βββ proj1-code/
β How to Succeed on This Project
- Read the spec thoroughly. TAs may decline to help if you havenβt.
- Understand the starter code. Know what each file does.
- Test independently. Donβt rely solely on automated tests.
- Expect bugs. Stay patient and persistent.
- Start early. Avoid deadline pressure.
- Ask questions publicly on Piazza. This helps everyone.
- Know the late policy. No submissions accepted more than 48 hours late.
π§ Introduction
In this project, you will implement a simplified version of the Unix tar
utility called minitar
. Youβll work with C and the stdio
library to:
- Practice file I/O
- Explore systems programming techniques
- Build a Posix-compliant archive tool
Your implementation will be able to:
- Create and append to archives
- Extract files
- Interoperate with tar
π» Makefile Commands
make # Compile minitar
make clean # Remove compiled files
make clean-tests # Remove test output
make zip # Create Gradescope zip
make test # Run all test cases
make test testnum=5 # Run specific test
π§ͺ Manual Testing Advice
- Use your own test cases
- View archives using:
xxd test.tar | less
- Use
tar
for interoperability comparison - Install
xxd
in Docker:apt update apt install xxd
π§° Starter Code Files
File | Purpose | Notes |
---|---|---|
Makefile |
Build/tests | Do not modify |
file_list.h / file_list.c |
Linked list support | Do not modify |
minitar.h |
Archive headers | Do not modify |
minitar.c |
Archive operations | EDIT THIS |
minitar_main.c |
CLI logic | EDIT THIS |
testius |
Test runner | Do not modify |
test_cases/ |
Sample inputs | Do not modify |
Only modify the files marked as EDIT.
π¦ Archive Format Overview
- Each archive is made of 512-byte blocks
- Each file: 1 header block + content blocks
- Ends with two zero blocks
tar_header Struct
Defined in minitar.h
, it uses octal-encoded strings for numeric fields.
char size[12]; // octal, null-terminated string
Use fill_tar_header()
to generate headers.
π Archive Operations
Create
./minitar -c -f archive.tar file1 file2
Append
./minitar -a -f archive.tar newfile
remove_trailing_bytes()
- Append new headers/data
- Add new footer
List
./minitar -t -f archive.tar
Update
./minitar -u -f archive.tar existingfile
Error: One or more of the specified files is not already present in archive.
Extract
./minitar -x -f archive.tar
π‘ Tips & Assumptions
- No nested directory support
- Use high-level I/O (
fopen
, notopen
) - Use
memset()
,fseek()
,ftell()
- Leverage
fill_tar_header()
andfile_list
utilities
Useful C Functions
fread()
,fwrite()
ftell()
,fseek()
sscanf()
for octal parsingperror()
for error reporting
π§ Strategy & Hints
- Reuse logic between operations
- Write helpers for block iteration
- Start early, debug often, test manually
- Avoid mixing
fopen()
andopen()
π Summary
This project is your first big opportunity to apply systems-level thinking and build a utility that mirrors a well-known Unix tool. You'll practice file I/O, struct management, and command-line parsing β and develop habits that will serve you in all future OS coursework.
Ready to begin? Download the starter code and get coding!