From c671c1dd3e48927a7c545ade4dec80d7dff5beda Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 31 Jul 2016 21:33:15 -0400 Subject: [PATCH] lib: Port away from gs_file_rename() In one case, we already had relative fds and hence this was nicer. Unfortunately the other areas got uglier. More fd-relative porting to do later. Closes: #424 Approved by: giuseppe --- src/libostree/ostree-bootloader-grub2.c | 8 +++++--- src/libostree/ostree-sysroot-deploy.c | 17 +++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c index 6aa551ae..30edb7a5 100644 --- a/src/libostree/ostree-bootloader-grub2.c +++ b/src/libostree/ostree-bootloader-grub2.c @@ -408,9 +408,11 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, */ if (!ot_gfile_ensure_unlinked (self->config_path_efi, cancellable, error)) goto out; - if (!gs_file_rename (new_config_path, self->config_path_efi, - cancellable, error)) - goto out; + if (rename (gs_file_get_path_cached (new_config_path), gs_file_get_path_cached (self->config_path_efi)) < 0) + { + glnx_set_error_from_errno (error); + goto out; + } } ret = TRUE; diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 779c7dc1..d4feb7ed 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -795,9 +795,12 @@ selinux_relabel_var_if_needed (OstreeSysroot *sysroot, cancellable, error)) goto out; - if (!gs_file_rename (deployment_var_labeled_tmp, deployment_var_labeled, - cancellable, error)) - goto out; + if (rename (gs_file_get_path_cached (deployment_var_labeled_tmp), + gs_file_get_path_cached (deployment_var_labeled)) < 0) + { + glnx_set_error_from_errno (error); + goto out; + } } ret = TRUE; @@ -861,9 +864,11 @@ merge_configuration (OstreeSysroot *sysroot, else if (etc_exists) { /* Compatibility hack */ - if (!gs_file_rename (deployment_etc_path, deployment_usretc_path, - cancellable, error)) - goto out; + if (renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc") < 0) + { + glnx_set_error_from_errno (error); + goto out; + } usretc_exists = TRUE; etc_exists = FALSE; }