Skip to content

Add new DirEntry class#1389

Merged
Schamper merged 2 commits intomainfrom
direntry
Nov 21, 2025
Merged

Add new DirEntry class#1389
Schamper merged 2 commits intomainfrom
direntry

Conversation

@Schamper
Copy link
Member

@Schamper Schamper commented Nov 6, 2025

Related to #649, but I don't want to close that with this PR since there's still quite a lot of work left to do.

This is my initial effort into adding a DirEntry class that accompanies FilesystemEntry. With this, a FilesystemEntry could be seen more akin to an "inode", and DirEntry is, obviously, a "dirent". The function signature of .scandir() changes with this PR.

Not all possible improvements are immediately implemented with this PR, I want to do that incrementally. For example, VirtualFilesystem should get a major refactor, which means a ton of other "filesystems" will too. There's also a ton of separate improvements to be made for each filesystem, as most implementations don't currently have a DirEntry concept of their own (with the exception of VMFS and APFS, and NTFS with fox-it/dissect.ntfs#48, which this PR depends on).

Also the mentioned possibility of "flags" on directory entries in #649 is not implemented yet (e.g. "deleted").

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 72.96037% with 116 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.02%. Comparing base (73dd16d) to head (786bccd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dissect/target/filesystems/ntfs.py 44.89% 27 Missing ⚠️
dissect/target/filesystems/vmfs.py 48.00% 13 Missing ⚠️
dissect/target/filesystems/btrfs.py 50.00% 8 Missing ⚠️
dissect/target/filesystem.py 91.25% 7 Missing ⚠️
dissect/target/filesystems/extfs.py 60.00% 6 Missing ⚠️
dissect/target/filesystems/ffs.py 60.00% 6 Missing ⚠️
dissect/target/filesystems/smb.py 68.42% 6 Missing ⚠️
dissect/target/filesystems/xfs.py 60.00% 6 Missing ⚠️
dissect/target/filesystems/fat.py 61.53% 5 Missing ⚠️
dissect/target/filesystems/ad1.py 60.00% 4 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1389      +/-   ##
==========================================
+ Coverage   80.94%   81.02%   +0.08%     
==========================================
  Files         376      376              
  Lines       33544    33593      +49     
==========================================
+ Hits        27153    27220      +67     
+ Misses       6391     6373      -18     
Flag Coverage Δ
unittests 81.02% <72.96%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 6, 2025

CodSpeed Performance Report

Merging #1389 will not alter performance

Comparing direntry (786bccd) with main (73dd16d)

Summary

✅ 9 untouched

@twiggler twiggler self-requested a review November 11, 2025 12:48
Copy link
Contributor

@twiggler twiggler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget about APFS

@twiggler twiggler self-requested a review November 19, 2025 09:56
Copy link
Contributor

@twiggler twiggler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the windows unit tests are failing

@Schamper
Copy link
Member Author

Don't forget about APFS

If this is merged before #1365, I'll do it in that PR. If #1365 is merged before this, I'll fix it here.

@Schamper Schamper merged commit e798081 into main Nov 21, 2025
18 of 22 checks passed
@Schamper Schamper deleted the direntry branch November 21, 2025 10:59
@JSCU-CNI
Copy link
Contributor

Am I correct to assume this PR should or does not introduce breaking changes for existing filesystem implementations? I see the TargetPath.get method does some duck typing for the _direntry attribute.

@Schamper
Copy link
Member Author

Schamper commented Nov 25, 2025

Am I correct to assume this PR should or does not introduce breaking changes for existing filesystem implementations? I see the TargetPath.get method does some duck typing for the _direntry attribute.

If you implemented your own Filesystem, then there are some necessary changes:

  • FilesystemEntry.scandir() -> should yield DirEntry now
  • FilesystemEntry.iterdir() -> can be removed entirely
  • Ideally, you also implement your own subclass of DirEntry, otherwise you get a very inefficient fallback

Any code that uses the scandir method directly will need to be adjusted to deal with DirEntry. However, all code that uses TargetPath does not require any changes. This will also be reflected in the changelog in the release that contains this change.

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.

3 participants