util: the chattr flags field is actually unsigned, judging by kernel sources

Unlike some client code suggests...
This commit is contained in:
Lennart Poettering 2015-01-14 02:04:17 +01:00
parent 679bc6cb90
commit 45030287af
4 changed files with 17 additions and 9 deletions

View 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;

View 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);

View 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;

View 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 })