sysroot: Add an API to lock
If a system administrator happens to type `ostree admin upgrade` multiple times, currently that will lead to a potentially corrupted system. I originally attempted to do locking *internally* in `libostree`, but that didn't work out because currently a number of the commands perform multi-step operations that all need to be serialized. All of the current code in `ostree admin deploy` is an example. Therefore, allow callers to perform locking, as most of the higher level logic is presently implemented there. At some point, we can revisit having internal locking, but it will be difficult. A more likely approach would be similar to Java's approach with concurrency on iterators - a "fail fast" method.
This commit is contained in:
1 parent
33b0667597
commit
9ef98fd05a
8 files changed
+110
-1
No files matched your search
@@ -20,6 +20,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "libglnx.h"
|
||||
#include "ostree.h"
|
||||
#include "ostree-kernel-args.h"
|
||||
#include "ostree-bootloader.h"
|
||||
@@ -31,6 +32,7 @@ struct OstreeSysroot {
|
||||
|
||||
GFile *path;
|
||||
int sysroot_fd;
|
||||
GLnxLockFile lock;
|
||||
|
||||
gboolean loaded;
|
||||
|
||||
@@ -43,8 +45,11 @@ struct OstreeSysroot {
|
||||
|
||||
/* Only access through ostree_sysroot_get_repo() */
|
||||
OstreeRepo *repo;
|
||||
|
||||
};
|
||||
|
||||
#define OSTREE_SYSROOT_LOCKFILE "ostree/lock"
|
||||
|
||||
gboolean
|
||||
_ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
|
||||
int bootversion,
|
||||
|
||||
Reference in new issue
Block a user