diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c index 8723a44b43..27ecdb6189 100644 --- a/src/libostree/ostree-sysroot.c +++ b/src/libostree/ostree-sysroot.c @@ -474,25 +474,23 @@ remount_writable (const char *path, gboolean *did_remount, GError **error) static gboolean _ostree_sysroot_invisible (const OstreeSysroot *self, gboolean *out_val, GError **error) { - gboolean exists; - g_assert (self->sysroot_fd >= 0); g_assert (self->root_is_ostree_booted); - if (!ot_path_exists (self->sysroot_fd, "sysroot/ostree", &exists, error)) + if (!glnx_fstatat_allow_noent (self->sysroot_fd, "sysroot/ostree", NULL, 0, error)) return FALSE; - if (exists) + if (errno == 0) { *out_val = FALSE; return TRUE; } // root_is_ostree_booted is true so we can use AT_FDCWD here - if (!ot_path_exists (AT_FDCWD, OTCORE_RUN_OSTREE_PRIVATE "/sysroot-ns", &exists, error)) + if (!glnx_fstatat_allow_noent (AT_FDCWD, OTCORE_RUN_OSTREE_PRIVATE "/sysroot-ns", NULL, 0, error)) return FALSE; - if (!exists) + if (errno != 0) { *out_val = FALSE; return TRUE; diff --git a/src/libotutil/ot-fs-utils.c b/src/libotutil/ot-fs-utils.c index f986f8d75e..1e961a986c 100644 --- a/src/libotutil/ot-fs-utils.c +++ b/src/libotutil/ot-fs-utils.c @@ -277,26 +277,3 @@ ot_get_dir_size (int dfd, const char *path, guint64 blocksize, guint64 *out_size return TRUE; } - -/* Check whether a path exists */ -gboolean -ot_path_exists (int dfd, const char *path, gboolean *out_val, GError **error) -{ - g_autoptr (GError) local_error = NULL; - - struct stat stbuf; - if (glnx_fstatat (dfd, path, &stbuf, 0, &local_error)) - { - *out_val = TRUE; - return TRUE; - } - - if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) - { - *out_val = FALSE; - return TRUE; - } - - g_propagate_error (error, local_error); - return FALSE; -} diff --git a/src/libotutil/ot-fs-utils.h b/src/libotutil/ot-fs-utils.h index 52f0f6219b..7df79ba2a6 100644 --- a/src/libotutil/ot-fs-utils.h +++ b/src/libotutil/ot-fs-utils.h @@ -78,6 +78,4 @@ gboolean ot_parse_file_by_line (const char *path, gboolean (*cb) (const char *, gboolean ot_get_dir_size (int dfd, const char *path, guint64 blocksize, guint64 *out_size, GCancellable *cancellable, GError **error); -gboolean ot_path_exists (int dfd, const char *path, gboolean *out_val, GError **error); - G_END_DECLS