summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------libglnx0
-rw-r--r--src/libostree/ostree-bootloader-grub2.c2
-rw-r--r--src/libostree/ostree-bootloader-uboot.c2
-rw-r--r--src/libostree/ostree-core.c2
-rw-r--r--src/libostree/ostree-gpg-verifier.c4
-rw-r--r--src/libostree/ostree-impl-system-generator.c2
-rw-r--r--src/libostree/ostree-repo-checkout.c4
-rw-r--r--src/libostree/ostree-repo-commit.c8
-rw-r--r--src/libostree/ostree-repo-finder-mount.c4
-rw-r--r--src/libostree/ostree-repo-pull.c6
-rw-r--r--src/libostree/ostree-repo-refs.c24
-rw-r--r--src/libostree/ostree-repo-static-delta-compilation.c4
-rw-r--r--src/libostree/ostree-repo-static-delta-core.c10
-rw-r--r--src/libostree/ostree-repo-static-delta-processing.c13
-rw-r--r--src/libostree/ostree-repo.c57
-rw-r--r--src/libostree/ostree-sepolicy.c2
-rw-r--r--src/libostree/ostree-sysroot-cleanup.c2
-rw-r--r--src/libostree/ostree-sysroot-deploy.c59
-rw-r--r--src/libostree/ostree-sysroot.c12
-rw-r--r--src/libotutil/ot-fs-utils.c4
-rw-r--r--src/ostree/ostree-trivial-httpd.c2
-rw-r--r--src/ostree/ot-admin-builtin-init-fs.c2
-rw-r--r--src/ostree/ot-builtin-commit.c2
-rw-r--r--src/ostree/ot-builtin-create-usb.c2
-rw-r--r--src/ostree/ot-builtin-show.c2
-rw-r--r--src/ostree/ot-builtin-summary.c2
-rw-r--r--src/ostree/ot-remote-cookie-util.c4
-rw-r--r--src/rofiles-fuse/main.c2
-rw-r--r--tests/test-repo-finder-mount.c12
29 files changed, 115 insertions, 136 deletions
diff --git a/libglnx b/libglnx
-Subproject e30154431d7eea6397e5502b175ba3b50330140
+Subproject 5362f6bc3ff3e30f379e767b203d15c9e56d6f0
diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c
index 1366dc95..f0d34809 100644
--- a/src/libostree/ostree-bootloader-grub2.c
+++ b/src/libostree/ostree-bootloader-grub2.c
@@ -416,7 +416,7 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader,
}
/* Now let's fdatasync() for the new file */
- { glnx_fd_close int new_config_fd = -1;
+ { glnx_autofd int new_config_fd = -1;
if (!glnx_openat_rdonly (AT_FDCWD, gs_file_get_path_cached (new_config_path), TRUE, &new_config_fd, error))
return FALSE;
diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
index 81791e1c..2dbaead8 100644
--- a/src/libostree/ostree-bootloader-uboot.c
+++ b/src/libostree/ostree-bootloader-uboot.c
@@ -73,7 +73,7 @@ append_system_uenv (OstreeBootloaderUboot *self,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int uenv_fd = -1;
+ glnx_autofd int uenv_fd = -1;
__attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
const char *uenv_path = NULL;
const char *ostree_arg = NULL;
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index d840433a..733901f7 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -670,7 +670,7 @@ ostree_content_file_parse_at (gboolean compressed,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (parent_dfd, path, TRUE, &fd, error))
return FALSE;
diff --git a/src/libostree/ostree-gpg-verifier.c b/src/libostree/ostree-gpg-verifier.c
index 17655c1a..4bbf7f2d 100644
--- a/src/libostree/ostree-gpg-verifier.c
+++ b/src/libostree/ostree-gpg-verifier.c
@@ -177,7 +177,7 @@ _ostree_gpg_verifier_check_signature (OstreeGpgVerifier *self,
for (guint i = 0; i < self->key_ascii_files->len; i++)
{
const char *path = self->key_ascii_files->pdata[i];
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
g_auto(gpgme_data_t) kdata = NULL;
if (!glnx_openat_rdonly (AT_FDCWD, path, TRUE, &fd, error))
@@ -355,7 +355,7 @@ _ostree_gpg_verifier_add_keyring_dir_at (OstreeGpgVerifier *self,
if (g_str_equal (name, "secring.gpg"))
continue;
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (dfd_iter.fd, dent->d_name, TRUE, &fd, error))
return FALSE;
diff --git a/src/libostree/ostree-impl-system-generator.c b/src/libostree/ostree-impl-system-generator.c
index cc05562b..413e4f60 100644
--- a/src/libostree/ostree-impl-system-generator.c
+++ b/src/libostree/ostree-impl-system-generator.c
@@ -164,7 +164,7 @@ _ostree_impl_system_generator (const char *ostree_cmdline,
/* Prepare to write to the output unit dir; we use the "normal" dir
* that overrides /usr, but not /etc.
*/
- glnx_fd_close int normal_dir_dfd = -1;
+ glnx_autofd int normal_dir_dfd = -1;
if (!glnx_opendirat (AT_FDCWD, normal_dir, TRUE, &normal_dir_dfd, error))
return FALSE;
diff --git a/src/libostree/ostree-repo-checkout.c b/src/libostree/ostree-repo-checkout.c
index a3dd6887..99896142 100644
--- a/src/libostree/ostree-repo-checkout.c
+++ b/src/libostree/ostree-repo-checkout.c
@@ -782,7 +782,7 @@ checkout_tree_at_recurse (OstreeRepo *self,
}
}
- glnx_fd_close int destination_dfd = -1;
+ glnx_autofd int destination_dfd = -1;
if (!glnx_opendirat (destination_parent_fd, destination_name, TRUE,
&destination_dfd, error))
return FALSE;
@@ -947,7 +947,7 @@ checkout_tree_at (OstreeRepo *self,
* exists.
*/
int destination_dfd = destination_parent_fd;
- glnx_fd_close int destination_dfd_owned = -1;
+ glnx_autofd int destination_dfd_owned = -1;
if (strcmp (destination_name, ".") != 0)
{
if (mkdirat (destination_parent_fd, destination_name, 0700) < 0
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c
index d045fd3f..71aa120f 100644
--- a/src/libostree/ostree-repo-commit.c
+++ b/src/libostree/ostree-repo-commit.c
@@ -1229,7 +1229,7 @@ rename_pending_loose_objects (OstreeRepo *self,
/* Ensure that in the case of a power cut all the directory metadata that
we want has reached the disk. In particular, we want this before we
update the refs to point to these objects. */
- glnx_fd_close int target_dir_fd = -1;
+ glnx_autofd int target_dir_fd = -1;
loose_objpath[2] = 0;
@@ -2221,7 +2221,7 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
if (self->commit_stagedir.initialized)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->commit_stagedir.fd, buf, &fd, error))
return FALSE;
if (fd != -1)
@@ -2229,7 +2229,7 @@ ostree_repo_read_commit_detached_metadata (OstreeRepo *self,
out_metadata, error);
}
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->objects_dir_fd, buf, &fd, error))
return FALSE;
if (fd != -1)
@@ -3404,7 +3404,7 @@ import_one_object_direct (OstreeRepo *dest_repo,
* that basically just optionally does chown(). Perhaps
* in the future we should add flags for those things?
*/
- glnx_fd_close int src_fd = -1;
+ glnx_autofd int src_fd = -1;
if (!glnx_openat_rdonly (src_repo->objects_dir_fd, loose_path_buf,
FALSE, &src_fd, error))
return FALSE;
diff --git a/src/libostree/ostree-repo-finder-mount.c b/src/libostree/ostree-repo-finder-mount.c
index c385e70c..b41c2c8c 100644
--- a/src/libostree/ostree-repo-finder-mount.c
+++ b/src/libostree/ostree-repo-finder-mount.c
@@ -328,9 +328,9 @@ ostree_repo_finder_mount_resolve_async (OstreeRepoFinder *finde
g_autofree gchar *mount_name = NULL;
g_autoptr(GFile) mount_root = NULL;
g_autofree gchar *mount_root_path = NULL;
- glnx_fd_close int mount_root_dfd = -1;
+ glnx_autofd int mount_root_dfd = -1;
struct stat mount_root_stbuf;
- glnx_fd_close int repos_dfd = -1;
+ glnx_autofd int repos_dfd = -1;
gsize i;
g_autoptr(GHashTable) repo_to_refs = NULL; /* (element-type UriAndKeyring GHashTable) */
GHashTable *supported_ref_to_checksum; /* (element-type OstreeCollectionRef utf8) */
diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c
index 9a8c0ebf..ab69519c 100644
--- a/src/libostree/ostree-repo-pull.c
+++ b/src/libostree/ostree-repo-pull.c
@@ -547,7 +547,7 @@ write_commitpartial_for (OtPullData *pull_data,
GError **error)
{
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
- glnx_fd_close int fd = openat (pull_data->repo->repo_dir_fd, commitpartial_path, O_EXCL | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOCTTY, 0644);
+ glnx_autofd int fd = openat (pull_data->repo->repo_dir_fd, commitpartial_path, O_EXCL | O_CREAT | O_WRONLY | O_CLOEXEC | O_NOCTTY, 0644);
if (fd == -1)
{
if (errno != EEXIST)
@@ -2495,7 +2495,7 @@ _ostree_repo_load_cache_summary_if_same_sig (OstreeRepo *self,
return TRUE;
const char *summary_cache_sig_file = glnx_strjoina (_OSTREE_SUMMARY_CACHE_DIR, "/", remote, ".sig");
- glnx_fd_close int prev_fd = -1;
+ glnx_autofd int prev_fd = -1;
if (!ot_openat_ignore_enoent (self->cache_dir_fd, summary_cache_sig_file, &prev_fd, error))
return FALSE;
if (prev_fd < 0)
@@ -2508,7 +2508,7 @@ _ostree_repo_load_cache_summary_if_same_sig (OstreeRepo *self,
if (g_bytes_compare (old_sig_contents, summary_sig) == 0)
{
const char *summary_cache_file = glnx_strjoina (_OSTREE_SUMMARY_CACHE_DIR, "/", remote);
- glnx_fd_close int summary_fd = -1;
+ glnx_autofd int summary_fd = -1;
GBytes *summary_data;
diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c
index 86bdf999..b6bfb0ec 100644
--- a/src/libostree/ostree-repo-refs.c
+++ b/src/libostree/ostree-repo-refs.c
@@ -150,7 +150,7 @@ find_ref_in_remotes (OstreeRepo *self,
GError **error)
{
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
- glnx_fd_close int ret_fd = -1;
+ glnx_autofd int ret_fd = -1;
if (!glnx_dirfd_iterator_init_at (self->repo_dir_fd, "refs/remotes", TRUE, &dfd_iter, error))
return FALSE;
@@ -158,7 +158,7 @@ find_ref_in_remotes (OstreeRepo *self,
while (TRUE)
{
struct dirent *dent = NULL;
- glnx_fd_close int remote_dfd = -1;
+ glnx_autofd int remote_dfd = -1;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, NULL, error))
return FALSE;
@@ -234,7 +234,7 @@ resolve_refspec (OstreeRepo *self,
{
__attribute__((unused)) GCancellable *cancellable = NULL;
g_autofree char *ret_rev = NULL;
- glnx_fd_close int target_fd = -1;
+ glnx_autofd int target_fd = -1;
g_return_val_if_fail (ref != NULL, FALSE);
@@ -637,7 +637,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
{
if (S_ISDIR (stbuf.st_mode))
{
- glnx_fd_close int base_fd = -1;
+ glnx_autofd int base_fd = -1;
g_autoptr(GString) base_path = g_string_new ("");
if (!cut_prefix)
g_string_printf (base_path, "%s/", ref_prefix);
@@ -652,7 +652,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
}
else
{
- glnx_fd_close int prefix_dfd = -1;
+ glnx_autofd int prefix_dfd = -1;
if (!glnx_opendirat (self->repo_dir_fd, prefix_path, TRUE, &prefix_dfd, error))
return FALSE;
@@ -667,7 +667,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
{
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
g_autoptr(GString) base_path = g_string_new ("");
- glnx_fd_close int refs_heads_dfd = -1;
+ glnx_autofd int refs_heads_dfd = -1;
if (!glnx_opendirat (self->repo_dir_fd, "refs/heads", TRUE, &refs_heads_dfd, error))
return FALSE;
@@ -687,7 +687,7 @@ _ostree_repo_list_refs_internal (OstreeRepo *self,
while (TRUE)
{
struct dirent *dent;
- glnx_fd_close int remote_dfd = -1;
+ glnx_autofd int remote_dfd = -1;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&dfd_iter, &dent, cancellable, error))
return FALSE;
@@ -992,7 +992,7 @@ _ostree_repo_write_ref (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int dfd = -1;
+ glnx_autofd int dfd = -1;
g_return_val_if_fail (remote == NULL || ref->collection_id == NULL, FALSE);
g_return_val_if_fail (!(rev != NULL && alias != NULL), FALSE);
@@ -1016,7 +1016,7 @@ _ostree_repo_write_ref (OstreeRepo *self,
}
else if (remote == NULL && ref->collection_id != NULL)
{
- glnx_fd_close int refs_mirrors_dfd = -1;
+ glnx_autofd int refs_mirrors_dfd = -1;
/* refs/mirrors might not exist in older repositories, so create it. */
if (!glnx_shutil_mkdir_p_at_open (self->repo_dir_fd, "refs/mirrors", 0777,
@@ -1039,7 +1039,7 @@ _ostree_repo_write_ref (OstreeRepo *self,
}
else
{
- glnx_fd_close int refs_remotes_dfd = -1;
+ glnx_autofd int refs_remotes_dfd = -1;
if (!glnx_opendirat (self->repo_dir_fd, "refs/remotes", TRUE,
&refs_remotes_dfd, error))
@@ -1212,7 +1212,7 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
if (main_collection_id != NULL &&
(match_collection_id == NULL || g_strcmp0 (match_collection_id, main_collection_id) == 0))
{
- glnx_fd_close int refs_heads_dfd = -1;
+ glnx_autofd int refs_heads_dfd = -1;
if (!glnx_opendirat (self->repo_dir_fd, "refs/heads", TRUE, &refs_heads_dfd, error))
return FALSE;
@@ -1237,7 +1237,7 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
while (refs_dir_exists)
{
struct dirent *dent;
- glnx_fd_close int subdir_fd = -1;
+ glnx_autofd int subdir_fd = -1;
const gchar *current_collection_id;
g_autofree gchar *remote_collection_id = NULL;
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c
index a3b28470..67bfc96e 100644
--- a/src/libostree/ostree-repo-static-delta-compilation.c
+++ b/src/libostree/ostree-repo-static-delta-compilation.c
@@ -1209,12 +1209,12 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
g_autoptr(GVariant) to_commit = NULL;
const char *opt_filename;
g_autofree char *descriptor_name = NULL;
- glnx_fd_close int descriptor_dfd = -1;
+ glnx_autofd int descriptor_dfd = -1;
g_autoptr(GVariant) fallback_headers = NULL;
g_autoptr(GVariant) detached = NULL;
gboolean inline_parts;
guint endianness = G_BYTE_ORDER;
- glnx_fd_close int tmp_dfd = -1;
+ glnx_autofd int tmp_dfd = -1;
builder.parts = g_ptr_array_new_with_free_func ((GDestroyNotify)ostree_static_delta_part_builder_unref);
builder.fallback_objects = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index e5133a2b..b2595366 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -224,7 +224,7 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
const char *dir_or_file_path = gs_file_get_path_cached (dir_or_file);
/* First, try opening it as a directory */
- glnx_fd_close int dfd = glnx_opendirat_with_errno (AT_FDCWD, dir_or_file_path, TRUE);
+ glnx_autofd int dfd = glnx_opendirat_with_errno (AT_FDCWD, dir_or_file_path, TRUE);
if (dfd < 0)
{
if (errno != ENOTDIR)
@@ -241,7 +241,7 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
else
basename = g_strdup ("superblock");
- glnx_fd_close int meta_fd = openat (dfd, basename, O_RDONLY | O_CLOEXEC);
+ glnx_autofd int meta_fd = openat (dfd, basename, O_RDONLY | O_CLOEXEC);
if (meta_fd < 0)
return glnx_throw_errno_prefix (error, "openat(%s)", basename);
@@ -377,7 +377,7 @@ ostree_repo_static_delta_execute_offline (OstreeRepo *self,
else
{
g_autofree char *relpath = g_strdup_printf ("%u", i); /* TODO avoid malloc here */
- glnx_fd_close int part_fd = openat (dfd, relpath, O_RDONLY | O_CLOEXEC);
+ glnx_autofd int part_fd = openat (dfd, relpath, O_RDONLY | O_CLOEXEC);
if (part_fd < 0)
return glnx_throw_errno_prefix (error, "Opening deltapart '%s'", relpath);
@@ -525,7 +525,7 @@ show_one_part (OstreeRepo *self,
g_print ("PartMeta%u: nobjects=%u size=%" G_GUINT64_FORMAT " usize=%" G_GUINT64_FORMAT "\n",
i, (guint)(g_variant_get_size (objects) / OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN), size, usize);
- glnx_fd_close gint part_fd = openat (self->repo_dir_fd, part_path, O_RDONLY | O_CLOEXEC);
+ glnx_autofd int part_fd = openat (self->repo_dir_fd, part_path, O_RDONLY | O_CLOEXEC);
if (part_fd < 0)
return glnx_throw_errno_prefix (error, "openat(%s)", part_path);
g_autoptr(GInputStream) part_in = g_unix_input_stream_new (part_fd, FALSE);
@@ -767,7 +767,7 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
superblock_path = _ostree_get_relative_static_delta_superblock_path (from, to);
- glnx_fd_close int superblock_fd = -1;
+ glnx_autofd int superblock_fd = -1;
if (!glnx_openat_rdonly (self->repo_dir_fd, superblock_path, TRUE, &superblock_fd, error))
return FALSE;
if (!ot_variant_read_fd (superblock_fd, 0,
diff --git a/src/libostree/ostree-repo-static-delta-processing.c b/src/libostree/ostree-repo-static-delta-processing.c
index bf32e02e..6d00e79f 100644
--- a/src/libostree/ostree-repo-static-delta-processing.c
+++ b/src/libostree/ostree-repo-static-delta-processing.c
@@ -762,11 +762,7 @@ dispatch_set_read_source (OstreeRepo *repo,
GLNX_AUTO_PREFIX_ERROR("opcode set-read-source", error);
guint64 source_offset;
- if (state->read_source_fd != -1)
- {
- (void) close (state->read_source_fd);
- state->read_source_fd = -1;
- }
+ glnx_close_fd (&state->read_source_fd);
if (!read_varuint64 (state, &source_offset, error))
return FALSE;
@@ -799,12 +795,7 @@ dispatch_unset_read_source (OstreeRepo *repo,
if (state->stats_only)
return TRUE; /* Early return */
- if (state->read_source_fd != -1)
- {
- (void) close (state->read_source_fd);
- state->read_source_fd = -1;
- }
-
+ glnx_close_fd (&state->read_source_fd);
g_clear_pointer (&state->read_source_object, g_free);
return TRUE;
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 59497353..23f158d9 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -488,18 +488,13 @@ ostree_repo_finalize (GObject *object)
g_free (self->stagedir_prefix);
g_clear_object (&self->repodir_fdrel);
g_clear_object (&self->repodir);
- if (self->repo_dir_fd != -1)
- (void) close (self->repo_dir_fd);
+ glnx_close_fd (&self->repo_dir_fd);
glnx_tmpdir_unset (&self->commit_stagedir);
glnx_release_lock_file (&self->commit_stagedir_lock);
- if (self->tmp_dir_fd != -1)
- (void) close (self->tmp_dir_fd);
- if (self->cache_dir_fd != -1)
- (void) close (self->cache_dir_fd);
- if (self->objects_dir_fd != -1)
- (void) close (self->objects_dir_fd);
- if (self->uncompressed_objects_dir_fd != -1)
- (void) close (self->uncompressed_objects_dir_fd);
+ glnx_close_fd (&self->tmp_dir_fd);
+ glnx_close_fd (&self->cache_dir_fd);
+ glnx_close_fd (&self->objects_dir_fd);
+ glnx_close_fd (&self->uncompressed_objects_dir_fd);
g_clear_object (&self->sysroot_dir);
g_weak_ref_clear (&self->sysroot);
g_free (self->remotes_config_dir);
@@ -734,7 +729,7 @@ ostree_repo_open_at (int dfd,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int repo_dfd = -1;
+ glnx_autofd int repo_dfd = -1;
if (!glnx_opendirat (dfd, path, TRUE, &repo_dfd, error))
return NULL;
@@ -1463,7 +1458,7 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
gpgme_import_status_t import_status;
g_autofree char *source_tmp_dir = NULL;
g_autofree char *target_tmp_dir = NULL;
- glnx_fd_close int target_temp_fd = -1;
+ glnx_autofd int target_temp_fd = -1;
g_autoptr(GPtrArray) keys = NULL;
struct stat stbuf;
gpgme_error_t gpg_error;
@@ -1596,7 +1591,7 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
}
else if (errno == ENOENT)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
/* Create an empty pubring.gpg file prior to importing keys. This
* prevents gpg2 from creating a pubring.kbx file in the new keybox
@@ -1815,7 +1810,7 @@ repo_create_at_internal (int dfd,
return FALSE;
if (errno == 0)
{
- glnx_fd_close int repo_dfd = -1;
+ glnx_autofd int repo_dfd = -1;
if (!glnx_opendirat (dfd, path, TRUE, &repo_dfd, error))
return FALSE;
@@ -1831,7 +1826,7 @@ repo_create_at_internal (int dfd,
return glnx_throw_errno_prefix (error, "mkdirat");
}
- glnx_fd_close int repo_dfd = -1;
+ glnx_autofd int repo_dfd = -1;
if (!glnx_opendirat (dfd, path, TRUE, &repo_dfd, error))
return FALSE;
@@ -1922,7 +1917,7 @@ ostree_repo_create (OstreeRepo *self,
g_variant_builder_add (builder, "{s@v}", "collection-id",
g_variant_new_variant (g_variant_new_string (self->collection_id)));
- glnx_fd_close int repo_dir_fd = -1;
+ glnx_autofd int repo_dir_fd = -1;
if (!repo_create_at_internal (AT_FDCWD, repopath, mode,
g_variant_builder_end (builder),
&repo_dir_fd,
@@ -1966,7 +1961,7 @@ ostree_repo_create_at (int dfd,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int repo_dfd = -1;
+ glnx_autofd int repo_dfd = -1;
if (!repo_create_at_internal (dfd, path, mode, options, &repo_dfd,
cancellable, error))
return NULL;
@@ -2531,14 +2526,12 @@ ostree_repo_set_cache_dir (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- int fd;
-
+ glnx_autofd int fd = -1;
if (!glnx_opendirat (dfd, path, TRUE, &fd, error))
return FALSE;
- if (self->cache_dir_fd != -1)
- close (self->cache_dir_fd);
- self->cache_dir_fd = fd;
+ glnx_close_fd (&self->cache_dir_fd);
+ self->cache_dir_fd = glnx_steal_fd (&fd);
return TRUE;
}
@@ -2814,7 +2807,7 @@ load_metadata_internal (OstreeRepo *self,
GError **error)
{
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
g_autoptr(GInputStream) ret_stream = NULL;
g_autoptr(GVariant) ret_variant = NULL;
@@ -2932,7 +2925,7 @@ repo_load_file_archive (OstreeRepo *self,
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
_ostree_loose_path (loose_path_buf, checksum, OSTREE_OBJECT_TYPE_FILE, self->mode);
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->objects_dir_fd, loose_path_buf, &fd,
error))
return FALSE;
@@ -2988,7 +2981,7 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
}
struct stat stbuf;
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
g_autofree char *ret_symlink = NULL;
g_autoptr(GVariant) ret_xattrs = NULL;
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
@@ -3062,7 +3055,7 @@ _ostree_repo_load_file_bare (OstreeRepo *self,
ret_symlink = g_strndup (targetbuf, target_size);
}
/* In the symlink case, we don't want to return the bare-user fd */
- (void) close (glnx_steal_fd (&fd));
+ glnx_close_fd (&fd);
}
}
else if (self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY)
@@ -3138,7 +3131,7 @@ ostree_repo_load_file (OstreeRepo *self,
cancellable, error);
else
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
struct stat stbuf;
g_autofree char *symlink_target = NULL;
g_autoptr(GVariant) ret_xattrs = NULL;
@@ -4182,14 +4175,14 @@ ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (self->repo_dir_fd, "summary", TRUE, &fd, error))
return FALSE;
g_autoptr(GBytes) summary_data = ot_fd_readall_or_mmap (fd, 0, error);
if (!summary_data)
return FALSE;
/* Note that fd is reused below */
- (void) close (glnx_steal_fd (&fd));
+ glnx_close_fd (&fd);
g_autoptr(GVariant) existing_signatures = NULL;
if (!ot_openat_ignore_enoent (self->repo_dir_fd, "summary.sig", &fd, error))
@@ -4239,7 +4232,7 @@ find_keyring (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!ot_openat_ignore_enoent (self->repo_dir_fd, remote->keyring, &fd, error))
return FALSE;
@@ -4748,7 +4741,7 @@ ostree_repo_regenerate_summary (OstreeRepo *self,
return FALSE;
g_autofree char *superblock = _ostree_get_relative_static_delta_superblock_path ((from && from[0]) ? from : NULL, to);
- glnx_fd_close int superblock_file_fd = -1;
+ glnx_autofd int superblock_file_fd = -1;
if (!glnx_openat_rdonly (self->repo_dir_fd, superblock, TRUE, &superblock_file_fd, error))
return FALSE;
@@ -4965,7 +4958,7 @@ _ostree_repo_allocate_tmpdir (int tmpdir_dfd,
dent->d_type != DT_DIR)
continue;
- glnx_fd_close int target_dfd = -1;
+ glnx_autofd int target_dfd = -1;
if (!glnx_opendirat (dfd_iter.fd, dent->d_name, FALSE,
&target_dfd, &local_error))
{
diff --git a/src/libostree/ostree-sepolicy.c b/src/libostree/ostree-sepolicy.c
index ab045970..410cf194 100644
--- a/src/libostree/ostree-sepolicy.c
+++ b/src/libostree/ostree-sepolicy.c
@@ -203,7 +203,7 @@ get_policy_checksum (char **out_csum,
g_autofree char *best_policy = NULL;
int best_version = 0;
- glnx_fd_close int bindir_dfd = -1;
+ glnx_autofd int bindir_dfd = -1;
if (!glnx_opendirat (AT_FDCWD, bindir_path, TRUE, &bindir_dfd, error))
return FALSE;
diff --git a/src/libostree/ostree-sysroot-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c
index a01334e3..7a6ac1e9 100644
--- a/src/libostree/ostree-sysroot-cleanup.c
+++ b/src/libostree/ostree-sysroot-cleanup.c
@@ -282,7 +282,7 @@ cleanup_old_deployments (OstreeSysroot *self,
if (!g_hash_table_lookup (active_deployment_dirs, deployment_path))
{
struct stat stbuf;
- glnx_fd_close int deployment_fd = -1;
+ glnx_autofd int deployment_fd = -1;
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE,
&deployment_fd, error))
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 4b2f3707..c1f5af9e 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -164,7 +164,7 @@ copy_dir_recurse (int src_parent_dfd,
GError **error)
{
g_auto(GLnxDirFdIterator) src_dfd_iter = { 0, };
- glnx_fd_close int dest_dfd = -1;
+ glnx_autofd int dest_dfd = -1;
struct dirent *dent;
if (!glnx_dirfd_iterator_init_at (src_parent_dfd, name, TRUE, &src_dfd_iter, error))
@@ -226,8 +226,8 @@ ensure_directory_from_template (int orig_etc_fd,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int src_dfd = -1;
- glnx_fd_close int target_dfd = -1;
+ glnx_autofd int src_dfd = -1;
+ glnx_autofd int target_dfd = -1;
g_assert (path != NULL);
g_assert (*path != '/' && *path != '\0');
@@ -297,7 +297,7 @@ copy_modified_config_file (int orig_etc_fd,
if (!glnx_fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW, error))
return glnx_prefix_error (error, "Reading modified config file");
- glnx_fd_close int dest_parent_dfd = -1;
+ glnx_autofd int dest_parent_dfd = -1;
if (strchr (path, '/') != NULL)
{
g_autofree char *parent = g_path_get_dirname (path);
@@ -393,7 +393,7 @@ merge_configuration_from (OstreeSysroot *sysroot,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int owned_merge_deployment_dfd = -1;
+ glnx_autofd int owned_merge_deployment_dfd = -1;
const OstreeSysrootDebugFlags flags = sysroot->debug_flags;
g_assert (merge_deployment != NULL && new_deployment != NULL);
@@ -443,13 +443,13 @@ merge_configuration_from (OstreeSysroot *sysroot,
_ostree_sysroot_emit_journal_msg (sysroot, msg);
}
- glnx_fd_close int orig_etc_fd = -1;
+ glnx_autofd int orig_etc_fd = -1;
if (!glnx_opendirat (merge_deployment_dfd, "usr/etc", TRUE, &orig_etc_fd, error))
return FALSE;
- glnx_fd_close int modified_etc_fd = -1;
+ glnx_autofd int modified_etc_fd = -1;
if (!glnx_opendirat (merge_deployment_dfd, "etc", TRUE, &modified_etc_fd, error))
return FALSE;
- glnx_fd_close int new_etc_fd = -1;
+ glnx_autofd int new_etc_fd = -1;
if (!glnx_opendirat (new_deployment_dfd, "etc", TRUE, &new_etc_fd, error))
return FALSE;
@@ -508,7 +508,7 @@ checkout_deployment_tree (OstreeSysroot *sysroot,
const char *csum = ostree_deployment_get_csum (deployment);
g_autofree char *checkout_target_name = NULL;
g_autofree char *osdeploy_path = NULL;
- glnx_fd_close int osdeploy_dfd = -1;
+ glnx_autofd int osdeploy_dfd = -1;
int ret_fd;
osdeploy_path = g_strconcat ("ostree/deploy/", ostree_deployment_get_osname (deployment), "/deploy", NULL);
@@ -899,8 +899,7 @@ typedef struct {
static void
_ostree_kernel_layout_free (OstreeKernelLayout *layout)
{
- if (layout->boot_dfd != -1)
- (void) close (layout->boot_dfd);
+ glnx_close_fd (&layout->boot_dfd);
g_free (layout->kernel_srcpath);
g_free (layout->kernel_namever);
g_free (layout->initramfs_srcpath);
@@ -991,7 +990,7 @@ get_kernel_from_tree_usrlib_modules (int deployment_dfd,
/* We found a module directory, compute the checksum */
g_auto(OtChecksum) checksum = { 0, };
ot_checksum_init (&checksum);
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
/* Checksum the kernel */
if (!glnx_openat_rdonly (ret_layout->boot_dfd, "vmlinuz", TRUE, &fd, error))
return FALSE;
@@ -999,7 +998,7 @@ get_kernel_from_tree_usrlib_modules (int deployment_dfd,
if (!ot_gio_splice_update_checksum (NULL, in, &checksum, cancellable, error))
return FALSE;
g_clear_object (&in);
- (void) close (fd); fd = -1;
+ glnx_close_fd (&fd);
/* Look for an initramfs, but it's optional; since there wasn't any precedent
* for this, let's be a bit conservative and support both `initramfs.img` and
@@ -1238,8 +1237,8 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
int sockpair[2];
if (socketpair (AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sockpair) < 0)
return glnx_throw_errno_prefix (error, "socketpair");
- glnx_fd_close int sock_parent = sockpair[0];
- glnx_fd_close int sock_watchdog = sockpair[1];
+ glnx_autofd int sock_parent = sockpair[0];
+ glnx_autofd int sock_watchdog = sockpair[1];
pid_t pid = fork ();
if (pid < 0)
@@ -1249,7 +1248,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
char c = '!';
if (pid == 0) /* Child watchdog/unfreezer process. */
{
- (void) close (glnx_steal_fd (&sock_parent));
+ glnx_close_fd (&sock_parent);
/* Daemonize, and mask SIGINT/SIGTERM, so we're likely to survive e.g.
* someone doing a `systemctl restart rpm-ostreed` or a Ctrl-C of
* `ostree admin upgrade`. We don't daemonize though if testing so
@@ -1306,7 +1305,7 @@ fsfreeze_thaw_cycle (OstreeSysroot *self,
}
else /* Parent process. */
{
- (void) close (glnx_steal_fd (&sock_watchdog));
+ glnx_close_fd (&sock_watchdog);
/* Wait for the watchdog to say it's set up; mainly that it's
* masked SIGTERM successfully.
*/
@@ -1390,7 +1389,7 @@ full_system_sync (OstreeSysroot *self,
out_stats->root_syncfs_msec = (end_msec - start_msec);
start_msec = g_get_monotonic_time () / 1000;
- glnx_fd_close int boot_dfd = -1;
+ glnx_autofd int boot_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, "boot", TRUE, &boot_dfd, error))
return FALSE;
if (!fsfreeze_thaw_cycle (self, boot_dfd, cancellable, error))
@@ -1425,7 +1424,7 @@ create_new_bootlinks (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int ostree_dfd = -1;
+ glnx_autofd int ostree_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, "ostree", TRUE, &ostree_dfd, error))
return FALSE;
@@ -1450,7 +1449,7 @@ create_new_bootlinks (OstreeSysroot *self,
if (!glnx_shutil_mkdir_p_at (ostree_dfd, ostree_subbootdir_name, 0755, cancellable, error))
return FALSE;
- glnx_fd_close int ostree_subbootdir_dfd = -1;
+ glnx_autofd int ostree_subbootdir_dfd = -1;
if (!glnx_opendirat (ostree_dfd, ostree_subbootdir_name, FALSE, &ostree_subbootdir_dfd, error))
return FALSE;
@@ -1487,7 +1486,7 @@ swap_bootlinks (OstreeSysroot *self,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int ostree_dfd = -1;
+ glnx_autofd int ostree_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, "ostree", TRUE, &ostree_dfd, error))
return FALSE;
@@ -1558,7 +1557,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
{
OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (deployment);
g_autofree char *deployment_dirpath = ostree_sysroot_get_deployment_dirpath (sysroot, deployment);
- glnx_fd_close int deployment_dfd = -1;
+ glnx_autofd int deployment_dfd = -1;
if (!glnx_opendirat (sysroot->sysroot_fd, deployment_dirpath, FALSE,
&deployment_dfd, error))
return FALSE;
@@ -1569,7 +1568,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
cancellable, error))
return FALSE;
- glnx_fd_close int boot_dfd = -1;
+ glnx_autofd int boot_dfd = -1;
if (!glnx_opendirat (sysroot->sysroot_fd, "boot", TRUE, &boot_dfd, error))
return FALSE;
@@ -1583,7 +1582,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
if (!glnx_shutil_mkdir_p_at (boot_dfd, bootcsumdir, 0775, cancellable, error))
return FALSE;
- glnx_fd_close int bootcsum_dfd = -1;
+ glnx_autofd int bootcsum_dfd = -1;
if (!glnx_opendirat (boot_dfd, bootcsumdir, TRUE, &bootcsum_dfd, error))
return FALSE;
@@ -1714,7 +1713,7 @@ install_deployment_kernel (OstreeSysroot *sysroot,
g_autofree char *options_key = _ostree_kernel_args_to_string (kargs);
ostree_bootconfig_parser_set (bootconfig, "options", options_key);
- glnx_fd_close int bootconf_dfd = -1;
+ glnx_autofd int bootconf_dfd = -1;
if (!glnx_opendirat (boot_dfd, bootconfdir, TRUE, &bootconf_dfd, error))
return FALSE;
@@ -1759,7 +1758,7 @@ swap_bootloader (OstreeSysroot *sysroot,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int boot_dfd = -1;
+ glnx_autofd int boot_dfd = -1;
g_assert ((current_bootversion == 0 && new_bootversion == 1) ||
(current_bootversion == 1 && new_bootversion == 0));
@@ -2254,7 +2253,7 @@ allocate_deployserial (OstreeSysroot *self,
g_autoptr(GPtrArray) tmp_current_deployments =
g_ptr_array_new_with_free_func (g_object_unref);
- glnx_fd_close int deploy_dfd = -1;
+ glnx_autofd int deploy_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, "ostree/deploy", TRUE, &deploy_dfd, error))
return FALSE;
@@ -2309,7 +2308,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
osname = ostree_deployment_get_osname (self->booted_deployment);
const char *osdeploypath = glnx_strjoina ("ostree/deploy/", osname);
- glnx_fd_close int os_deploy_dfd = -1;
+ glnx_autofd int os_deploy_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, osdeploypath, TRUE, &os_deploy_dfd, error))
return FALSE;
@@ -2330,7 +2329,7 @@ ostree_sysroot_deploy_tree (OstreeSysroot *self,
ostree_deployment_set_origin (new_deployment, origin);
/* Check out the userspace tree onto the filesystem */
- glnx_fd_close int deployment_dfd = -1;
+ glnx_autofd int deployment_dfd = -1;
if (!checkout_deployment_tree (self, repo, new_deployment, &deployment_dfd,
cancellable, error))
{
@@ -2476,7 +2475,7 @@ ostree_sysroot_deployment_set_mutable (OstreeSysroot *self,
return FALSE;
g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment);
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &fd, error))
return FALSE;
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
index 984e16d5..d320e220 100644
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -296,11 +296,7 @@ _ostree_sysroot_bump_mtime (OstreeSysroot *self,
void
ostree_sysroot_unload (OstreeSysroot *self)
{
- if (self->sysroot_fd != -1)
- {
- (void) close (self->sysroot_fd);
- self->sysroot_fd = -1;
- }
+ glnx_close_fd (&self->sysroot_fd);
}
/**
@@ -638,7 +634,7 @@ parse_deployment (OstreeSysroot *self,
&treecsum, &deployserial, error))
return FALSE;
- glnx_fd_close int deployment_dfd = -1;
+ glnx_autofd int deployment_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, relative_boot_link, TRUE,
&deployment_dfd, error))
return FALSE;
@@ -1438,7 +1434,7 @@ ostree_sysroot_init_osname (OstreeSysroot *self,
if (mkdirat (self->sysroot_fd, deploydir, 0777) < 0)
return glnx_throw_errno_prefix (error, "Creating %s", deploydir);
- glnx_fd_close int dfd = -1;
+ glnx_autofd int dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, deploydir, TRUE, &dfd, error))
return FALSE;
@@ -1694,7 +1690,7 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self,
return FALSE;
g_autofree char *deployment_path = ostree_sysroot_get_deployment_dirpath (self, deployment);
- glnx_fd_close int deployment_dfd = -1;
+ glnx_autofd int deployment_dfd = -1;
if (!glnx_opendirat (self->sysroot_fd, deployment_path, TRUE, &deployment_dfd, error))
return FALSE;
diff --git a/src/libotutil/ot-fs-utils.c b/src/libotutil/ot-fs-utils.c
index cad27496..0dea3a9c 100644
--- a/src/libotutil/ot-fs-utils.c
+++ b/src/libotutil/ot-fs-utils.c
@@ -79,7 +79,7 @@ ot_openat_read_stream (int dfd,
GCancellable *cancellable,
GError **error)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (dfd, path, follow, &fd, error))
return FALSE;
*out_istream = g_unix_input_stream_new (glnx_steal_fd (&fd), TRUE);
@@ -127,7 +127,7 @@ ot_dfd_iter_init_allow_noent (int dfd,
gboolean *out_exists,
GError **error)
{
- glnx_fd_close int fd = glnx_opendirat_with_errno (dfd, path, TRUE);
+ glnx_autofd int fd = glnx_opendirat_with_errno (dfd, path, TRUE);
if (fd < 0)
{
if (errno != ENOENT)
diff --git a/src/ostree/ostree-trivial-httpd.c b/src/ostree/ostree-trivial-httpd.c
index e173fc38..b9909c8e 100644
--- a/src/ostree/ostree-trivial-httpd.c
+++ b/src/ostree/ostree-trivial-httpd.c
@@ -353,7 +353,7 @@ do_get (OtTrivialHttpd *self,
if (msg->method == SOUP_METHOD_GET)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
g_autoptr(GMappedFile) mapping = NULL;
gsize buffer_length, file_size;
SoupRange *ranges;
diff --git a/src/ostree/ot-admin-builtin-init-fs.c b/src/ostree/ot-admin-builtin-init-fs.c
index c5a9781f..3ef9017f 100644
--- a/src/ostree/ot-admin-builtin-init-fs.c
+++ b/src/ostree/ot-admin-builtin-init-fs.c
@@ -57,7 +57,7 @@ ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GErr
const char *sysroot_path = argv[1];
- glnx_fd_close int root_dfd = -1;
+ glnx_autofd int root_dfd = -1;
if (!glnx_opendirat (AT_FDCWD, sysroot_path, TRUE, &root_dfd, error))
return FALSE;
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 97431062..b10e8d2d 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -501,7 +501,7 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
&filter_data, NULL);
if (opt_selinux_policy)
{
- glnx_fd_close int rootfs_dfd = -1;
+ glnx_autofd int rootfs_dfd = -1;
if (!glnx_opendirat (AT_FDCWD, opt_selinux_policy, TRUE, &rootfs_dfd, error))
{
g_prefix_error (error, "selinux-policy: ");
diff --git a/src/ostree/ot-builtin-create-usb.c b/src/ostree/ot-builtin-create-usb.c
index c77dbcba..2812f348 100644
--- a/src/ostree/ot-builtin-create-usb.c
+++ b/src/ostree/ot-builtin-create-usb.c
@@ -80,7 +80,7 @@ ostree_builtin_create_usb (int argc,
const char *mount_root_path = argv[1];
struct stat mount_root_stbuf;
- glnx_fd_close int mount_root_dfd = -1;
+ glnx_autofd int mount_root_dfd = -1;
if (!glnx_opendirat (AT_FDCWD, mount_root_path, TRUE, &mount_root_dfd, error))
return FALSE;
if (!glnx_fstat (mount_root_dfd, &mount_root_stbuf, error))
diff --git a/src/ostree/ot-builtin-show.c b/src/ostree/ot-builtin-show.c
index 3ab56eb2..c4b586b1 100644
--- a/src/ostree/ot-builtin-show.c
+++ b/src/ostree/ot-builtin-show.c
@@ -58,7 +58,7 @@ do_print_variant_generic (const GVariantType *type,
{
g_autoptr(GVariant) variant = NULL;
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (AT_FDCWD, filename, TRUE, &fd, error))
return FALSE;
if (!ot_variant_read_fd (fd, 0, type, FALSE, &variant, error))
diff --git a/src/ostree/ot-builtin-summary.c b/src/ostree/ot-builtin-summary.c
index ed9e0b3d..15998efd 100644
--- a/src/ostree/ot-builtin-summary.c
+++ b/src/ostree/ot-builtin-summary.c
@@ -217,7 +217,7 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
if (opt_raw)
flags |= OSTREE_DUMP_RAW;
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
if (!glnx_openat_rdonly (repo->repo_dir_fd, "summary", TRUE, &fd, error))
return FALSE;
summary_data = ot_fd_readall_or_mmap (fd, 0, error);
diff --git a/src/ostree/ot-remote-cookie-util.c b/src/ostree/ot-remote-cookie-util.c
index 6f7b4c2b..3baaf78c 100644
--- a/src/ostree/ot-remote-cookie-util.c
+++ b/src/ostree/ot-remote-cookie-util.c
@@ -79,7 +79,7 @@ ot_parse_cookies_at (int dfd, const char *path,
{
OtCookieParser *parser;
g_autofree char *cookies_content = NULL;
- glnx_fd_close int infd = -1;
+ glnx_autofd int infd = -1;
infd = openat (dfd, path, O_RDONLY | O_CLOEXEC);
if (infd < 0)
@@ -143,7 +143,7 @@ ot_add_cookie_at (int dfd, const char *jar_path,
const char *name, const char *value,
GError **error)
{
- glnx_fd_close int fd = openat (dfd, jar_path, O_WRONLY | O_APPEND | O_CREAT, 0644);
+ glnx_autofd int fd = openat (dfd, jar_path, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd < 0)
return glnx_throw_errno_prefix (error, "open(%s)", jar_path);
diff --git a/src/rofiles-fuse/main.c b/src/rofiles-fuse/main.c
index b80c916d..97c91b60 100644
--- a/src/rofiles-fuse/main.c
+++ b/src/rofiles-fuse/main.c
@@ -268,7 +268,7 @@ callback_chown (const char *path, uid_t uid, gid_t gid)
static int
callback_truncate (const char *path, off_t size)
{
- glnx_fd_close int fd = -1;
+ glnx_autofd int fd = -1;
path = ENSURE_RELPATH (path);
VERIFY_WRITE(path);
diff --git a/tests/test-repo-finder-mount.c b/tests/test-repo-finder-mount.c
index 10b253f7..6722f2db 100644
--- a/tests/test-repo-finder-mount.c
+++ b/tests/test-repo-finder-mount.c
@@ -154,7 +154,7 @@ assert_create_repos_dir (Fixture *fixture,
int *out_repos_dfd,
GMount **out_mount)
{
- glnx_fd_close int repos_dfd = -1;
+ glnx_autofd int repos_dfd = -1;
g_autoptr(GError) error = NULL;
g_autofree gchar *path = g_build_filename (mount_root_name, ".ostree", "repos.d", NULL);
@@ -242,7 +242,7 @@ assert_create_repo_dir (Fixture *fixture,
gchar **out_uri,
...)
{
- glnx_fd_close int ref_dfd = -1;
+ glnx_autofd int ref_dfd = -1;
g_autoptr(OstreeRepo) repo = NULL;
g_autoptr(GError) error = NULL;
va_list args;
@@ -318,9 +318,9 @@ test_repo_finder_mount_mixed_mounts (Fixture *fixture,
g_autoptr(GMount) repo1_mount = NULL;
g_autoptr(GMount) repo2_mount = NULL;
g_autoptr(GFile) non_removable_root = NULL;
- glnx_fd_close int no_repos_repos = -1;
- glnx_fd_close int repo1_repos = -1;
- glnx_fd_close int repo2_repos = -1;
+ glnx_autofd int no_repos_repos = -1;
+ glnx_autofd int repo1_repos = -1;
+ glnx_autofd int repo2_repos = -1;
g_autoptr(OstreeRepo) repo1_repo_a = NULL, repo1_repo_b = NULL;
g_autoptr(OstreeRepo) repo2_repo_a = NULL;
g_autofree gchar *repo1_repo_a_uri = NULL, *repo1_repo_b_uri = NULL;
@@ -464,7 +464,7 @@ test_repo_finder_mount_well_known (Fixture *fixture,
g_autoptr(GError) error = NULL;
g_autoptr(GList) mounts = NULL; /* (element-type OstreeMockMount) */
g_autoptr(GMount) mount = NULL;
- glnx_fd_close int repos = -1;
+ glnx_autofd int repos = -1;
g_autoptr(OstreeRepo) repo_a = NULL, repo_b = NULL;
g_autofree gchar *repo_a_uri = NULL, *repo_b_uri = NULL;
g_autofree gchar *ref_a_checksum = NULL, *ref_b_checksum = NULL;