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 birthtime, blocksize and blks to stat_output for NTFSFilesystemEntry #848

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Miauwkeru
Copy link
Contributor

st_block is 0 when the file is resident, as it inside the MFT metadata
st_birthtime and st_birthtime_ns now use the creation_time from a MFT Record

Other timestamps where incorrectly used, and have been changed:

st_mtime: changed from using last_change_time to last_modification_time
st_ctime: changed from using creation_time to last_change_time

@Miauwkeru Miauwkeru linked an issue Sep 13, 2024 that may be closed by this pull request
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.59%. Comparing base (c5bf1ed) to head (8fd94c0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #848   +/-   ##
=======================================
  Coverage   75.59%   75.59%           
=======================================
  Files         311      311           
  Lines       26561    26569    +8     
=======================================
+ Hits        20078    20086    +8     
  Misses       6483     6483           
Flag Coverage Δ
unittests 75.59% <100.00%> (+<0.01%) ⬆️

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.

@Schamper
Copy link
Member

image

@Miauwkeru
Copy link
Contributor Author

Miauwkeru commented Sep 13, 2024

image

"_st_ctime": "integer time of last change",

So what do we want to use, the windows style or unix style? Cause I'd prefer them to be consistent across dissect. Regardless what the python docs say. As we change it anyways

@Schamper
Copy link
Member

The entire filesystem layer is designed to be consistent with Python since the beginning of Dissect.

@Miauwkeru
Copy link
Contributor Author

The entire filesystem layer is designed to be consistent with Python since the beginning of Dissect.

In that case, have we changed that for any other filesystem then? Where the c_time gets used for the birth timestamp on the machine? Or should we adapt the btrfs stuff too when using windows?

Cause in this current case it seems to only hold for ntfs doesn't it?

@Schamper
Copy link
Member

Schamper commented Sep 13, 2024

https://github.com/python/cpython/blob/3.12/Modules/posixmodule.c#L2142-L2145
https://docs.python.org/3/library/os.html#os.DirEntry.stat (deprecation note)

The only thing missing currently is setting st_birthtime and st_birthtime_ns to their proper values on Windows filesystems (read, NTFS).

Btrfs and other filesystems don't have this, as they actually properly expose all 4 timestamps.

@Miauwkeru
Copy link
Contributor Author

https://github.com/python/cpython/blob/3.12/Modules/posixmodule.c#L2142-L2145 https://docs.python.org/3/library/os.html#os.DirEntry.stat (deprecation note)

The only thing missing currently is setting st_birthtime and st_birthtime_ns to their proper values on Windows filesystems (read, NTFS).

Btrfs and other filesystems don't have this, as they actually properly expose all 4 timestamps.

st_birthtime gets set here right?: https://github.com/python/cpython/blob/aee219f4558dda619bd86e4b0e028ce47a5e4b77/Python/fileutils.c#L1122

where ctime gets changed afterwards at the posixmodule sets it to the value in st_birthtime, which is only used for backwards compatibility.

So sure, I'll set the ctime to birthtime for now. And make a note about it for backwards compatibility

st_block is `0` when the file is resident, as it inside the MFT metadata
st_birthtime and st_birthtime_ns now use the creation_time from a MFT Record

Other timestamps where incorrectly used, and have been changed:

st_mtime: changed from using last_change_time to last_modification_time
st_ctime: changed from using creation_time to last_change_time
@Miauwkeru Miauwkeru force-pushed the 820-add-metadata-to-stat-output-for-ntfs branch from d5a6364 to 8fd94c0 Compare September 20, 2024 09:09
@Schamper
Copy link
Member

@Miauwkeru
Copy link
Contributor Author

st_birthtime gets set here right?: https://github.com/python/cpython/blob/aee219f4558dda619bd86e4b0e028ce47a5e4b77/Python/fileutils.c#L1122

In our code.

which I've done?

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 NTFS
2 participants