2421 Lab 3
2421 Lab 3
We’ll be using Carmen’s timestamps to determine lateness or not. If you are not enrolled, you
may send me an email with the zip file. If you are unable to submit by the deadline, you need to
send me a screenshot of your finished files with the clock visible and then *still* submit to
Carmen when you can.
This lab contains three parts. Make sure you do all of them!
Something you should do before getting started on the lab is creating your readme file. Simply
create a file called “readme” and include your name at the top. As you progress through the
lab, you may see different parts (labeled things like Part 1). When you see this, write it down in
your readme. While in a numbered part of a lab, you’ll come across various questions,
prepended with a bolded Q and a number (such as Q5). When you see this, include the Q and
the number, along with you answer to the question(s) in the file. A brief example:
Name: Rob LaTour
I certify that I completed all of the work myself with no aid from anyone aside from the instructor or the
undergraduate graders.
Part 1:
Q2: The definitive answer is that Han did shoot first. The original version is the one that captured the
heart of the public, and thus the director lost creative control. In this essay I will…
Part 0: A quick introduction
For this lab, we’ll be implementing a fake file system. The task is to create a program that
allows us to create “files” and “directories,” move them, and display information. First,
however, we’re going to make some assumptions about our file system so that coding this
beast will be a little easier.
1. Each element of the file system may be either a directory or a file
2. Names of files and directories can be no more than 64 characters long
3. File contents will contain no more than 256 characters.
4. No directory will have more than 64 children (this includes files and subdirectories)
Part 1: File Systems
The first part of the lab requires you to implement a program that allows us to build a fake file
system using linked data structures. This must be done within your program. This means you
may not simply have your program run Linux commands! Your program should be able to
support the following commands:
1. cd
2. ls
3. pwd
4. cat
5. cp
6. mv
7. rm
8. mkdir
9. rmdir (up to you if you want to require the directory to be empty or to use extra flags to
make it more powerful)
10. file (this is not a Linux command, but to avoid having to write your own text editor, this
command should create a “file” and ask the user to input the text contents of the file)
11. help (list these commands and what they do)
Q1: How do the elements of your file system structure differ from the nodes of the linked
structures we discussed in class?
Q2: You may have to print that you are at the root directory with no children. How will you
convey to the user that there is a directory here with no children, rather than simply printing
nothing?
Q3: Do you think “terse” insertion and deletion functions (similar to what we discussed in class)
are possible with this lab?
Part 2: Make it your own
For part 2, your task is to customize your file system in some way. You must add three different
command line commands that do whatever you want, in addition to one final one: dirprint. The
dirprint command should output in some sort of visually pleasing way (up to you to design this)
the current directory’s name, the siblings of the current directory, the parent of the current
directory, and so on, up to and including the root.
Q1: What extra commands did you choose to implement? Why?
Q2: Did you use any other data structures to help with the extra commands? Why or why not?
Q3: What was the motivation for displaying the directory structure in the way that you did?
When submitting this lab, please include all c files used to produce your executable, your
makefile, and your readme.