sysroot: Port some small cleanup code to fd-relative
Just a quick patch since I saw this function scroll by in Emacs and it was too ugly not to be rewritten. Closes: #510 Approved by: giuseppe
This commit is contained in:
parent
a8301b909c
commit
84a9d61e15
|
|
@ -1635,25 +1635,28 @@ cleanup_legacy_current_symlinks (OstreeSysroot *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
|
||||||
guint i;
|
guint i;
|
||||||
g_autoptr(GHashTable) created_current_for_osname =
|
g_autoptr(GString) buf = g_string_new ("");
|
||||||
g_hash_table_new (g_str_hash, g_str_equal);
|
|
||||||
|
|
||||||
for (i = 0; i < self->deployments->len; i++)
|
for (i = 0; i < self->deployments->len; i++)
|
||||||
{
|
{
|
||||||
OstreeDeployment *deployment = self->deployments->pdata[i];
|
OstreeDeployment *deployment = self->deployments->pdata[i];
|
||||||
const char *osname = ostree_deployment_get_osname (deployment);
|
const char *osname = ostree_deployment_get_osname (deployment);
|
||||||
g_autoptr(GFile) osdir = ot_gfile_resolve_path_printf (self->path, "ostree/deploy/%s", osname);
|
|
||||||
g_autoptr(GFile) legacy_link = g_file_get_child (osdir, "current");
|
|
||||||
|
|
||||||
if (!ot_gfile_ensure_unlinked (legacy_link, cancellable, error))
|
g_string_truncate (buf, 0);
|
||||||
goto out;
|
g_string_append_printf (buf, "ostree/deploy/%s/current", osname);
|
||||||
|
|
||||||
|
if (unlinkat (self->sysroot_fd, buf->str, 0) < 0)
|
||||||
|
{
|
||||||
|
if (errno != ENOENT)
|
||||||
|
{
|
||||||
|
glnx_set_error_from_errno (error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue