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

Add XFS metadata: blocks per file and block size #33

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Conversation

twiggler
Copy link
Contributor

@twiggler twiggler commented Oct 3, 2024

Expose blocks per file and the block size of the file system

Companion PR to fox-it/dissect.target#874

Closes #32

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.50%. Comparing base (b95970a) to head (c176748).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
+ Coverage   64.25%   64.50%   +0.25%     
==========================================
  Files           4        4              
  Lines         414      417       +3     
==========================================
+ Hits          266      269       +3     
  Misses        148      148              
Flag Coverage Δ
unittests 64.50% <100.00%> (+0.25%) ⬆️

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.

@twiggler twiggler requested a review from pyrco October 3, 2024 12:23
@@ -294,6 +294,10 @@ def _has_large_extent_counts(self) -> bool:
def size(self) -> int:
return self.inode.di_size

@property
def number_of_blocks(self) -> int:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def number_of_blocks(self) -> int:
def nblocks(self) -> int:

@@ -22,9 +23,11 @@ def test_xfs(xfs_bin):
assert list(root.listdir().keys()) == [".", "..", "test_file", "test_dir", "test_link"]

test_file = xfs.get("test_file")
assert test_file.number_of_blocks == 1
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert test_file.number_of_blocks == 1
assert test_file.nblocks == 1

assert test_file.open().read() == b"test content\n"

test_link = xfs.get("test_link")
assert test_link.number_of_blocks == 0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert test_link.number_of_blocks == 0
assert test_link.nblocks == 0

@@ -34,18 +37,22 @@ def test_xfs_sparse(xfs_sparse_bin):

sparse_start = xfs.get("sparse_start")
assert sparse_start.size == 0x258000
assert sparse_start.number_of_blocks == 200
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert sparse_start.number_of_blocks == 200
assert sparse_start.nblocks == 200

assert sparse_start.dataruns() == [(None, 400), (1392, 200)]

sparse_hole = xfs.get("sparse_hole")
assert sparse_hole.size == 0x258000
assert sparse_hole.number_of_blocks == 400
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert sparse_hole.number_of_blocks == 400
assert sparse_hole.nblocks == 400

assert sparse_hole.dataruns() == [(1792, 200), (None, 200), (2192, 200)]

sparse_end = xfs.get("sparse_end")
assert sparse_end.size == 0x190000
assert sparse_end.number_of_blocks == 200
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert sparse_end.number_of_blocks == 200
assert sparse_end.nblocks == 200

assert sparse_end.dataruns() == [(2392, 200), (None, 200)]

sparse_all = xfs.get("sparse_all")
assert sparse_all.size == 0x500000
assert sparse_all.number_of_blocks == 0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert sparse_all.number_of_blocks == 0
assert sparse_all.nblocks == 0

@twiggler twiggler merged commit 02c5531 into main Oct 7, 2024
17 checks passed
@twiggler twiggler deleted the xfs-metadata branch October 7, 2024 15:36
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.

Add metadata to stat output for XFS
2 participants