debugfs: dump: add rdump -p and handle attrs better #135
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.
This change is part of a contribution I made to erofs-utils on the fsck.erofs --extract=X option.
Timestamps should always be preserved as they are safe to preserve, regardless of user type.
This isn't the case for chmod/chown, which is only allowed to be used by root.
debugfs is used by different kinds of users (e.g. AOSP build system) since rdump is the only official way to dump the contents of an ext2/3/4 image.
The dump command already has the -p option, which lets non-root users omit to avoid an "operation not permitted" vomit all over the terminal, but rdump still pukes all the way.
AOSP knows this, they use rdump in their "deapexer" Python utility, and their way of handling this is just swallowing all output to both stdout and stderr, and only printing it out if the execution failed. This change brings the -p flag to rdump, and root users who actually need it can use it. Normal users simply can't avoid it, as it stands now.
The other change was making sure access/mod timestamps are preserved properly, since "utime" and "chown" try to dereference symlinks and thus not acting on the symlinks themselves. Using "utimensat" when available, and "lchown" instead of "chown" will avoid this error.
All this is already used in erofs-utils. I think we should sync this to e2fsprogs.
Feel free to change what you feel necessary.