|
|
c0e983a |
From e4928f0ab2b16ded55316cfc44a32f542b88c81f Mon Sep 17 00:00:00 2001
|
|
|
8ac090b |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
|
8ac090b |
Date: Tue, 20 Jun 2017 15:21:07 -0400
|
|
|
c0e983a |
Subject: [PATCH 3/4] cadecoder: only try to set settable chattr bits
|
|
|
8ac090b |
|
|
|
c0e983a |
We shouldn't be trying to set bits like FS_EXTENT_FL, which chattr(1) says
|
|
|
c0e983a |
"cannot be set by chattr", i.e. presumably also not by us. Only compare
|
|
|
c0e983a |
and try to set bits which under the FS_FL_USER_MODIFIABLE mask.
|
|
|
8ac090b |
|
|
|
c0e983a |
Fixes #27.
|
|
|
8ac090b |
---
|
|
|
c0e983a |
src/cadecoder.c | 7 +++++--
|
|
|
c0e983a |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
8ac090b |
|
|
|
8ac090b |
diff --git a/src/cadecoder.c b/src/cadecoder.c
|
|
|
c0e983a |
index deba462a47..93f8ebf392 100644
|
|
|
8ac090b |
--- a/src/cadecoder.c
|
|
|
8ac090b |
+++ b/src/cadecoder.c
|
|
|
c0e983a |
@@ -3645,15 +3645,18 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo
|
|
|
c0e983a |
int new_attr, old_attr;
|
|
|
8ac090b |
|
|
|
8ac090b |
new_attr = ca_feature_flags_to_chattr(read_le64(&child->entry->flags) & d->feature_flags);
|
|
|
8ac090b |
+ assert((new_attr & ~FS_FL_USER_MODIFIABLE) == 0);
|
|
|
8ac090b |
|
|
|
8ac090b |
if (ioctl(child->fd, FS_IOC_GETFLAGS, &old_attr) < 0) {
|
|
|
8ac090b |
|
|
|
8ac090b |
if (new_attr != 0 || !IN_SET(errno, ENOTTY, ENOSYS, EBADF, EOPNOTSUPP))
|
|
|
8ac090b |
return -errno;
|
|
|
8ac090b |
|
|
|
8ac090b |
- } else if (old_attr != new_attr) {
|
|
|
8ac090b |
+ } else if ((old_attr & FS_FL_USER_MODIFIABLE) != new_attr) {
|
|
|
c0e983a |
+ int final_attr;
|
|
|
8ac090b |
|
|
|
8ac090b |
- if (ioctl(child->fd, FS_IOC_SETFLAGS, &new_attr) < 0)
|
|
|
8ac090b |
+ final_attr = (old_attr & !FS_FL_USER_MODIFIABLE) | new_attr;
|
|
|
8ac090b |
+ if (ioctl(child->fd, FS_IOC_SETFLAGS, &final_attr) < 0)
|
|
|
8ac090b |
return -errno;
|
|
|
8ac090b |
}
|
|
|
8ac090b |
}
|
|
|
8ac090b |
--
|
|
|
8ac090b |
2.13.0
|
|
|
8ac090b |
|