From: Colin Walters Date: Thu, 7 Sep 2017 16:11:55 +0000 (-0400) Subject: lib/sysroot: Use fd-relative acccess for bootversion cleanup X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~32^2~26 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7afa966198eb783a8fb4177ff71f9e8a6e23856c;p=ostree.git lib/sysroot: Use fd-relative acccess for bootversion cleanup I noticed this was an easy change. Closes: #1148 Approved by: peterbaouoft --- diff --git a/src/libostree/ostree-sysroot-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c index de313930..d689f02e 100644 --- a/src/libostree/ostree-sysroot-cleanup.c +++ b/src/libostree/ostree-sysroot-cleanup.c @@ -210,35 +210,29 @@ cleanup_other_bootversions (OstreeSysroot *self, GCancellable *cancellable, GError **error) { - int cleanup_bootversion = self->bootversion == 0 ? 1 : 0; - int cleanup_subbootversion = self->subbootversion == 0 ? 1 : 0; - - g_autoptr(GFile) cleanup_boot_dir = NULL; - cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d", cleanup_bootversion); - if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error)) + const int cleanup_bootversion = self->bootversion == 0 ? 1 : 0; + const int cleanup_subbootversion = self->subbootversion == 0 ? 1 : 0; + /* Reusable buffer for path */ + g_autoptr(GString) buf = g_string_new (""); + + /* These directories are for the other major version */ + g_string_truncate (buf, 0); g_string_append_printf (buf, "boot/loader.%d", cleanup_bootversion); + if (!glnx_shutil_rm_rf_at (self->sysroot_fd, buf->str, cancellable, error)) return FALSE; - g_clear_object (&cleanup_boot_dir); - - cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d", cleanup_bootversion); - if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error)) + g_string_truncate (buf, 0); g_string_append_printf (buf, "ostree/boot.%d", cleanup_bootversion); + if (!glnx_shutil_rm_rf_at (self->sysroot_fd, buf->str, cancellable, error)) return FALSE; - g_clear_object (&cleanup_boot_dir); - - cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.0", cleanup_bootversion); - if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error)) + g_string_truncate (buf, 0); g_string_append_printf (buf, "ostree/boot.%d.0", cleanup_bootversion); + if (!glnx_shutil_rm_rf_at (self->sysroot_fd, buf->str, cancellable, error)) return FALSE; - g_clear_object (&cleanup_boot_dir); - - cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.1", cleanup_bootversion); - if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error)) + g_string_truncate (buf, 0); g_string_append_printf (buf, "ostree/boot.%d.1", cleanup_bootversion); + if (!glnx_shutil_rm_rf_at (self->sysroot_fd, buf->str, cancellable, error)) return FALSE; - g_clear_object (&cleanup_boot_dir); - cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.%d", self->bootversion, - cleanup_subbootversion); - if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error)) + /* And finally the other subbootversion */ + g_string_truncate (buf, 0); g_string_append_printf (buf, "ostree/boot.%d.%d", self->bootversion, cleanup_subbootversion); + if (!glnx_shutil_rm_rf_at (self->sysroot_fd, buf->str, cancellable, error)) return FALSE; - g_clear_object (&cleanup_boot_dir); return TRUE; }