summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/copy.c4
-rw-r--r--src/shared/copy.h4
-rw-r--r--src/shared/util.c14
-rw-r--r--src/shared/util.h4
4 files changed, 17 insertions, 9 deletions
diff --git a/src/shared/copy.c b/src/shared/copy.c
index b681f6f109..0239a58066 100644
--- a/src/shared/copy.c
+++ b/src/shared/copy.c
@@ -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;
diff --git a/src/shared/copy.h b/src/shared/copy.h
index e4e3079120..8de0cfba32 100644
--- a/src/shared/copy.h
+++ b/src/shared/copy.h
@@ -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);
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;
diff --git a/src/shared/util.h b/src/shared/util.h
index 850019ab9d..e58a17a825 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -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 })