-Subproject commit caa51ac24ffcdffcb610bc6ccc9da964d4be74ee
+Subproject commit 01e934c18efdbac071ebc19a8a95916d324970c9
return ret;
}
-static gboolean
-ot_fallocate (int fd, goffset size, GError **error)
-{
- if (size == 0)
- return TRUE;
-
- int r = posix_fallocate (fd, 0, size);
- if (r != 0)
- {
- /* posix_fallocate is a weird deviation from errno standards */
- errno = r;
- return glnx_throw_errno_prefix (error, "fallocate");
- }
- return TRUE;
-}
-
/* Combines a check for whether or not we already have the object with
* allocating a tempfile if we don't. Used by the static delta code.
*/
&tmpf, error))
return FALSE;
- if (!ot_fallocate (tmpf.fd, length, error))
+ if (!glnx_try_fallocate (tmpf.fd, 0, length, error))
return FALSE;
if (G_IS_FILE_DESCRIPTOR_BASED (input))
if (!glnx_open_tmpfile_linkable_at (self->tmp_dir_fd, ".", O_WRONLY|O_CLOEXEC,
&tmpf, error))
return FALSE;
- if (!ot_fallocate (tmpf.fd, len, error))
+ if (!glnx_try_fallocate (tmpf.fd, 0, len, error))
return FALSE;
if (glnx_loop_write (tmpf.fd, bufp, len) < 0)
return glnx_throw_errno_prefix (error, "write()");
cancellable, error))
return FALSE;
- if (G_UNLIKELY (renameat (child_dfd_iter.fd, loose_objpath + 3,
- self->objects_dir_fd, loose_objpath) < 0))
- return glnx_throw_errno (error);
+ if (!glnx_renameat (child_dfd_iter.fd, loose_objpath + 3,
+ self->objects_dir_fd, loose_objpath, error))
+ return FALSE;
renamed_some_object = TRUE;
}
g_autoptr(GInputStream) istream = NULL;
g_autoptr(GOutputStream) out = NULL;
- if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, "/tmp", O_RDWR | O_CLOEXEC,
- &tmpf, error))
+ if (!glnx_open_anonymous_tmpfile (O_RDWR | O_CLOEXEC, &tmpf, error))
return FALSE;
if (!ostree_repo_load_file (repo, checksum, &istream, NULL, NULL,
return TRUE;
}
-static inline void
-glnx_tmpfile_clear_p (void *ptr)
-{
- GLnxTmpfile *tmpf = ptr;
- if (!tmpf)
- return;
- glnx_tmpfile_clear (tmpf);
-}
-
/**
* ostree_repo_static_delta_generate:
* @self: Repo
}
part_headers = g_variant_builder_new (G_VARIANT_TYPE ("a" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT));
- part_temp_paths = g_ptr_array_new_with_free_func (glnx_tmpfile_clear_p);
+ part_temp_paths = g_ptr_array_new_with_free_func ((GDestroyNotify)glnx_tmpfile_clear);
for (i = 0; i < builder.parts->len; i++)
{
OstreeStaticDeltaPartBuilder *part_builder = builder.parts->pdata[i];
goto out;
}
- /* Rename it into place */
- do
- res = renameat (parent_dfd, temppath, parent_dfd, newpath);
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (res == -1)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ /* Rename it into place */
+ if (!glnx_renameat (parent_dfd, temppath, parent_dfd, newpath, error))
+ goto out;
ret = TRUE;
out:
else if (etc_exists)
{
/* Compatibility hack */
- if (renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc") < 0)
- return glnx_throw_errno_prefix (error, "renameat");
+ if (!glnx_renameat (deployment_dfd, "etc", deployment_dfd, "usr/etc", error))
+ return FALSE;
usretc_exists = TRUE;
etc_exists = FALSE;
}
GError **error)
{
glnx_fd_close int boot_dfd = -1;
- int res;
g_assert ((current_bootversion == 0 && new_bootversion == 1) ||
(current_bootversion == 1 && new_bootversion == 0));
* its data is in place. Renaming now should give us atomic semantics;
* see https://bugzilla.gnome.org/show_bug.cgi?id=755595
*/
- do
- res = renameat (boot_dfd, "loader.tmp", boot_dfd, "loader");
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (res == -1)
- return glnx_throw_errno (error);
+ if (!glnx_renameat (boot_dfd, "loader.tmp", boot_dfd, "loader", error))
+ return FALSE;
/* Now we explicitly fsync this directory, even though it
* isn't required for atomicity, for two reasons: