Update libglnx, do some porting to new APIs
In particular I wanted to start using `GLNX_AUTO_PREFIX_ERROR`. Update submodule: libglnx Closes: #893 Approved by: jlebon
This commit is contained in:
parent
2082b3f8fb
commit
5763027b5f
2
libglnx
2
libglnx
@ -1 +1 @@
|
||||
Subproject commit 607f1775bb1c626cae1875a957a34802daebe81c
|
||||
Subproject commit 7d6a31fb9316ec85d462c26b84fb8fe9ca04ef2b
|
@ -78,18 +78,13 @@ static gboolean
|
||||
start_daemon (GDBusConnection *connection,
|
||||
GError **error)
|
||||
{
|
||||
GLNX_AUTO_PREFIX_ERROR ("Couldn't start daemon", error);
|
||||
rpm_ostree_daemon = g_initable_new (RPMOSTREED_TYPE_DAEMON,
|
||||
NULL, error,
|
||||
"connection", connection,
|
||||
"sysroot-path", opt_sysroot,
|
||||
NULL);
|
||||
if (!rpm_ostree_daemon)
|
||||
{
|
||||
g_prefix_error (error, "Couldn't start daemon: ");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return rpm_ostree_daemon != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -790,9 +790,9 @@ rpmostree_sort_pkgs_strv (const char *const* pkgs,
|
||||
g_ptr_array_add (repo_pkgs, g_strdup (*pkg));
|
||||
else
|
||||
{
|
||||
glnx_fd_close int fd = open (*pkg, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
return glnx_throw_errno_prefix (error, "can't open '%s'", *pkg);
|
||||
glnx_fd_close int fd = -1;
|
||||
if (!glnx_openat_rdonly (AT_FDCWD, *pkg, TRUE, &fd, error))
|
||||
return FALSE;
|
||||
|
||||
int idx = g_unix_fd_list_append (fd_list, fd, error);
|
||||
if (idx < 0)
|
||||
|
@ -326,19 +326,16 @@ rpmostree_bwrap_run (RpmOstreeBwrap *bwrap,
|
||||
/* Add the final NULL */
|
||||
g_ptr_array_add (bwrap->argv, NULL);
|
||||
|
||||
const char *errmsg = glnx_strjoina ("Executing bwrap(", bwrap->child_argv0, ")");
|
||||
GLNX_AUTO_PREFIX_ERROR (errmsg, error);
|
||||
|
||||
if (!g_spawn_sync (NULL, (char**)bwrap->argv->pdata, (char**) bwrap_env, G_SPAWN_SEARCH_PATH,
|
||||
bwrap_child_setup, bwrap,
|
||||
NULL, NULL, &estatus, error))
|
||||
{
|
||||
g_prefix_error (error, "Executing bwrap(%s): ", bwrap->child_argv0);
|
||||
return FALSE;
|
||||
}
|
||||
if (!g_spawn_check_exit_status (estatus, error))
|
||||
{
|
||||
g_prefix_error (error, "Executing bwrap(%s): ", bwrap->child_argv0);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1973,8 +1973,8 @@ break_single_hardlink_at (int dfd,
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if (fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
return glnx_throw_errno_prefix (error, "fstatat");
|
||||
if (!glnx_fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW, error))
|
||||
return FALSE;
|
||||
|
||||
if (!S_ISLNK (stbuf.st_mode) && !S_ISREG (stbuf.st_mode))
|
||||
return glnx_throw (error, "Unsupported type for entry '%s'", path);
|
||||
@ -2011,8 +2011,8 @@ break_single_hardlink_at (int dfd,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (renameat (dfd, path_tmp, dfd, path) != 0)
|
||||
return glnx_throw_errno_prefix (error, "rename(%s)", path);
|
||||
if (!glnx_renameat (dfd, path_tmp, dfd, path, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -2394,8 +2394,8 @@ get_package_metainfo (RpmOstreeContext *self,
|
||||
GError **error)
|
||||
{
|
||||
glnx_fd_close int metadata_fd = -1;
|
||||
if ((metadata_fd = openat (self->tmpdir_fd, path, O_RDONLY | O_CLOEXEC)) < 0)
|
||||
return glnx_throw_errno_prefix (error, "open(%s)", path);
|
||||
if (!glnx_openat_rdonly (self->tmpdir_fd, path, TRUE, &metadata_fd, error))
|
||||
return FALSE;
|
||||
|
||||
return rpmostree_unpacker_read_metainfo (metadata_fd, out_header, NULL,
|
||||
out_fi, error);
|
||||
|
@ -1095,9 +1095,9 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
|
||||
const char *usrlibfiletmp = glnx_strjoina ("usr/lib/", file, ".tmp");
|
||||
|
||||
/* Retain the current copies in /etc as backups */
|
||||
if (renameat (rootfs_dfd, usretcfile, rootfs_dfd,
|
||||
glnx_strjoina (usretcfile, ".rpmostreesave")) < 0)
|
||||
return glnx_throw_errno_prefix (error, "renameat");
|
||||
if (!glnx_renameat (rootfs_dfd, usretcfile, rootfs_dfd,
|
||||
glnx_strjoina (usretcfile, ".rpmostreesave"), error))
|
||||
return FALSE;
|
||||
|
||||
/* Copy /usr/lib/{passwd,group} -> /usr/etc (breaking hardlinks) */
|
||||
if (!glnx_file_copy_at (rootfs_dfd, usrlibfile, NULL,
|
||||
@ -1111,8 +1111,8 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
|
||||
GLNX_FILE_COPY_OVERWRITE, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (renameat (rootfs_dfd, usrlibfiletmp, rootfs_dfd, usrlibfile) < 0)
|
||||
return glnx_throw_errno_prefix (error, "renameat");
|
||||
if (!glnx_renameat (rootfs_dfd, usrlibfiletmp, rootfs_dfd, usrlibfile, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* And break hardlinks for the shadow files, since we don't have
|
||||
@ -1136,8 +1136,8 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
|
||||
rootfs_dfd, tmp, GLNX_FILE_COPY_OVERWRITE,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
if (renameat (rootfs_dfd, tmp, rootfs_dfd, src) < 0)
|
||||
return glnx_throw_errno_prefix (error, "renameat");
|
||||
if (!glnx_renameat (rootfs_dfd, tmp, rootfs_dfd, src, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -681,11 +681,8 @@ hardlink_recurse (int src_dfd,
|
||||
if (!dent)
|
||||
break;
|
||||
|
||||
if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
if (!glnx_fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (dent->d_type == DT_DIR)
|
||||
{
|
||||
|
@ -336,9 +336,9 @@ rpmostree_unpacker_new_at (int dfd, const char *path,
|
||||
RpmOstreeUnpackerFlags flags,
|
||||
GError **error)
|
||||
{
|
||||
glnx_fd_close int fd = openat (dfd, path, O_RDONLY | O_CLOEXEC | O_NOCTTY);
|
||||
if (fd < 0)
|
||||
return glnx_null_throw_errno_prefix (error, "openat(%s)", path);
|
||||
glnx_fd_close int fd = -1;
|
||||
if (!glnx_openat_rdonly (dfd, path, TRUE, &fd, error))
|
||||
return FALSE;
|
||||
|
||||
RpmOstreeUnpacker *ret = rpmostree_unpacker_new_fd (fd, pkg, flags, error);
|
||||
if (ret == NULL)
|
||||
|
@ -159,12 +159,8 @@ _rpmostree_util_update_checksum_from_file (GChecksum *checksum,
|
||||
glnx_fd_close int fd = -1;
|
||||
g_autoptr(GMappedFile) mfile = NULL;
|
||||
|
||||
fd = openat (dfd, path, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
if (!glnx_openat_rdonly (dfd, path, TRUE, &fd, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
|
||||
if (!mfile)
|
||||
|
Loading…
Reference in New Issue
Block a user