summaryrefslogtreecommitdiff
path: root/src/libotutil/ot-fs-utils.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2015-04-06 14:19:08 -0400
committerColin Walters <walters@verbum.org>2015-05-06 08:07:20 -0400
commit5becd5ccad47fff009c1578fc870ffad66b940af (patch)
treeaba09b96bfdb0cfed877654dd09c359a39d12a3c /src/libotutil/ot-fs-utils.c
parent279308b5b95b587a306ab0841ebdd1b7ae4880e0 (diff)
downloadostree-5becd5ccad47fff009c1578fc870ffad66b940af.tar.gz
Teach fsck about partial commits
An OSTree user noticed that `ostree fsck` would produce `missing object` errors in the case of interrupted pulls. It's possible to do e.g. `ostree pull --subpath=/usr/share/rpm ...`, which gets you just that portion of the commit. The use case for this was being able to see what changes would appear in an update before actually downloading all of it. (I think this would be better covered by static deltas, but those aren't final yet, and `--subpath` predates it) Further, `.commitpartial` is used as a successor to the `transaction` symlink for more precise knowledge in the case where a pull was interrupted that we needed to resume scanning. So it makes sense for `ostree fsck` to be aware of it.
Diffstat (limited to 'src/libotutil/ot-fs-utils.c')
-rw-r--r--src/libotutil/ot-fs-utils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libotutil/ot-fs-utils.c b/src/libotutil/ot-fs-utils.c
index 040636bd..b0f41a64 100644
--- a/src/libotutil/ot-fs-utils.c
+++ b/src/libotutil/ot-fs-utils.c
@@ -22,6 +22,7 @@
#include "ot-fs-utils.h"
#include "libgsystem.h"
+#include "libglnx.h"
#include <sys/xattr.h>
#include <gio/gunixinputstream.h>
@@ -188,3 +189,20 @@ ot_openat_read_stream (int dfd,
out:
return ret;
}
+
+gboolean
+ot_ensure_unlinked_at (int dfd,
+ const char *path,
+ GError **error)
+{
+ if (unlinkat (dfd, path, 0) != 0)
+ {
+ if (G_UNLIKELY (errno != ENOENT))
+ {
+ glnx_set_error_from_errno (error);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+