-
Notifications
You must be signed in to change notification settings - Fork 232
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 support for exporting and importing file flags on FreeBSD #1378
Conversation
2d00e72
to
f820350
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question
LGTM
Rebased |
d3e97d2
to
8bd87e9
Compare
@flouthoc that commit could be split into functional parts, e.g.:
Would that help to clarify? |
@dfr Yes I think that would be really helpful thanks for considering my comment :) . |
I split the pkg/archive commit along the lines I suggested - hope that helps. |
Rebased |
@flouthoc PTAL |
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM — I’m really not that familiar with pkg/archive
, but at least the added tests add quite a bit of confidence.
Just a few optional stylistic nits.
Could you fix the two issues @mtrmac found. |
This also adds an integration test for deleting containers with immutable files. Signed-off-by: Doug Rabson <dfr@rabson.org>
Signed-off-by: Doug Rabson <dfr@rabson.org>
Note: these are likely to be identical on other BSDs, including darwin, but I'm keeping this for just FreeBSD to start with. Signed-off-by: Doug Rabson <dfr@rabson.org>
This will also probably work on other BSD derived platforms including darwin. Signed-off-by: Doug Rabson <dfr@rabson.org>
This adds platform-specific entry points to encode and decode file flags. These are exported so that they can be used in buildah/copier. A function which can be used to optionally reset the immutable flag on a file or directory is also added and this will be used when applying layer changes to trees with immutable files or directories. These new entry points are implemented for FreeBSD and are noop stubs on other platforms. The chflags approach could be used on darwin and other BSD-derived platforms if needed. On FreeBSD, file flag information is encoded for import/export using the PAX SCHILY.fflags option. This is compatible with bsdtar (see https://github.com/libarchive/libarchive). Reading the code for libarchive, it also has support for encoding/decoding Linux file flags so this seems like a good reference. Signed-off-by: Doug Rabson <dfr@rabson.org>
Note: the Flags method of system.StatT always returns zero on non-FreeBSD platforms so this should have no functional change for those platforms. Signed-off-by: Doug Rabson <dfr@rabson.org>
This encodes flag information into the tar stream using ReadFileFlagsToTarHeader and decodes with WriteFileFlagsFromTarHeader. To support applying diffs to trees with flags, this adds logic to reset immutable flags during the UnpackLayer process. To support immutable directories, we also need to defer setting flags on directories until after all modifications to the directory contents. Fortunately, something similar is already in place for setting directory modify times. Signed-off-by: Doug Rabson <dfr@rabson.org>
Done, thanks! |
LGTM |
The implementation could be shared with darwin and other BSDs if needed but initially is only enabled on FreeBSD. This uses the SCHILY.fflags PAX option to encode flags which is supported by libarchive (bsdtar) and star. The flag save/restore entry points are exported, allowing them to be used by buildah/copier.
To support applying diffs to trees with flags, I added logic to reset immutable flags during the UnpackLayer process - this is slightly complicated by the desire to support immutable directories which needs to defer setting fiags on directories to after all modifications to the directory contents. Fortunately, something similar is already in place for setting directory modify times.