Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab1: find #6

Open
Bevisy opened this issue Jul 10, 2022 · 0 comments
Open

lab1: find #6

Bevisy opened this issue Jul 10, 2022 · 0 comments
Assignees
Labels
Middle Hardness of assignments: 1-2 hours

Comments

@Bevisy
Copy link
Member

Bevisy commented Jul 10, 2022

Write a simple version of the UNIX find program: find all the files in a directory tree with a specific name. Your solution should be in the file user/find.c.

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 is correct if produces the following output (when the file system contains the files b and a/b):
$ make qemu
...
init: starting sh
$ echo > b
$ mkdir a
$ echo > a/b
$ find . b
./b
./a/b
$ 
@Bevisy Bevisy added the Middle Hardness of assignments: 1-2 hours label Jul 10, 2022
@Bevisy Bevisy self-assigned this Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Middle Hardness of assignments: 1-2 hours
Projects
None yet
Development

No branches or pull requests

1 participant