mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-03 05:18:24 +03:00
sysroot: Use glnx_fstatat_allow_noent, drop ot_path_exists
This commit is contained in:
parent
627b4f88df
commit
c7caee9093
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user