chiark / gitweb /
util: the chattr flags field is actually unsigned, judging by kernel sources
authorLennart Poettering <lennart@poettering.net>
Wed, 14 Jan 2015 01:04:17 +0000 (02:04 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 14 Jan 2015 22:18:33 +0000 (23:18 +0100)
Unlike some client code suggests...

src/shared/copy.c
src/shared/copy.h
src/shared/util.c
src/shared/util.h

index b681f6f109126b1856cfc0d6a23a4af2eac9981a..0239a58066ec3314dc004fde3a3a49cf84846e2b 100644 (file)
@@ -359,7 +359,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
         return r;
 }
 
-int copy_file(const char *from, const char *to, int flags, mode_t mode, int chattr_flags) {
+int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags) {
         int fdt, r;
 
         assert(from);
@@ -389,7 +389,7 @@ int copy_file(const char *from, const char *to, int flags, mode_t mode, int chat
         return 0;
 }
 
-int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, int chattr_flags) {
+int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags) {
         _cleanup_free_ char *t;
         int r;
 
index e4e307912096c7274de00ecb0053eadd3e21880a..8de0cfba325e75767862c106e08f53c5c01eca44 100644 (file)
@@ -25,8 +25,8 @@
 #include <sys/types.h>
 
 int copy_file_fd(const char *from, int to, bool try_reflink);
-int copy_file(const char *from, const char *to, int flags, mode_t mode, int chattr_flags);
-int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, int chattr_flags);
+int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags);
+int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags);
 int copy_tree(const char *from, const char *to, bool merge);
 int copy_tree_at(int fdf, const char *from, int fdt, const char *to, bool merge);
 int copy_directory_fd(int dirfd, const char *to, bool merge);
index 1210900bcaee61e72952e58dfe39b8b7f5e0e25a..9fd2d89556819500d9c602cce6f99a60cf45c02c 100644 (file)
@@ -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;
index 850019ab9d46e45a61c771519078bd750bab7a2a..e58a17a825b4db2a93b9e1f4d1711ad8dcb0e192 100644 (file)
@@ -1074,7 +1074,7 @@ int fd_getcrtime_at(int dirfd, const char *name, usec_t *usec, int flags);
 
 int same_fd(int a, int b);
 
-int chattr_fd(int fd, bool b, int mask);
-int chattr_path(const char *p, bool b, int mask);
+int chattr_fd(int fd, bool b, unsigned mask);
+int chattr_path(const char *p, bool b, unsigned mask);
 
 #define RLIMIT_MAKE_CONST(lim) ((struct rlimit) { lim, lim })