if (stbuf.st_nlink == 1)
{
- if (unlinkat (dfd_iter.fd, dent->d_name, 0) != 0)
- {
- glnx_set_error_from_errno (error);
- return FALSE;
- }
+ if (!glnx_unlinkat (dfd_iter.fd, dent->d_name, 0, error))
+ return FALSE;
}
}
}
GError **error)
{
g_autofree char *path = _ostree_get_commitpartial_path (checksum);
- if (unlinkat (repo->repo_dir_fd, path, 0) != 0)
- {
- if (errno != ENOENT)
- return glnx_throw_errno_prefix (error, "unlinkat");
- }
-
- return TRUE;
+ return ot_ensure_unlinked_at (repo->repo_dir_fd, path, error);
}
static gboolean
if (has_sig_suffix)
dent->d_name[len - 4] = '.';
- if (unlinkat (dfd_iter.fd, dent->d_name, 0) < 0)
- return glnx_throw_errno_prefix (error, "unlinkat");
+ if (!glnx_unlinkat (dfd_iter.fd, dent->d_name, 0, error))
+ return FALSE;
}
}
goto out;
/* From here on, if we fail to apply the delta, we'll re-fetch it */
- if (unlinkat (_ostree_fetcher_get_dfd (fetcher), temp_path, 0) < 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (!glnx_unlinkat (_ostree_fetcher_get_dfd (fetcher), temp_path, 0, error))
+ goto out;
in = g_unix_input_stream_new (fd, FALSE);
{
if (dfd >= 0)
{
- if (unlinkat (dfd, ref->ref_name, 0) != 0)
- {
- if (errno != ENOENT)
- return glnx_throw_errno (error);
- }
+ if (!ot_ensure_unlinked_at (dfd, ref->ref_name, error))
+ return FALSE;
}
}
else if (rev != NULL)
_ostree_loose_path (meta_loose, sha256, OSTREE_OBJECT_TYPE_COMMIT_META, self->mode);
- if (TEMP_FAILURE_RETRY (unlinkat (self->objects_dir_fd, meta_loose, 0)) < 0)
- {
- if (G_UNLIKELY (errno != ENOENT))
- return glnx_throw_errno_prefix (error, "unlinkat(%s)", meta_loose);
- }
+ if (!ot_ensure_unlinked_at (self->objects_dir_fd, meta_loose, error))
+ return FALSE;
}
- if (TEMP_FAILURE_RETRY (unlinkat (self->objects_dir_fd, loose_path, 0)) < 0)
- return glnx_throw_errno_prefix (error, "Deleting object %s.%s", sha256, ostree_object_type_to_string (objtype));
+ if (!glnx_unlinkat (self->objects_dir_fd, loose_path, 0, error))
+ return glnx_prefix_error (error, "Deleting object %s.%s", sha256, ostree_object_type_to_string (objtype));
/* If the repository is configured to use tombstone commits, create one when deleting a commit. */
if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
error))
return FALSE;
- if (unlinkat (self->repo_dir_fd, "summary.sig", 0) < 0)
- {
- if (errno != ENOENT)
- return glnx_throw_errno_prefix (error, "unlinkat");
- }
+ if (!ot_ensure_unlinked_at (self->repo_dir_fd, "summary.sig", error))
+ return FALSE;
return TRUE;
}
return TRUE;
}
+/* Like unlinkat() but ignore ENOENT */
gboolean
ot_ensure_unlinked_at (int dfd,
const char *path,