mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
sysroot: Update some code to use fstatat_allow_noent API
It's much easier to read and use correctly. Making this change since I saw an unprefixed error in an issue. Closes: #1757 Approved by: jlebon
This commit is contained in:
parent
e242033fe7
commit
5183c8f35e
@ -376,12 +376,11 @@ _ostree_sysroot_read_current_subbootversion (OstreeSysroot *self,
|
||||
|
||||
g_autofree char *ostree_bootdir_name = g_strdup_printf ("ostree/boot.%d", bootversion);
|
||||
struct stat stbuf;
|
||||
if (fstatat (self->sysroot_fd, ostree_bootdir_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
if (!glnx_fstatat_allow_noent (self->sysroot_fd, ostree_bootdir_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
|
||||
return FALSE;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
*out_subbootversion = 0;
|
||||
else
|
||||
return glnx_throw_errno (error);
|
||||
*out_subbootversion = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -499,10 +498,10 @@ read_current_bootversion (OstreeSysroot *self,
|
||||
int ret_bootversion;
|
||||
struct stat stbuf;
|
||||
|
||||
if (fstatat (self->sysroot_fd, "boot/loader", &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
if (!glnx_fstatat_allow_noent (self->sysroot_fd, "boot/loader", &stbuf, AT_SYMLINK_NOFOLLOW, error))
|
||||
return FALSE;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
return glnx_throw_errno (error);
|
||||
ret_bootversion = 0;
|
||||
}
|
||||
else
|
||||
@ -976,11 +975,12 @@ ostree_sysroot_load_if_changed (OstreeSysroot *self,
|
||||
/* Otherwise - check for /sysroot which should only exist in a deployment,
|
||||
* not in ${sysroot} (a metavariable for the real physical root).
|
||||
*/
|
||||
else if (fstatat (self->sysroot_fd, "sysroot", &stbuf, 0) < 0)
|
||||
else
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
return glnx_throw_errno_prefix (error, "fstatat");
|
||||
self->is_physical = TRUE;
|
||||
if (!glnx_fstatat_allow_noent (self->sysroot_fd, "sysroot", &stbuf, 0, error))
|
||||
return FALSE;
|
||||
if (errno == ENOENT)
|
||||
self->is_physical = TRUE;
|
||||
}
|
||||
/* Otherwise, the default is FALSE */
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user