lib/fsutil: Port to new code style

Pretty trivial.

Closes: #889
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-05-26 13:41:12 -04:00 committed by Atomic Bot
parent ff2b881275
commit 2f834968c6
1 changed files with 11 additions and 25 deletions

View File

@ -27,6 +27,8 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <ext2fs/ext2_fs.h> #include <ext2fs/ext2_fs.h>
#include "otutil.h"
/** /**
* _ostree_linuxfs_fd_alter_immutable_flag: * _ostree_linuxfs_fd_alter_immutable_flag:
* @fd: A file descriptor * @fd: A file descriptor
@ -47,29 +49,21 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE;
unsigned long flags;
int r;
static gint no_alter_immutable = 0; static gint no_alter_immutable = 0;
if (g_atomic_int_get (&no_alter_immutable)) if (g_atomic_int_get (&no_alter_immutable))
return TRUE; return TRUE;
r = ioctl (fd, EXT2_IOC_GETFLAGS, &flags); unsigned long flags;
int r = ioctl (fd, EXT2_IOC_GETFLAGS, &flags);
if (r == -1) if (r == -1)
{ {
int errsv = errno; if (errno == EPERM)
if (errsv == EPERM)
g_atomic_int_set (&no_alter_immutable, 1); g_atomic_int_set (&no_alter_immutable, 1);
else if (errsv == EOPNOTSUPP || errsv == ENOTTY) else if (errno == EOPNOTSUPP || errno == ENOTTY)
; ;
else else
{ return glnx_throw_errno_prefix (error, "ioctl(EXT2_IOC_GETFLAGS)");
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"ioctl(EXT2_IOC_GETFLAGS): %s",
g_strerror (errsv));
goto out;
}
} }
else else
{ {
@ -80,22 +74,14 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
r = ioctl (fd, EXT2_IOC_SETFLAGS, &flags); r = ioctl (fd, EXT2_IOC_SETFLAGS, &flags);
if (r == -1) if (r == -1)
{ {
int errsv = errno; if (errno == EPERM)
if (errsv == EPERM)
g_atomic_int_set (&no_alter_immutable, 1); g_atomic_int_set (&no_alter_immutable, 1);
else if (errsv == EOPNOTSUPP || errsv == ENOTTY) else if (errno == EOPNOTSUPP || errno == ENOTTY)
; ;
else else
{ return glnx_throw_errno_prefix (error, "ioctl(EXT2_IOC_SETFLAGS)");
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"ioctl(EXT2_IOC_GETFLAGS): %s",
g_strerror (errsv));
goto out;
}
} }
} }
ret = TRUE; return TRUE;
out:
return ret;
} }