libglnx porting: Use glnx_shutil_rm_rf_at()

In some cases (such as `ostree-sysroot-cleanup.c`), the surrounding
code would be substantially cleaner if it was also ported to
fd-relative, but I'm going to do that in a separate patch.

That way these patches are easier to review for mechanical
correctness.  I used an Emacs keyboard macro as the poor man's
[Coccinelle](http://coccinelle.lip6.fr/).
This commit is contained in:
Colin Walters 2016-03-18 16:59:59 -04:00
parent d456fe5adb
commit 18530894c7
5 changed files with 14 additions and 14 deletions

View File

@ -1272,8 +1272,8 @@ rename_pending_loose_objects (OstreeRepo *self,
}
}
if (!gs_shutil_rm_rf_at (self->tmp_dir_fd, self->commit_stagedir_name,
cancellable, error))
if (!glnx_shutil_rm_rf_at (self->tmp_dir_fd, self->commit_stagedir_name,
cancellable, error))
goto out;
ret = TRUE;
@ -1323,7 +1323,7 @@ cleanup_tmpdir (OstreeRepo *self,
delta = curtime_secs - mtime;
if (delta > 60*60*24)
{
if (!gs_shutil_rm_rf (path, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (path), cancellable, error))
goto out;
}
}

View File

@ -236,7 +236,7 @@ ostree_repo_prune_static_deltas (OstreeRepo *self, const char *commit,
deltadir = _ostree_get_relative_static_delta_path (from, to, NULL);
if (!gs_shutil_rm_rf_at (self->repo_dir_fd, deltadir,
if (!glnx_shutil_rm_rf_at (self->repo_dir_fd, deltadir,
cancellable, error))
goto out;
}

View File

@ -255,28 +255,28 @@ cleanup_other_bootversions (OstreeSysroot *self,
cleanup_subbootversion = self->subbootversion == 0 ? 1 : 0;
cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d", cleanup_bootversion);
if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error))
goto out;
g_clear_object (&cleanup_boot_dir);
cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d", cleanup_bootversion);
if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error))
goto out;
g_clear_object (&cleanup_boot_dir);
cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.0", cleanup_bootversion);
if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error))
goto out;
g_clear_object (&cleanup_boot_dir);
cleanup_boot_dir = ot_gfile_resolve_path_printf (self->path, "ostree/boot.%d.1", cleanup_bootversion);
if (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error))
goto out;
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 (!gs_shutil_rm_rf (cleanup_boot_dir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (cleanup_boot_dir), cancellable, error))
goto out;
g_clear_object (&cleanup_boot_dir);
@ -377,7 +377,7 @@ cleanup_old_deployments (OstreeSysroot *self,
if (g_hash_table_lookup (active_boot_checksums, bootcsum))
continue;
if (!gs_shutil_rm_rf (bootdir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (bootdir), cancellable, error))
goto out;
}

View File

@ -473,7 +473,7 @@ merge_etc_changes (GFile *orig_etc,
g_assert (path);
target_file = g_file_resolve_relative_path (new_etc, path);
if (!gs_shutil_rm_rf (target_file, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (target_file), cancellable, error))
goto out;
}
@ -1821,7 +1821,7 @@ ostree_sysroot_write_deployments (OstreeSysroot *self,
new_loader_entries_dir = ot_gfile_resolve_path_printf (self->path, "boot/loader.%d/entries",
new_bootversion);
if (!gs_shutil_rm_rf (new_loader_entries_dir, cancellable, error))
if (!glnx_shutil_rm_rf_at (AT_FDCWD, gs_file_get_path_cached (new_loader_entries_dir), cancellable, error))
goto out;
if (!ot_util_ensure_directory_and_fsync (new_loader_entries_dir, cancellable, error))
goto out;

View File

@ -113,8 +113,8 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
merge_deployment = ostree_sysroot_get_merge_deployment (sysroot, opt_osname);
/* Here we perform cleanup of any leftover data from previous
* partial failures. This avoids having to call gs_shutil_rm_rf()
* at random points throughout the process.
* partial failures. This avoids having to call
* glnx_shutil_rm_rf_at() at random points throughout the process.
*
* TODO: Add /ostree/transaction file, and only do this cleanup if
* we find it.