[ostree] libostree: Silently ignore EPERM when setting EXT2_IMMUTABLE_FL
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] libostree: Silently ignore EPERM when setting EXT2_IMMUTABLE_FL
- Date: Mon, 9 Jun 2014 18:44:25 +0000 (UTC)
commit e31daf448afdaec9e692612ae522c7d89bf8be28
Author: Colin Walters <walters verbum org>
Date: Wed Jun 4 18:21:32 2014 -0400
libostree: Silently ignore EPERM when setting EXT2_IMMUTABLE_FL
In the case of running ostree as non-root on a regular filesystem (not
tmpfs which doesn't support immutable), we should just silently do
nothing if we encounter EPERM. Cache the result to avoid spam in
strace.
https://bugzilla.gnome.org/show_bug.cgi?id=728006
src/libostree/ostree-linuxfsutil.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/libostree/ostree-linuxfsutil.c b/src/libostree/ostree-linuxfsutil.c
index 8e11d2c..2bfc92f 100644
--- a/src/libostree/ostree-linuxfsutil.c
+++ b/src/libostree/ostree-linuxfsutil.c
@@ -38,8 +38,9 @@
* Alter the immutable flag of object referred to by @fd; may be a
* regular file or a directory.
*
- * If the operation is not supported by the underlying filesystem,
- * this function will silently do nothing.
+ * If the operation is not supported by the underlying filesystem, or
+ * we are running without sufficient privileges, this function will
+ * silently do nothing.
*/
gboolean
_ostree_linuxfs_fd_alter_immutable_flag (int fd,
@@ -50,12 +51,18 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
gboolean ret = FALSE;
unsigned long flags;
int r;
+ static gint no_alter_immutable = 0;
+
+ if (g_atomic_int_get (&no_alter_immutable))
+ return TRUE;
r = ioctl (fd, EXT2_IOC_GETFLAGS, &flags);
if (r == -1)
{
int errsv = errno;
- if (errsv == EOPNOTSUPP || errsv == ENOTTY)
+ if (errsv == EPERM)
+ g_atomic_int_set (&no_alter_immutable, 1);
+ else if (errsv == EOPNOTSUPP || errsv == ENOTTY)
;
else
{
@@ -75,7 +82,9 @@ _ostree_linuxfs_fd_alter_immutable_flag (int fd,
if (r == -1)
{
int errsv = errno;
- if (errsv == EOPNOTSUPP || errsv == ENOTTY)
+ if (errsv == EPERM)
+ g_atomic_int_set (&no_alter_immutable, 1);
+ else if (errsv == EOPNOTSUPP || errsv == ENOTTY)
;
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]