repo: Add a checkout option to not hardlink zero-sized files
In rpm-ostree we've hit a few cases where hardlinking zero-sized files causes us problems. The most prominent is lock files in `/usr/etc`, such as `/usr/etc/selinux/semanage.LOCK`. If there are two zero-sized lock files to grab, but they're hardlinked, then locking will fail. Another case here is if one is using ostree inside a container and don't have access to FUSE (i.e. `rofiles-fuse`), then the ostree hardlinking can cause files that aren't ordinarily hardlinked to become so, and mutation of one mutates all. An example where this is concerning is Python `__init__.py` files. Now, these lock files should clearly not be in the tree to begin with, but - we're not gaining a huge amount by hardlinking these files either, so let's add an option to disable it. Closes: #1752 Approved by: jlebon
This commit is contained in:
1 parent
c70526841e
commit
673cacd633
4 files changed
+30
-4
No files matched your search
@@ -586,6 +586,7 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
const gboolean is_symlink = (g_file_info_get_file_type (source_info) == G_FILE_TYPE_SYMBOLIC_LINK);
|
||||
const gboolean is_whiteout = (!is_symlink && options->process_whiteouts &&
|
||||
g_str_has_prefix (destination_name, WHITEOUT_PREFIX));
|
||||
const gboolean is_reg_zerosized = (!is_symlink && g_file_info_get_size (source_info) == 0);
|
||||
|
||||
/* First, see if it's a Docker whiteout,
|
||||
* https://github.com/docker/docker/blob/1a714e76a2cb9008cd19609059e9988ff1660b78/pkg/archive/whiteouts.go
|
||||
@@ -604,6 +605,10 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
|
||||
need_copy = FALSE;
|
||||
}
|
||||
else if (options->force_copy_zerosized && is_reg_zerosized)
|
||||
{
|
||||
need_copy = TRUE;
|
||||
}
|
||||
else if (!options->force_copy)
|
||||
{
|
||||
HardlinkResult hardlink_res = HARDLINK_RESULT_NOT_SUPPORTED;
|
||||
@@ -699,6 +704,7 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
if (can_cache
|
||||
&& !is_whiteout
|
||||
&& !is_symlink
|
||||
&& !is_reg_zerosized
|
||||
&& need_copy
|
||||
&& repo->mode == OSTREE_REPO_MODE_ARCHIVE
|
||||
&& options->mode == OSTREE_REPO_CHECKOUT_MODE_USER)
|
||||
@@ -762,7 +768,7 @@ checkout_one_file_at (OstreeRepo *repo,
|
||||
* succeeded at hardlinking above.
|
||||
*/
|
||||
if (options->no_copy_fallback)
|
||||
g_assert (is_bare_user_symlink);
|
||||
g_assert (is_bare_user_symlink || is_reg_zerosized);
|
||||
if (!ostree_repo_load_file (repo, checksum, &input, NULL, &xattrs,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
@@ -933,7 +933,8 @@ typedef struct {
|
||||
gboolean no_copy_fallback;
|
||||
gboolean force_copy; /* Since: 2017.6 */
|
||||
gboolean bareuseronly_dirs; /* Since: 2017.7 */
|
||||
gboolean unused_bools[5];
|
||||
gboolean force_copy_zerosized; /* Since: 2018.9 */
|
||||
gboolean unused_bools[4];
|
||||
/* 4 byte hole on 64 bit */
|
||||
|
||||
const char *subpath;
|
||||
|
||||
Reference in new issue
Block a user