chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
importd: take a lock while we set up /var/lib/machines/
[elogind.git]
/
src
/
shared
/
machine-pool.c
diff --git
a/src/shared/machine-pool.c
b/src/shared/machine-pool.c
index add19bb5a10f86577ad79320fb70f106757c5fa1..7b17395d212b2bff7a82bd93b41f6c244739154f 100644
(file)
--- 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) {
}
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,
};
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;
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");
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");