summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-14 02:04:17 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-14 23:18:33 +0100
commit45030287af1e8e76b0feb1cfc3011a0ef2b37d0d (patch)
tree6bec1c78392af4fbe9519064a52db5c182ccc4fb /src/shared/util.c
parent679bc6cb9016715339aac4ae6b2d5371c6262935 (diff)
util: the chattr flags field is actually unsigned, judging by kernel sources
Unlike some client code suggests...
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 1210900bca..9fd2d89556 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -7758,11 +7758,14 @@ int same_fd(int a, int b) {
return fa == fb;
}
-int chattr_fd(int fd, bool b, int mask) {
- int old_attr, new_attr;
+int chattr_fd(int fd, bool b, unsigned mask) {
+ unsigned old_attr, new_attr;
assert(fd >= 0);
+ if (mask == 0)
+ return 0;
+
if (ioctl(fd, FS_IOC_GETFLAGS, &old_attr) < 0)
return -errno;
@@ -7780,9 +7783,14 @@ int chattr_fd(int fd, bool b, int mask) {
return 0;
}
-int chattr_path(const char *p, bool b, int mask) {
+int chattr_path(const char *p, bool b, unsigned mask) {
_cleanup_close_ int fd = -1;
+ assert(p);
+
+ if (mask == 0)
+ return 0;
+
fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
if (fd < 0)
return -errno;