From 4d723df2f2e59764a13df3778743140c0ea2f439 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 1 Aug 2017 05:43:35 -0400 Subject: [PATCH] lib/sysroot: Add prefixes to syncfs/fsync error messages And clean up one other bare `glnx_throw_errno()`. Closes: #1044 Approved by: jlebon --- src/libostree/ostree-sysroot-deploy.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index b2b46b36..2e030429 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -977,7 +977,7 @@ syncfs_dir_at (int dfd, if (!glnx_opendirat (dfd, path, TRUE, &child_dfd, error)) return FALSE; if (syncfs (child_dfd) != 0) - return glnx_throw_errno (error); + return glnx_throw_errno_prefix (error, "syncfs(%s)", path); return TRUE; } @@ -992,7 +992,7 @@ full_system_sync (OstreeSysroot *self, GError **error) { if (syncfs (self->sysroot_fd) != 0) - return glnx_throw_errno (error); + return glnx_throw_errno_prefix (error, "syncfs(sysroot)"); if (!syncfs_dir_at (self->sysroot_fd, "boot", cancellable, error)) return FALSE; @@ -1379,7 +1379,7 @@ swap_bootloader (OstreeSysroot *sysroot, * admin by going back to the previous session. */ if (fsync (boot_dfd) != 0) - return glnx_throw_errno (error); + return glnx_throw_errno_prefix (error, "fsync(boot)"); return TRUE; } @@ -1452,10 +1452,9 @@ cleanup_legacy_current_symlinks (OstreeSysroot *self, GCancellable *cancellable, GError **error) { - guint i; g_autoptr(GString) buf = g_string_new (""); - for (i = 0; i < self->deployments->len; i++) + for (guint i = 0; i < self->deployments->len; i++) { OstreeDeployment *deployment = self->deployments->pdata[i]; const char *osname = ostree_deployment_get_osname (deployment); @@ -1463,11 +1462,8 @@ cleanup_legacy_current_symlinks (OstreeSysroot *self, g_string_truncate (buf, 0); g_string_append_printf (buf, "ostree/deploy/%s/current", osname); - if (unlinkat (self->sysroot_fd, buf->str, 0) < 0) - { - if (errno != ENOENT) - return glnx_throw_errno (error); - } + if (!ot_ensure_unlinked_at (self->sysroot_fd, buf->str, error)) + return FALSE; } return TRUE;