-
Notifications
You must be signed in to change notification settings - Fork 25
Tree + Clear #32
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
base: main
Are you sure you want to change the base?
Tree + Clear #32
Conversation
|
I will review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Functionality works as expected and accounts for edge cases. Clear description in TREE.md as well, making it easy to use. Clean implementation for clear. Good comments in tree.c, makes it easy to follow and understand flow of the code. Test files are good (simple but makes sense considering it is just a placeholder for files). Minor improvement recommendation, since all of us have user and kernel directories, add those into the Makefile as well so that tree works and can find those directories as well. Very simple fix, just how you added tests into the Makefile so it can find the directory. But overall looks great!
High Level Checks:
- PR fully resolves the task/issue
- Does the PR have tests?
- Does the PR follow project code formatting standards?
- Does the OS still compile and run?
- Is documentation included?
Code Checks:
- Does the code achieve its intended purpose?
- Were all edge cases considered?
- Is the code organized and maintainable?
- Does the code maintain the same level of performance? (no performance regressions)
|
Verification Testing |-- file1.txt
|-- file2.txt
|-- file3.txt
|-- testdir
| |-- test4.txt
2 directories, 4 filesWhen pulling the repo the testdir directory was not inside the test files. However I was able to create the directory as the README displayed and when testing, using Code Walkthrough One think that was noticed when I added that testdir directory and tested $ tree /tests/testtree
/tests/testtree
|-- file1.txt
|-- file2.txt
|-- file3.txt
|-- testdir
| |-- test4.txt
2 directories, 4 files
$ tree .
.
|-- README.md
|-- cat
|-- clear
|-- echo
|-- forktest
|-- grep
|-- init
|-- kill
|-- ln
|-- ls
|-- mkdir
|-- rm
|-- sh
|-- stressfs
|-- usertests
|-- grind
|-- wc
|-- zombie
|-- logstress
|-- forphan
|-- dorphan
|-- tree
|-- tests
| |-- testtree
| | |-- file1.txt
| | |-- file2.txt
| | |-- file3.txt
| | |-- testdir
usertrap(): unexpected scause 0xf pid=6
sepc=0x92e stval=0x2d78`Going through the tree.c file this could be an issue with the recursion of the buffer here. while (read(fd, &de, sizeof(de)) == sizeof(de)) {
if (de.inum == 0 || strcmp(de.name, ".") == 0 || strcmp(de.name, "..") == 0)
continue; // Skip the current dir and the parent dir entries to avoid infinite loop
strcpy(p, de.name); // Holds the name of the current item it has found, copies the item's name into the bufferThe pointer p stays the same while the buffer is always changing when going through paths. Maybe add a checkpoint for the pointer. Formatting Checklist
Code Checks:
|
|
Tree is always nice to have, and the output looks great here. The approach for tracking the indentation level as a string is interesting. However, you will always be stuck with some hard-coded value, unless you dynamically resize the string... At which point the question might be, why not simply track the indentation level as an integer, add a helper function that dynamically indents, and call that instead? Then there's no worry about running out of space. I see you added a strcat helper but then are also still using memmove to concatenate... I'd pick one and stick with it. There's a comment in there about "p" being correctly identified as critical, I guess leftover LLM output? Looks like an agent did the fix. But "p" is not the problem here. Your 512-char Lastly, adding clear is a great idea, but I would be interested to know why you need to write in a loop. Did a humble 4.5/5 +0.5 the 3 fixes described above. |
This pull request was created to address Issue #5 which is implements the 'clear' and 'tree' command
See /docs/TREE.md for more documentation and test cases with expected outputs.