diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-11-29 18:16:43 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-12-01 00:25:51 +0100 |
commit | 8d4aa2bb32c0fb9ab136167a1594bb4e4a09c8d5 (patch) | |
tree | b1abded3103af20f05cf74c0ef2fe07ceb15d703 /src/nspawn/nspawn.c | |
parent | 8ce48cf0f899c50a7dfba8efe45a729f61df060a (diff) |
nspawn: make use of CHASE_NON_EXISTING when locking image
If --template= is used on an image, then the image might not exist initially.
We can use CHASE_NON_EXISTING to properly lock the image already before it
exists. Let's do so.
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r-- | src/nspawn/nspawn.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 1a625e142e..9a308688e1 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2666,7 +2666,7 @@ static int determine_names(void) { return 0; } -static int chase_symlinks_and_update(char **p) { +static int chase_symlinks_and_update(char **p, unsigned flags) { char *chased; int r; @@ -2675,7 +2675,7 @@ static int chase_symlinks_and_update(char **p) { if (!*p) return 0; - r = chase_symlinks(*p, NULL, 0, &chased); + r = chase_symlinks(*p, NULL, flags, &chased); if (r < 0) return log_error_errno(r, "Failed to resolve path %s: %m", *p); @@ -4155,7 +4155,7 @@ int main(int argc, char *argv[]) { if (arg_ephemeral) { _cleanup_free_ char *np = NULL; - r = chase_symlinks_and_update(&arg_directory); + r = chase_symlinks_and_update(&arg_directory, 0); if (r < 0) goto finish; @@ -4203,6 +4203,10 @@ int main(int argc, char *argv[]) { remove_directory = true; } else { + r = chase_symlinks_and_update(&arg_directory, arg_template ? CHASE_NON_EXISTING : 0); + if (r < 0) + goto finish; + r = image_path_lock(arg_directory, (arg_read_only ? LOCK_SH : LOCK_EX) | LOCK_NB, &tree_global_lock, &tree_local_lock); if (r == -EBUSY) { log_error_errno(r, "Directory tree %s is currently busy.", arg_directory); @@ -4214,7 +4218,7 @@ int main(int argc, char *argv[]) { } if (arg_template) { - r = chase_symlinks_and_update(&arg_template); + r = chase_symlinks_and_update(&arg_template, 0); if (r < 0) goto finish; @@ -4236,10 +4240,6 @@ int main(int argc, char *argv[]) { log_info("Populated %s from template %s.", arg_directory, arg_template); } } - - r = chase_symlinks_and_update(&arg_directory); - if (r < 0) - goto finish; } if (arg_start_mode == START_BOOT) { @@ -4263,7 +4263,7 @@ int main(int argc, char *argv[]) { assert(arg_image); assert(!arg_template); - r = chase_symlinks_and_update(&arg_image); + r = chase_symlinks_and_update(&arg_image, 0); if (r < 0) goto finish; |