!WIP! mkfs: copy verity metadata from the --rootdir #971
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.
Add a new --fs-verity option. If it's specified, then check if the regular files in the --rootdir have fs-verity enabled, and if they do, copy the metadata into the created filesystem.
We could have done this implicitly on creation of all filesystems, but I believe the new --fs-verity option is justified (over simply always checking) for a number of reasons:
Issue: #929
So far this works, but not for zero-size or inline files.
I'd love some feedback here on the implementation. In particular, the way this fits in with the extents copying code is really awkward. I'd like to share the fd that we open() but we don't open the file if it's empty. I'd also maybe like to share the buffer.
My first thought would be to declare a separate buffer as a global and use it from both data copying and fs-verity copying. This code is not multithreaded and already has a bunch of global variables, so it's not thread-safe anyway. This would save the continuous
malloc()
/free()
. I'd also be happy to use a stack for this sort of thing: it's a large allocation (1MB) but it's in non-recursive application code, so it ought to be OK.There's also a question if the fs-verity copy should happen inside of the extent-copying function or not. That's where the fd is opened and I'd like to avoid opening the same file twice. I think I might like to create a function which opens the fd and then calls the extent copying code and then the fs-verity copying code separately. It's all a matter of taste and I'd like some input there.