GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
-
/* We may be writing as root to a non-root-owned repository; if so,
* automatically inherit the non-root ownership.
*/
if (fd != -1)
{
if (fchown (fd, self->target_owner_uid, self->target_owner_gid) < 0)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "fchown");
}
else if (G_UNLIKELY (fchownat (self->tmp_dir_fd, temp_filename,
self->target_owner_uid,
self->target_owner_gid,
AT_SYMLINK_NOFOLLOW) == -1))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "fchownat");
}
/* Special handling for symlinks in bare repositories */
if (G_UNLIKELY (fchownat (self->tmp_dir_fd, temp_filename,
uid, gid,
AT_SYMLINK_NOFOLLOW) == -1))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "fchownat");
if (xattrs != NULL)
{
ot_security_smack_reset_dfd_name (self->tmp_dir_fd, temp_filename);
if (!glnx_dfd_name_set_all_xattrs (self->tmp_dir_fd, temp_filename,
xattrs, cancellable, error))
- goto out;
+ return FALSE;
}
}
else
{
- int res;
-
if (objtype == OSTREE_OBJECT_TYPE_FILE && self->mode == OSTREE_REPO_MODE_BARE)
{
- do
- res = fchown (fd, uid, gid);
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (G_UNLIKELY (res == -1))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (TEMP_FAILURE_RETRY (fchown (fd, uid, gid)) < 0)
+ return glnx_throw_errno_prefix (error, "fchown");
- do
- res = fchmod (fd, mode);
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (G_UNLIKELY (res == -1))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (TEMP_FAILURE_RETRY (fchmod (fd, mode)) < 0)
+ return glnx_throw_errno_prefix (error, "fchmod");
if (xattrs)
{
ot_security_smack_reset_fd (fd);
if (!glnx_fd_set_all_xattrs (fd, xattrs, cancellable, error))
- goto out;
+ return FALSE;
}
}
* set the modification time to OSTREE_TIMESTAMP.
*/
const struct timespec times[2] = { { OSTREE_TIMESTAMP, UTIME_OMIT }, { OSTREE_TIMESTAMP, 0} };
- do
- res = futimens (fd, times);
- while (G_UNLIKELY (res == -1 && errno == EINTR));
- if (G_UNLIKELY (res == -1))
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ if (TEMP_FAILURE_RETRY (futimens (fd, times)) < 0)
+ return glnx_throw_errno_prefix (error, "futimens");
}
/* Ensure that in case of a power cut, these files have the data we
if (!self->in_transaction && !self->disable_fsync)
{
if (fsync (fd) == -1)
- {
- glnx_set_error_from_errno (error);
- goto out;
- }
+ return glnx_throw_errno_prefix (error, "fsync");
}
}
if (!_ostree_repo_commit_loose_final (self, checksum, objtype,
self->tmp_dir_fd, fd, temp_filename,
cancellable, error))
- goto out;
-
- ret = TRUE;
- out:
- if (G_UNLIKELY (error && *error))
- g_prefix_error (error, "Writing object %s.%s: ", checksum, ostree_object_type_to_string (objtype));
- return ret;
+ return FALSE;
+
+ return TRUE;
}
typedef struct
FALSE, uid, gid, mode,
xattrs, state->fd,
cancellable, error))
- goto out;
+ {
+ g_prefix_error (error, "Writing object %s.%s: ", checksum, ostree_object_type_to_string (OSTREE_OBJECT_TYPE_FILE));
+ goto out;
+ }
}
ret = TRUE;
uid, gid, mode,
xattrs, temp_fd,
cancellable, error))
- return FALSE;
+ return glnx_prefix_error (error, "Writing object %s.%s: ", actual_checksum,
+ ostree_object_type_to_string (OSTREE_OBJECT_TYPE_FILE));
/* Clear the unlinker path, it was consumed */
tmp_unlinker.path = NULL;