Find

Some hints:

  • Look at user/ls.c to see how to read directories.

  • Use recursion to allow find to descend into sub-directories.

  • Don't recurse into "." and "..".

  • Changes to the file system persist across runs of qemu; to get a clean file system run make clean and then make qemu.

  • You'll need to use C strings. Have a look at K&R (the C book), for example Section 5.5.

  • Note that == does not compare strings like in Python. Use strcmp() instead.

  • Add the program to UPROGS in Makefile.

Your solution should produce the following output (when the file system contains the files b, a/b and a/aa/b):

    $ make qemu
    ...
    init: starting sh
    $ echo > b
    $ mkdir a
    $ echo > a/b
    $ mkdir a/aa
    $ echo > a/aa/b
    $ find . b
    ./b
    ./a/b
    ./a/aa/b
    $
  

Run make grade to see what our tests think.

Last updated