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
This commit is contained in:
Colin Walters 2016-07-31 21:33:15 -04:00 committed by Atomic Bot
parent 52acb9d8e3
commit c671c1dd3e
2 changed files with 16 additions and 9 deletions

View File

@ -408,9 +408,11 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
*/ */
if (!ot_gfile_ensure_unlinked (self->config_path_efi, cancellable, error)) if (!ot_gfile_ensure_unlinked (self->config_path_efi, cancellable, error))
goto out; goto out;
if (!gs_file_rename (new_config_path, self->config_path_efi, if (rename (gs_file_get_path_cached (new_config_path), gs_file_get_path_cached (self->config_path_efi)) < 0)
cancellable, error)) {
goto out; glnx_set_error_from_errno (error);
goto out;
}
} }
ret = TRUE; ret = TRUE;

View File

@ -795,9 +795,12 @@ selinux_relabel_var_if_needed (OstreeSysroot *sysroot,
cancellable, error)) cancellable, error))
goto out; goto out;
if (!gs_file_rename (deployment_var_labeled_tmp, deployment_var_labeled, if (rename (gs_file_get_path_cached (deployment_var_labeled_tmp),
cancellable, error)) gs_file_get_path_cached (deployment_var_labeled)) < 0)
goto out; {
glnx_set_error_from_errno (error);
goto out;
}
} }
ret = TRUE; ret = TRUE;
@ -861,9 +864,11 @@ merge_configuration (OstreeSysroot *sysroot,
else if (etc_exists) else if (etc_exists)
{ {
/* Compatibility hack */ /* Compatibility hack */
if (!gs_file_rename (deployment_etc_path, deployment_usretc_path, if (renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc") < 0)
cancellable, error)) {
goto out; glnx_set_error_from_errno (error);
goto out;
}
usretc_exists = TRUE; usretc_exists = TRUE;
etc_exists = FALSE; etc_exists = FALSE;
} }