diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-03-01 16:46:50 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-03-02 12:15:25 +0100 |
commit | 403e5b32301cab098151814acbd08821475c00c3 (patch) | |
tree | 1cd0ed39fcb774ffbde17ddd04591241e38aec01 | |
parent | 432cea008720480f6eaae7e75e6ad255e91fe2b4 (diff) |
importd: take a lock while we set up /var/lib/machines/
This way, we can safely set up the directories from two processes at the
same time, including machined and importd simultaneously.
-rw-r--r-- | src/shared/machine-pool.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/machine-pool.c b/src/shared/machine-pool.c index add19bb5a1..7b17395d21 100644 --- a/src/shared/machine-pool.c +++ b/src/shared/machine-pool.c @@ -161,6 +161,7 @@ fail: } int setup_machine_directory(sd_bus_error *error) { + _cleanup_release_lock_file_ LockFile lock_file = LOCK_FILE_INIT; struct loop_info64 info = { .lo_flags = LO_FLAGS_AUTOCLEAR, }; @@ -170,6 +171,11 @@ int setup_machine_directory(sd_bus_error *error) { bool tmpdir_made = false, mntdir_made = false, mntdir_mounted = false; int r, nr = -1; + /* Make sure we only set the directory up once at a time */ + r = make_lock_file("/run/systemd/machines.lock", LOCK_EX, &lock_file); + if (r < 0) + return r; + r = check_btrfs(); if (r < 0) return sd_bus_error_set_errnof(error, r, "Failed to determine whether /var/lib/machines is located on btrfs: %m"); |