CS61C Project 1 Simplified-- Fall 2006

Like the normal Project 1 But without Softlinks


UPDATE: It seems that the fix for the memory leak in mv was incorrect. Please see the blue update in the main spec for the correct fix (basically place the return; statement back in and add two free commands). Because this is a bug that was in the project spec, error checking will no longer be tested on mv.

This is a simplified version of project 1.  The maximum score of this is 20/20, rather than 25/20.

The description of this project is a subset of the main project.  The only difference is that the "ln" command no longer needs to be supported and that a data structure change should be made.  You MUST refer to the main project to understand the entire thing; simply disregard anything about "softlinks" in the main project.

Fundamental Differences

With the complication of softlinks removed, working directories become much simpler to manage.  Why? Because there are no longer multiple routes to get to a directory!

To make life much easier, you should add
struct entryNode * parent;
to the entryNode structure in directory.c (This is the only modification you are allowed to make to that structure).

It is now: 
struct entryNode {

    char * name;
    struct entryNode * next;    
    uint16_t attributes;

    struct entryNode * parent;   /*NEW - PARENT POINTER!!!*/

    union {
      char * contents; /*for files*/
      struct entryNode * entryList; /*for directories*/
      char * shortcutReference;  /*for softlinks - just keep this in (it means nothing now of course)*/
    } entry;
};
This new parent element points to the "parent directory" of this entryNode.

Remember our example?


This is now represented as (again 0 and 1 refer to the the directory attribute):
directory


So what does this mean?

To keep of the working directory, you need nothing more than a pointer to a specific entryNode.

Because softlinks no longer exist, cd .. will now always refer to the the parent of the current working directory!
And pwd can be done by simply walking up from the current entryNode to the root!

So you no longer need to implement any new data structures to keep track of working directories - you just need a pointer (or maybe a few pointers) to entryNodes.

The parent of the root directory can be anything you want.  Good choices are the parent itself or just NULL.  Just remember, that "cd .." in the root directory is the root directory.  

So what must you do?

The following is the original to-do list.  I have struck-out what you no longer have to do.

-Finish the code for the following commands (according to the specifications of the main project - ignoring the details about softlinks):
    create - in createFile
    append - in appendfile
    mkdir - in createDir
    cd - in newWorkingDir
    ln (almost completed already) - in createSoftLink
    rm - in removeFile
    rmdir - in removeDir
    mv (almost completed already) - in moveEntry
    pwd - in printWorkingDir
    ls - in listWorkingDir and listWithinWorkingDir
    setRead - in modifyReadable
    setWrite - in modifyWritable
-Design the data structure to keep track of working directories (needed for locateItem, resolvePath, cd, and pwd)
-Add any helper functions you may need to successfully implement the beforementioned commands.
-Correctly initialize the file system as well as your working Directory structure - in initialFileSystem
-Implement the helper functions:

    locateItem
    resolvePath
-Write your README file

Remember, paths haven't gone anywhere.  They are just easier to deal with since softlinks do not exist.

Oh, and ln can do whatever you want it to.  We won't be testing it anymore.  (You will need to keep the createSoftLink function though so that your project links (no pun intended) correctly).

Submission

Submission is the same as the original:

Submit your solution with the submit proj1 command.
You must include directory.c, which contains your modifications to directory.c, as well as a README file, which should discuss design decisions you made, explain your choice of data structures, and if you like, provide brief comments on any problems you encountered and how you overcame them.  Be sure to mention in the README file that you do not support softlinks.


ENJOY!