libglnx porting: Use glnx_set_error_from_errno

⚠️ There is a notable spiked pit trap here around
`posix_fallocate()` and `errno`.  This has bit other projects,
see e.g.
7bb87460e6

Otherwise the port was straightforward.
This commit is contained in:
Colin Walters 2016-03-18 16:52:10 -04:00
parent 614483ecd1
commit d456fe5adb
13 changed files with 88 additions and 87 deletions

View File

@ -406,7 +406,7 @@ session_thread_request_uri (ThreadClosure *thread_closure,
exists = FALSE; exists = FALSE;
else else
{ {
gs_set_error_from_errno (&local_error, errno); glnx_set_error_from_errno (&local_error);
g_task_return_error (task, local_error); g_task_return_error (task, local_error);
return; return;
} }
@ -706,7 +706,7 @@ finish_stream (OstreeFetcherPendingURI *pending,
pending->out_tmpfile, pending->out_tmpfile,
&stbuf, AT_SYMLINK_NOFOLLOW) != 0) &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -922,7 +922,7 @@ on_request_sent (GObject *object,
pending->out_tmpfile, oflags, 0666); pending->out_tmpfile, oflags, 0666);
if (fd == -1) if (fd == -1)
{ {
gs_set_error_from_errno (&local_error, errno); glnx_set_error_from_errno (&local_error);
goto out; goto out;
} }
pending->out_stream = g_unix_output_stream_new (fd, TRUE); pending->out_stream = g_unix_output_stream_new (fd, TRUE);

View File

@ -73,7 +73,7 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -91,7 +91,7 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
{ {
if (errno != EEXIST) if (errno != EEXIST)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
g_prefix_error (error, "Storing file '%s': ", temp_filename); g_prefix_error (error, "Storing file '%s': ", temp_filename);
goto out; goto out;
} }
@ -144,7 +144,7 @@ write_regular_file_content (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -153,7 +153,7 @@ write_regular_file_content (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -168,7 +168,7 @@ write_regular_file_content (OstreeRepo *self,
{ {
if (fsync (fd) == -1) if (fsync (fd) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -203,7 +203,7 @@ checkout_file_from_input_at (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1) if (res == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -214,7 +214,7 @@ checkout_file_from_input_at (OstreeRepo *self,
g_file_info_get_attribute_uint32 (file_info, "unix::gid"), g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
AT_SYMLINK_NOFOLLOW) == -1)) AT_SYMLINK_NOFOLLOW) == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -242,7 +242,7 @@ checkout_file_from_input_at (OstreeRepo *self,
while (G_UNLIKELY (fd == -1 && errno == EINTR)); while (G_UNLIKELY (fd == -1 && errno == EINTR));
if (fd == -1) if (fd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
temp_out = g_unix_output_stream_new (fd, TRUE); temp_out = g_unix_output_stream_new (fd, TRUE);
@ -318,7 +318,7 @@ checkout_file_unioning_from_input_at (OstreeRepo *repo,
if (G_UNLIKELY (renameat (destination_dfd, temp_filename, if (G_UNLIKELY (renameat (destination_dfd, temp_filename,
destination_dfd, destination_name) == -1)) destination_dfd, destination_name) == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -373,7 +373,7 @@ checkout_file_hardlink (OstreeRepo *self,
else else
{ {
g_prefix_error (error, "Hardlinking %s to %s: ", loose_path, destination_name); g_prefix_error (error, "Hardlinking %s to %s: ", loose_path, destination_name);
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -650,7 +650,7 @@ checkout_tree_at (OstreeRepo *self,
did_exist = TRUE; did_exist = TRUE;
else else
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -734,7 +734,7 @@ checkout_tree_at (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -748,7 +748,7 @@ checkout_tree_at (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -764,7 +764,7 @@ checkout_tree_at (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -773,7 +773,7 @@ checkout_tree_at (OstreeRepo *self,
{ {
if (fsync (destination_dfd) == -1) if (fsync (destination_dfd) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }

View File

@ -65,10 +65,9 @@ _ostree_repo_ensure_loose_objdir_at (int dfd,
loose_prefix[2] = '\0'; loose_prefix[2] = '\0';
if (mkdirat (dfd, loose_prefix, 0777) == -1) if (mkdirat (dfd, loose_prefix, 0777) == -1)
{ {
int errsv = errno; if (G_UNLIKELY (errno != EEXIST))
if (G_UNLIKELY (errsv != EEXIST))
{ {
gs_set_error_from_errno (error, errsv); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
} }
} }
@ -118,7 +117,7 @@ write_file_metadata_to_xattr (int fd,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
g_prefix_error (error, "Unable to set xattr: "); g_prefix_error (error, "Unable to set xattr: ");
return FALSE; return FALSE;
} }
@ -155,7 +154,7 @@ _ostree_repo_commit_loose_final (OstreeRepo *self,
{ {
if (errno != EEXIST) if (errno != EEXIST)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
g_prefix_error (error, "Storing file '%s': ", temp_filename); g_prefix_error (error, "Storing file '%s': ", temp_filename);
goto out; goto out;
} }
@ -195,7 +194,7 @@ commit_loose_object_trusted (OstreeRepo *self,
self->target_owner_gid, self->target_owner_gid,
AT_SYMLINK_NOFOLLOW) == -1)) AT_SYMLINK_NOFOLLOW) == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -213,7 +212,7 @@ commit_loose_object_trusted (OstreeRepo *self,
uid, gid, uid, gid,
AT_SYMLINK_NOFOLLOW) == -1)) AT_SYMLINK_NOFOLLOW) == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -236,7 +235,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -245,7 +244,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -272,7 +271,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -294,7 +293,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -306,7 +305,7 @@ commit_loose_object_trusted (OstreeRepo *self,
{ {
if (fsync (fd) == -1) if (fsync (fd) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -453,7 +452,9 @@ fallocate_stream (GFileDescriptorBased *stream,
int r = posix_fallocate (fd, 0, size); int r = posix_fallocate (fd, 0, size);
if (r != 0) if (r != 0)
{ {
gs_set_error_from_errno (error, r); /* posix_fallocate is a weird deviation from errno standards */
errno = r;
glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -511,7 +512,7 @@ _ostree_repo_commit_untrusted_content_bare (OstreeRepo *self,
fd = openat (self->tmp_dir_fd, state->temp_filename, O_RDONLY); fd = openat (self->tmp_dir_fd, state->temp_filename, O_RDONLY);
if (fd == -1) if (fd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -844,7 +845,7 @@ write_object (OstreeRepo *self,
if (fstatat (self->tmp_dir_fd, temp_filename, &stbuf, AT_SYMLINK_NOFOLLOW) == -1) if (fstatat (self->tmp_dir_fd, temp_filename, &stbuf, AT_SYMLINK_NOFOLLOW) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -1225,7 +1226,7 @@ rename_pending_loose_objects (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1) if (res == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -1265,7 +1266,7 @@ rename_pending_loose_objects (OstreeRepo *self,
if (G_UNLIKELY (renameat (child_dfd_iter.fd, loose_objpath + 3, if (G_UNLIKELY (renameat (child_dfd_iter.fd, loose_objpath + 3,
self->objects_dir_fd, loose_objpath) < 0)) self->objects_dir_fd, loose_objpath) < 0))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -1449,7 +1450,7 @@ ostree_repo_commit_transaction (OstreeRepo *self,
if (syncfs (self->tmp_dir_fd) < 0) if (syncfs (self->tmp_dir_fd) < 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -2689,7 +2690,7 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
if (fstat (src_dfd_iter->fd, &dir_stbuf) != 0) if (fstat (src_dfd_iter->fd, &dir_stbuf) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -2745,7 +2746,7 @@ write_dfd_iter_to_mtree_internal (OstreeRepo *self,
if (fstatat (src_dfd_iter->fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) == -1) if (fstatat (src_dfd_iter->fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }

View File

@ -841,7 +841,7 @@ meta_fetch_on_complete (GObject *object,
fd = openat (_ostree_fetcher_get_dfd (fetcher), temp_path, O_RDONLY | O_CLOEXEC); fd = openat (_ostree_fetcher_get_dfd (fetcher), temp_path, O_RDONLY | O_CLOEXEC);
if (fd == -1) if (fd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }

View File

@ -465,7 +465,7 @@ get_unpacked_unlinked_content (OstreeRepo *repo,
fd = g_mkstemp (tmpname); fd = g_mkstemp (tmpname);
if (fd == -1) if (fd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
/* Doesn't need a name */ /* Doesn't need a name */

View File

@ -754,7 +754,7 @@ dispatch_write (OstreeRepo *repo,
{ {
if (lseek (state->read_source_fd, content_offset, SEEK_SET) == -1) if (lseek (state->read_source_fd, content_offset, SEEK_SET) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
while (content_size > 0) while (content_size > 0)
@ -767,7 +767,7 @@ dispatch_write (OstreeRepo *repo,
while (G_UNLIKELY (bytes_read == -1 && errno == EINTR)); while (G_UNLIKELY (bytes_read == -1 && errno == EINTR));
if (bytes_read == -1) if (bytes_read == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
if (G_UNLIKELY (bytes_read == 0)) if (G_UNLIKELY (bytes_read == 0))

View File

@ -2288,12 +2288,12 @@ ostree_repo_open (OstreeRepo *self,
if (!self->writable) if (!self->writable)
{ {
/* This is returned through ostree_repo_is_writable(). */ /* This is returned through ostree_repo_is_writable(). */
gs_set_error_from_errno (&self->writable_error, errno); glnx_set_error_from_errno (&self->writable_error);
} }
if (fstat (self->objects_dir_fd, &stbuf) != 0) if (fstat (self->objects_dir_fd, &stbuf) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -2525,7 +2525,7 @@ list_loose_objects_at (OstreeRepo *self,
d = fdopendir (dfd); d = fdopendir (dfd);
if (!d) if (!d)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -2619,7 +2619,7 @@ list_loose_objects (OstreeRepo *self,
continue; continue;
else else
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -2750,7 +2750,7 @@ query_info_for_bare_content_object (OstreeRepo *self,
ret = TRUE; ret = TRUE;
goto out; goto out;
} }
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -3100,7 +3100,7 @@ _ostree_repo_has_loose_object (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1 && errno != ENOENT) if (res == -1 && errno != ENOENT)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -3114,7 +3114,7 @@ _ostree_repo_has_loose_object (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1 && errno != ENOENT) if (res == -1 && errno != ENOENT)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -3232,7 +3232,7 @@ ostree_repo_delete_object (OstreeRepo *self,
{ {
if (G_UNLIKELY (errno != ENOENT)) if (G_UNLIKELY (errno != ENOENT))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -3243,7 +3243,7 @@ ostree_repo_delete_object (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -3379,7 +3379,7 @@ import_one_object_link (OstreeRepo *self,
ret = TRUE; ret = TRUE;
} }
else else
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -3483,7 +3483,7 @@ ostree_repo_query_object_storage_size (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -4651,7 +4651,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
superblock_file_fd = openat (self->repo_dir_fd, superblock, O_RDONLY | O_CLOEXEC); superblock_file_fd = openat (self->repo_dir_fd, superblock, O_RDONLY | O_CLOEXEC);
if (superblock_file_fd == -1) if (superblock_file_fd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -4694,7 +4694,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
{ {
if (errno != ENOENT) if (errno != ENOENT)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }

View File

@ -347,10 +347,9 @@ ostree_sepolicy_get_label (OstreeSePolicy *self,
res = selabel_lookup_raw (self->selinux_hnd, &con, relpath, unix_mode); res = selabel_lookup_raw (self->selinux_hnd, &con, relpath, unix_mode);
if (res != 0) if (res != 0)
{ {
int errsv = errno; if (errno != ENOENT)
if (errsv != ENOENT)
{ {
gs_set_error_from_errno (error, errsv); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -443,7 +442,7 @@ ostree_sepolicy_restorecon (OstreeSePolicy *self,
int res = lsetfilecon (gs_file_get_path_cached (target), label); int res = lsetfilecon (gs_file_get_path_cached (target), label);
if (res != 0) if (res != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -491,7 +490,7 @@ ostree_sepolicy_setfscreatecon (OstreeSePolicy *self,
if (setfscreatecon_raw (label) != 0) if (setfscreatecon_raw (label) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
} }

View File

@ -112,17 +112,17 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd,
if (fstat (src_dfd, &src_stbuf) != 0) if (fstat (src_dfd, &src_stbuf) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
if (fchown (dest_dfd, src_stbuf.st_uid, src_stbuf.st_gid) != 0) if (fchown (dest_dfd, src_stbuf.st_uid, src_stbuf.st_gid) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
if (fchmod (dest_dfd, src_stbuf.st_mode) != 0) if (fchmod (dest_dfd, src_stbuf.st_mode) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -150,7 +150,7 @@ copy_dir_recurse (int src_parent_dfd,
/* Create with mode 0700, we'll fchmod/fchown later */ /* Create with mode 0700, we'll fchmod/fchown later */
if (mkdirat (dest_parent_dfd, name, 0700) != 0) if (mkdirat (dest_parent_dfd, name, 0700) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -164,7 +164,7 @@ copy_dir_recurse (int src_parent_dfd,
srcd = fdopendir (src_dfd); srcd = fdopendir (src_dfd);
if (!srcd) if (!srcd)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -180,7 +180,7 @@ copy_dir_recurse (int src_parent_dfd,
if (fstatat (src_dfd, name, &child_stbuf, if (fstatat (src_dfd, name, &child_stbuf,
AT_SYMLINK_NOFOLLOW) != 0) AT_SYMLINK_NOFOLLOW) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -262,7 +262,7 @@ ensure_directory_from_template (int orig_etc_fd,
} }
else else
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
g_prefix_error (error, "mkdirat: "); g_prefix_error (error, "mkdirat: ");
goto out; goto out;
} }
@ -312,7 +312,7 @@ copy_modified_config_file (int orig_etc_fd,
if (fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW) < 0) if (fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW) < 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
g_prefix_error (error, "Failed to read modified config file '%s': ", path); g_prefix_error (error, "Failed to read modified config file '%s': ", path);
goto out; goto out;
} }
@ -330,7 +330,7 @@ copy_modified_config_file (int orig_etc_fd,
dest_parent_dfd = dup (new_etc_fd); dest_parent_dfd = dup (new_etc_fd);
if (dest_parent_dfd == -1) if (dest_parent_dfd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -343,7 +343,7 @@ copy_modified_config_file (int orig_etc_fd,
; ;
else else
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -369,7 +369,7 @@ copy_modified_config_file (int orig_etc_fd,
{ {
if (unlinkat (new_etc_fd, path, 0) < 0) if (unlinkat (new_etc_fd, path, 0) < 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -1367,7 +1367,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
{ {
if (errno != ENOENT) if (errno != ENOENT)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
else else

View File

@ -45,7 +45,7 @@ ot_gopendirat (int dfd,
int ret = ot_opendirat (dfd, path, follow); int ret = ot_opendirat (dfd, path, follow);
if (ret == -1) if (ret == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
} }
*out_fd = ret; *out_fd = ret;
@ -71,7 +71,7 @@ ot_lgetxattrat (int dfd,
while (G_UNLIKELY (bytes_read < 0 && errno == EINTR)); while (G_UNLIKELY (bytes_read < 0 && errno == EINTR));
if (G_UNLIKELY (bytes_read < 0)) if (G_UNLIKELY (bytes_read < 0))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -81,7 +81,7 @@ ot_lgetxattrat (int dfd,
while (G_UNLIKELY (real_size < 0 && errno == EINTR)); while (G_UNLIKELY (real_size < 0 && errno == EINTR));
if (G_UNLIKELY (real_size < 0)) if (G_UNLIKELY (real_size < 0))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
g_free (buf); g_free (buf);
goto out; goto out;
} }
@ -111,7 +111,7 @@ ot_lsetxattrat (int dfd,
while (G_UNLIKELY (res == -1 && errno == EINTR)); while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1)) if (G_UNLIKELY (res == -1))
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
} }
@ -134,7 +134,7 @@ ot_readlinkat_gfile_info (int dfd,
while (G_UNLIKELY (len == -1 && errno == EINTR)); while (G_UNLIKELY (len == -1 && errno == EINTR));
if (len == -1) if (len == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
targetbuf[len] = '\0'; targetbuf[len] = '\0';
@ -180,7 +180,7 @@ ot_openat_read_stream (int dfd,
while (G_UNLIKELY (fd == -1 && errno == EINTR)); while (G_UNLIKELY (fd == -1 && errno == EINTR));
if (fd == -1) if (fd == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }

View File

@ -309,7 +309,9 @@ ot_file_replace_contents_at (int dfd,
int r = posix_fallocate (fd, 0, g_bytes_get_size (contents)); int r = posix_fallocate (fd, 0, g_bytes_get_size (contents));
if (r != 0) if (r != 0)
{ {
gs_set_error_from_errno (error, r); /* posix_fallocate is a weird deviation from errno standards */
errno = r;
glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }
@ -320,7 +322,7 @@ ot_file_replace_contents_at (int dfd,
if (datasync && fdatasync (fd) != 0) if (datasync && fdatasync (fd) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -329,7 +331,7 @@ ot_file_replace_contents_at (int dfd,
if (renameat (dfd, tmpname, dfd, path) == -1) if (renameat (dfd, tmpname, dfd, path) == -1)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -429,7 +431,7 @@ ot_util_fsync_directory (GFile *dir,
if (fsync (dfd) != 0) if (fsync (dfd) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }

View File

@ -204,7 +204,7 @@ ot_util_variant_map_fd (int fd,
if (fstat (fd, &stbuf) != 0) if (fstat (fd, &stbuf) != 0)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }
@ -212,7 +212,7 @@ ot_util_variant_map_fd (int fd,
map = mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, start); map = mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, start);
if (!map) if (!map)
{ {
gs_set_error_from_errno (error, errno); glnx_set_error_from_errno (error);
goto out; goto out;
} }

View File

@ -427,10 +427,9 @@ ostree_builtin_trivial_httpd (int argc, char **argv, GCancellable *cancellable,
*/ */
if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0) if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0)
{ {
int errsv = errno; if (errno != ENOSYS)
if (errsv != ENOSYS)
{ {
gs_set_error_from_errno (error, errsv); glnx_set_error_from_errno (error);
goto out; goto out;
} }
} }