From 9ef98fd05a335834b3ecb005d820be19784764d8 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 4 May 2015 18:35:52 -0400 Subject: 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. --- src/ostree/ot-admin-builtin-deploy.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ostree/ot-admin-builtin-deploy.c') diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c index 091a7eac..1872894b 100644 --- a/src/ostree/ot-admin-builtin-deploy.c +++ b/src/ostree/ot-admin-builtin-deploy.c @@ -79,6 +79,9 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro refspec = argv[1]; + if (!ostree_sysroot_lock (sysroot, error)) + goto out; + if (!ostree_sysroot_load (sysroot, cancellable, error)) goto out; @@ -172,6 +175,8 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro ret = TRUE; out: + if (sysroot) + ostree_sysroot_unlock (sysroot); if (origin) g_key_file_unref (origin); if (context) -- cgit v1.2.1