Skip to content

See why rm * shows fewer files, but deletes all#303

Open
kittykatspiral wants to merge 4 commits into
xoriors:cdl-spring-2025from
kittykatspiral:main
Open

See why rm * shows fewer files, but deletes all#303
kittykatspiral wants to merge 4 commits into
xoriors:cdl-spring-2025from
kittykatspiral:main

Conversation

@kittykatspiral

Copy link
Copy Markdown

Title

See why rm * shows fewer files, but deletes all – #38

Description

This PR investigates the issue described in #38 where running rm * in a directory with more than 100 files results in only ~100 entries being listed, but all files still being deleted.

I originally attempted a fix by modifying the readdir function’s offset handling, but the required changes to the iterator's structure conflicted with the expected return types and caused compilation issues. Given the complexity and interconnectedness of the offset behavior in FUSE, especially how it handles continuation with offsets during reads, I decided instead to leave the logic unchanged and add inline comments explaining the current behavior and known limitations.

This way, the problem is now clearly documented in the code for future maintainers, and anyone picking up the issue later will have a better sense of what’s going on and why things are the way they are.

I also added comments near the key areas that contribute to the offset behavior. These highlight the spot where FUSE uses the offset value to decide where to resume the directory listing, which seems to be where this “incomplete listing” issue originates when using rm * or similar commands that rely on reading the full list.


Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my code
  • I have tested my code on different platforms (if applicable)
  • I have commented my code, particularly in hard-to-understand areas
  • I have added necessary documentation (if appropriate)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Context

This PR doesn't fix the issue directly but serves as a documentation step for maintainers and contributors. Any “real” fix would likely require rethinking how DirectoryEntryIterator interacts with offsets or restructuring how offsets are assigned and used across the directory read logic — which is outside the scope of this PR and risky to do without a full test suite around it.

This is intended as a safe step toward understanding the bug, not a final resolution.

radumarias and others added 4 commits May 3, 2025 08:03
- Replaced simple `.skip(offset as usize)` with `.skip_while` + conditional `.skip(1)` to skip entries up to the requested offset.
- Added explicit handling to start from the beginning if offset is 0.
- Removed unused variables and cleaned up parameter names by prefixing with underscores.
- Kept clippy allows for safe casting and to reduce warnings.
- This change aims to better conform to FUSE offset semantics when reading directories.

Signed-off-by: kittykatspiral <anaflorentinaneacsu@gmail.com>
…SE behavior

- revert changes to readdir that attempted to fix offset handling
- added comments explaining known issues with FUSE and offset behavior
- current logic causes tools like `rm *` to only list 100 files but still deletes all
- fixing this properly would require deeper changes to iterator structure and offsets
- leaving it as-is for now with comments for future contributors

Signed-off-by: kittykatspiral <anaflorentinaneacsu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants