-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
stat: Convert to use uucore functions
#8398
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
GNU testsuite comparison: |
We can rely on other fsext/time functions, and stay a bit more consistent.
Depending on the caller, we want the number of seconds, that and an error printed out, or seconds+nanoseconds.
Useful for archaeologists and time travellers, do not crash if ctime is before 1970. Creating a file with such a change time is a bit challenging (touch can't change that), so we can't easily add end-to-end tests. Steps to create a filesystem with a file `x` with birth/change time in 1960. ``` dd if=/dev/zero bs=100M count=0 seek=1 of=ext4 mkfs.ext4 ext4 sudo mount ext4 mnt touch mnt/x umount mnt echo "set_inode_field x ctime 196001010101" | debugfs -w ext4 echo "set_inode_field x ctime_extra 1234" | debugfs -w ext4 echo "set_inode_field x crtime 196001010101" | debugfs -w ext4 echo "set_inode_field x crtime_extra 0x123400" | debugfs -w ext4 sudo mount ext4 mnt ``` $ cargo run -p uu_stat mnt/x File: mnt/x size: 0 Blocks: 0 IO Block: 1024 regular empty file Device: 700h/1792d Inode: 13 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2025-07-26 19:52:00.849821694 +0800 Modify: 2025-07-26 19:52:00.849821694 +0800 Change: 1960-01-02 09:01:00.000298240 +0800 Birth: 1960-01-02 09:01:00.000298240 +0800
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mostly common code elimination, and fix a crash if a file change time (ctime) is <1970 (not a terribly common thing ,-P)
fsext: Fix metadata_get_time for change time (ctime) before 1970
Useful for archaeologists and time travellers, do not crash if
ctime is before 1970.
Creating a file with such a change time is a bit challenging
(touch can't change that), so we can't easily add end-to-end
tests.
Steps to create a filesystem with a file
xwith birth/changetime in 1960.
uucore: time: Add options for format_system_time
Depending on the caller, we want the number of seconds, that
and an error printed out, or seconds+nanoseconds.
stat: Stop relying on fsext::Birth
We can rely on other fsext/time functions, and stay a bit more
consistent.
stat: Use uucore::time:format_system_time function