Port to libgsystem errno API, hard depend on 2014.3

This is long overdue to make it to libgsystem.  Update our dependency.
This commit is contained in:
Colin Walters 2015-01-04 21:17:11 -05:00
parent 1bcc7a8e3a
commit 1e8e070102
13 changed files with 71 additions and 84 deletions

View File

@ -42,7 +42,7 @@ AC_CHECK_HEADER([attr/xattr.h],,[AC_MSG_ERROR([You must have attr/xattr.h from l
PKG_PROG_PKG_CONFIG
GIO_DEPENDENCY="gio-unix-2.0 >= 2.36.0 libgsystem >= 2014.2"
GIO_DEPENDENCY="gio-unix-2.0 >= 2.36.0 libgsystem >= 2014.3"
PKG_CHECK_MODULES(OT_DEP_GIO_UNIX, $GIO_DEPENDENCY)
dnl 5.1.0 is an arbitrary version here

View File

@ -69,7 +69,7 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -86,7 +86,7 @@ checkout_object_for_uncompressed_cache (OstreeRepo *self,
{
if (errno != EEXIST)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
g_prefix_error (error, "Storing file '%s': ", temp_filename);
goto out;
}
@ -130,7 +130,7 @@ write_regular_file_content (OstreeRepoCheckoutMode mode,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -139,7 +139,7 @@ write_regular_file_content (OstreeRepoCheckoutMode mode,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -152,7 +152,7 @@ write_regular_file_content (OstreeRepoCheckoutMode mode,
if (fsync (fd) == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -186,7 +186,7 @@ checkout_file_from_input_at (OstreeRepoCheckoutMode mode,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -197,7 +197,7 @@ checkout_file_from_input_at (OstreeRepoCheckoutMode mode,
g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
AT_SYMLINK_NOFOLLOW) == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -225,7 +225,7 @@ checkout_file_from_input_at (OstreeRepoCheckoutMode mode,
while (G_UNLIKELY (fd == -1 && errno == EINTR));
if (fd == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
temp_out = g_unix_output_stream_new (fd, TRUE);
@ -301,7 +301,7 @@ checkout_file_unioning_from_input_at (OstreeRepoCheckoutMode mode,
if (G_UNLIKELY (renameat (destination_dfd, temp_filename,
destination_dfd, destination_name) == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -357,7 +357,7 @@ checkout_file_hardlink (OstreeRepo *self,
else
{
g_prefix_error (error, "Hardlinking %s to %s: ", loose_path, destination_name);
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -578,7 +578,7 @@ checkout_tree_at (OstreeRepo *self,
did_exist = TRUE;
else
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -663,7 +663,7 @@ checkout_tree_at (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -677,7 +677,7 @@ checkout_tree_at (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -690,7 +690,7 @@ checkout_tree_at (OstreeRepo *self,
{
if (fsync (destination_dfd) == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}

View File

@ -51,7 +51,7 @@ _ostree_repo_ensure_loose_objdir_at (int dfd,
int errsv = errno;
if (G_UNLIKELY (errsv != EEXIST))
{
ot_util_set_error_from_errno (error, errsv);
gs_set_error_from_errno (error, errsv);
return FALSE;
}
}
@ -97,7 +97,7 @@ write_file_metadata_to_xattr (int fd,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
return FALSE;
}
@ -131,7 +131,7 @@ commit_loose_object_trusted (OstreeRepo *self,
self->target_owner_gid,
AT_SYMLINK_NOFOLLOW) == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -150,7 +150,7 @@ commit_loose_object_trusted (OstreeRepo *self,
g_file_info_get_attribute_uint32 (file_info, "unix::gid"),
AT_SYMLINK_NOFOLLOW) == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -182,7 +182,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -191,7 +191,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -220,7 +220,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -242,7 +242,7 @@ commit_loose_object_trusted (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -254,7 +254,7 @@ commit_loose_object_trusted (OstreeRepo *self,
{
if (fsync (fd) == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -272,7 +272,7 @@ commit_loose_object_trusted (OstreeRepo *self,
{
if (errno != EEXIST)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
g_prefix_error (error, "Storing file '%s': ", temp_filename);
goto out;
}
@ -422,7 +422,7 @@ fallocate_stream (GFileDescriptorBased *stream,
int r = posix_fallocate (fd, 0, size);
if (r != 0)
{
ot_util_set_error_from_errno (error, r);
gs_set_error_from_errno (error, r);
goto out;
}
}

View File

@ -1287,7 +1287,7 @@ ostree_repo_open (OstreeRepo *self,
if (fstat (self->objects_dir_fd, &stbuf) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -1554,7 +1554,7 @@ list_loose_objects_at (OstreeRepo *self,
d = fdopendir (dfd);
if (!d)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -1648,7 +1648,7 @@ list_loose_objects (OstreeRepo *self,
continue;
else
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -1798,7 +1798,7 @@ query_info_for_bare_content_object (OstreeRepo *self,
ret = TRUE;
goto out;
}
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -1818,7 +1818,7 @@ query_info_for_bare_content_object (OstreeRepo *self,
while (G_UNLIKELY (len == -1 && errno == EINTR));
if (len == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
targetbuf[len] = '\0';
@ -2108,7 +2108,7 @@ _ostree_repo_has_loose_object (OstreeRepo *self,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (res == -1 && errno != ENOENT)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -2331,7 +2331,7 @@ import_one_object_link (OstreeRepo *self,
ret = TRUE;
}
else
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}

View File

@ -347,7 +347,7 @@ ostree_sepolicy_get_label (OstreeSePolicy *self,
int errsv = errno;
if (errsv != ENOENT)
{
ot_util_set_error_from_errno (error, errsv);
gs_set_error_from_errno (error, errsv);
goto out;
}
}
@ -440,7 +440,7 @@ ostree_sepolicy_restorecon (OstreeSePolicy *self,
int res = lsetfilecon (gs_file_get_path_cached (target), label);
if (res != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}

View File

@ -79,7 +79,7 @@ copy_one_file_fsync_at (int src_parent_dfd,
src_fd = openat (src_parent_dfd, name, O_RDONLY | O_NOFOLLOW | O_NOCTTY | O_NOATIME | O_CLOEXEC);
if (src_fd == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
in = g_unix_input_stream_new (src_fd, TRUE);
@ -88,7 +88,7 @@ copy_one_file_fsync_at (int src_parent_dfd,
stbuf->st_mode);
if (dest_fd == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
out = g_unix_output_stream_new (dest_fd, TRUE);
@ -98,18 +98,18 @@ copy_one_file_fsync_at (int src_parent_dfd,
if (fchown (dest_fd, stbuf->st_uid, stbuf->st_gid) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
if (fchmod (dest_fd, stbuf->st_mode) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
if (fdatasync (dest_fd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -125,20 +125,20 @@ copy_one_file_fsync_at (int src_parent_dfd,
while (G_UNLIKELY (len == -1 && errno == EINTR));
if (len == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
targetbuf[len] = '\0';
if (symlinkat (targetbuf, dest_parent_dfd, name) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
if (fchownat (dest_parent_dfd, name,
stbuf->st_uid, stbuf->st_gid,
AT_SYMLINK_NOFOLLOW) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -180,17 +180,17 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd,
if (fstat (src_dfd, &src_stbuf) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
if (fchown (dest_dfd, src_stbuf.st_uid, src_stbuf.st_gid) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
if (fchmod (dest_dfd, src_stbuf.st_mode) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -218,7 +218,7 @@ copy_dir_recurse_fsync (int src_parent_dfd,
/* Create with mode 0700, we'll fchmod/fchown later */
if (mkdirat (dest_parent_dfd, name, 0700) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -232,7 +232,7 @@ copy_dir_recurse_fsync (int src_parent_dfd,
srcd = fdopendir (src_dfd);
if (!srcd)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -248,7 +248,7 @@ copy_dir_recurse_fsync (int src_parent_dfd,
if (fstatat (src_dfd, name, &child_stbuf,
AT_SYMLINK_NOFOLLOW) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -270,7 +270,7 @@ copy_dir_recurse_fsync (int src_parent_dfd,
/* And finally, fsync the fd */
if (fsync (dest_dfd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -337,7 +337,7 @@ ensure_directory_from_template (int orig_etc_fd,
}
else
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
g_prefix_error (error, "mkdirat: ");
goto out;
}
@ -387,7 +387,7 @@ copy_modified_config_file (int orig_etc_fd,
if (fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW) < 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
g_prefix_error (error, "Failed to read modified config file '%s': ", path);
goto out;
}
@ -405,7 +405,7 @@ copy_modified_config_file (int orig_etc_fd,
dest_parent_dfd = dup (new_etc_fd);
if (dest_parent_dfd == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -418,7 +418,7 @@ copy_modified_config_file (int orig_etc_fd,
;
else
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -444,7 +444,7 @@ copy_modified_config_file (int orig_etc_fd,
{
if (unlinkat (new_etc_fd, path, 0) < 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -472,7 +472,7 @@ copy_modified_config_file (int orig_etc_fd,
if (fsync (dest_parent_dfd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}

View File

@ -43,7 +43,7 @@ ot_gopendirat (int dfd,
int ret = ot_opendirat (dfd, path, follow);
if (ret == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
return FALSE;
}
*out_fd = ret;
@ -69,7 +69,7 @@ ot_lgetxattrat (int dfd,
while (G_UNLIKELY (bytes_read < 0 && errno == EINTR));
if (G_UNLIKELY (bytes_read < 0))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -79,7 +79,7 @@ ot_lgetxattrat (int dfd,
while (G_UNLIKELY (real_size < 0 && errno == EINTR));
if (G_UNLIKELY (real_size < 0))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
g_free (buf);
goto out;
}
@ -109,7 +109,7 @@ ot_lsetxattrat (int dfd,
while (G_UNLIKELY (res == -1 && errno == EINTR));
if (G_UNLIKELY (res == -1))
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
return FALSE;
}

View File

@ -315,7 +315,7 @@ ot_gfile_replace_contents_fsync (GFile *path,
int r = posix_fallocate (fd, 0, g_bytes_get_size (contents));
if (r != 0)
{
ot_util_set_error_from_errno (error, r);
gs_set_error_from_errno (error, r);
goto out;
}
}
@ -326,7 +326,7 @@ ot_gfile_replace_contents_fsync (GFile *path,
if (fdatasync (fd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -335,7 +335,7 @@ ot_gfile_replace_contents_fsync (GFile *path,
if (renameat (parent_dfd, tmpname, parent_dfd, target_basename) == -1)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -403,7 +403,7 @@ ot_util_fsync_directory (GFile *dir,
if (fsync (dfd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -519,7 +519,7 @@ ot_gfile_atomic_symlink_swap (GFile *path,
/* Ensure the link has hit disk */
if (fsync (parent_dfd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -529,7 +529,7 @@ ot_gfile_atomic_symlink_swap (GFile *path,
/* And sync again for good measure */
if (fsync (parent_dfd) != 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}

View File

@ -123,17 +123,6 @@ ot_util_path_split_validate (const char *path,
return ret;
}
void
ot_util_set_error_from_errno (GError **error,
gint saved_errno)
{
g_set_error_literal (error,
G_IO_ERROR,
g_io_error_from_errno (saved_errno),
g_strerror (saved_errno));
errno = saved_errno;
}
void
ot_util_fatal_literal (const char *msg)
{

View File

@ -44,7 +44,5 @@ gboolean ot_util_filename_validate (const char *name, GError **error);
gboolean ot_util_path_split_validate (const char *path, GPtrArray **out_components, GError **error);
void ot_util_set_error_from_errno (GError **error, gint saved_errno);
G_END_DECLS

View File

@ -188,7 +188,7 @@ ot_util_variant_map_fd (GFileDescriptorBased *stream,
g_file_descriptor_based_get_fd (stream), start);
if (!map)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}

View File

@ -71,7 +71,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GErr
goto out;
if (chmod (gs_file_get_path_cached (dir), 01777) < 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
@ -86,7 +86,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GErr
{
if (symlink ("../run", gs_file_get_path_cached (dir)) < 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}
@ -96,7 +96,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GErr
{
if (symlink ("../run/lock", gs_file_get_path_cached (dir)) < 0)
{
ot_util_set_error_from_errno (error, errno);
gs_set_error_from_errno (error, errno);
goto out;
}
}

View File

@ -423,7 +423,7 @@ ostree_builtin_trivial_httpd (int argc, char **argv, GCancellable *cancellable,
int errsv = errno;
if (errsv != ENOSYS)
{
ot_util_set_error_from_errno (error, errsv);
gs_set_error_from_errno (error, errsv);
goto out;
}
}