|
|
c0e983a |
From 37d5f80d3942af462ca7e88055388a16739a3b52 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 14:48:38 -0400
|
|
|
c0e983a |
Subject: [PATCH 2/4] Redefine ioctl(FS_IOC_[SG]ETFLAGS) to take an int*
|
|
|
8ac090b |
|
|
|
8ac090b |
/usr/include/linux/fs.h: #define FS_IOC_SETFLAGS _IOW('f', 2, long)
|
|
|
8ac090b |
|
|
|
c0e983a |
Apparently this is known issue [1], but a fix does not seem to be
|
|
|
c0e983a |
in sight. Let's fix it on our end, so that valgrind does not throw
|
|
|
c0e983a |
false positives:
|
|
|
8ac090b |
|
|
|
8ac090b |
==31046== Syscall param ioctl(generic) points to uninitialised byte(s)
|
|
|
8ac090b |
==31046== at 0x5BB18C7: ioctl (syscall-template.S:84)
|
|
|
8ac090b |
==31046== by 0x41B791: ca_decoder_finalize_child (cadecoder.c:3656)
|
|
|
8ac090b |
==31046== by 0x41C0BE: ca_decoder_step_node (cadecoder.c:3875)
|
|
|
8ac090b |
==31046== by 0x41C9ED: ca_decoder_step (cadecoder.c:4109)
|
|
|
8ac090b |
==31046== by 0x408496: ca_sync_step_decode (casync.c:1988)
|
|
|
8ac090b |
==31046== by 0x4094F6: ca_sync_step (casync.c:2482)
|
|
|
8ac090b |
==31046== by 0x40366B: main (test-casync.c:75)
|
|
|
8ac090b |
==31046== Address 0xffefff5fc is on thread 1's stack
|
|
|
8ac090b |
==31046== in frame #1, created by ca_decoder_finalize_child (cadecoder.c:3252)
|
|
|
c0e983a |
|
|
|
c0e983a |
While at it, let's change the internal type from unsigned to int, since that's
|
|
|
c0e983a |
what the kernel really uses.
|
|
|
c0e983a |
|
|
|
c0e983a |
[1] http://linux-fsdevel.vger.kernel.narkive.com/eUZdzNjw/argument-type-for-fs-ioc-getflags-fs-ioc-setflags-ioctls
|
|
|
8ac090b |
---
|
|
|
c0e983a |
src/cadecoder.c | 4 ++--
|
|
|
c0e983a |
src/cadecoder.h | 2 +-
|
|
|
c0e983a |
src/caencoder.c | 2 +-
|
|
|
c0e983a |
src/caencoder.h | 2 +-
|
|
|
c0e983a |
src/caformat-util.c | 4 ++--
|
|
|
c0e983a |
src/caformat-util.h | 2 +-
|
|
|
c0e983a |
src/casync-tool.c | 4 ++--
|
|
|
c0e983a |
src/casync.c | 2 +-
|
|
|
c0e983a |
src/casync.h | 2 +-
|
|
|
c0e983a |
src/util.c | 6 +++---
|
|
|
c0e983a |
src/util.h | 11 ++++++++++-
|
|
|
c0e983a |
11 files changed, 25 insertions(+), 16 deletions(-)
|
|
|
8ac090b |
|
|
|
8ac090b |
diff --git a/src/cadecoder.c b/src/cadecoder.c
|
|
|
c0e983a |
index 6a59e02968..deba462a47 100644
|
|
|
8ac090b |
--- a/src/cadecoder.c
|
|
|
8ac090b |
+++ b/src/cadecoder.c
|
|
|
8ac090b |
@@ -3642,7 +3642,7 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo
|
|
|
8ac090b |
}
|
|
|
8ac090b |
|
|
|
8ac090b |
if ((d->feature_flags & CA_FORMAT_WITH_CHATTR) != 0 && child->fd >= 0) {
|
|
|
8ac090b |
- unsigned new_attr, old_attr;
|
|
|
c0e983a |
+ int new_attr, old_attr;
|
|
|
8ac090b |
|
|
|
8ac090b |
new_attr = ca_feature_flags_to_chattr(read_le64(&child->entry->flags) & d->feature_flags);
|
|
|
8ac090b |
|
|
|
8ac090b |
@@ -4471,7 +4471,7 @@ int ca_decoder_current_rdev(CaDecoder *d, dev_t *ret) {
|
|
|
8ac090b |
return 0;
|
|
|
8ac090b |
}
|
|
|
8ac090b |
|
|
|
8ac090b |
-int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret) {
|
|
|
c0e983a |
+int ca_decoder_current_chattr(CaDecoder *d, int *ret) {
|
|
|
8ac090b |
CaDecoderNode *n;
|
|
|
8ac090b |
mode_t mode;
|
|
|
8ac090b |
|
|
|
8ac090b |
diff --git a/src/cadecoder.h b/src/cadecoder.h
|
|
|
c0e983a |
index d658676c88..48f81e7c1a 100644
|
|
|
8ac090b |
--- a/src/cadecoder.h
|
|
|
8ac090b |
+++ b/src/cadecoder.h
|
|
|
8ac090b |
@@ -89,7 +89,7 @@ int ca_decoder_current_user(CaDecoder *d, const char **user);
|
|
|
8ac090b |
int ca_decoder_current_group(CaDecoder *d, const char **user);
|
|
|
8ac090b |
int ca_decoder_current_rdev(CaDecoder *d, dev_t *ret);
|
|
|
8ac090b |
int ca_decoder_current_offset(CaDecoder *d, uint64_t *ret);
|
|
|
8ac090b |
-int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret);
|
|
|
c0e983a |
+int ca_decoder_current_chattr(CaDecoder *d, int *ret);
|
|
|
8ac090b |
int ca_decoder_current_fat_attrs(CaDecoder *d, uint32_t *ret);
|
|
|
8ac090b |
int ca_decoder_current_xattr(CaDecoder *d, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size);
|
|
|
8ac090b |
|
|
|
8ac090b |
diff --git a/src/caencoder.c b/src/caencoder.c
|
|
|
c0e983a |
index 4bea8adae9..bcae40b289 100644
|
|
|
8ac090b |
--- a/src/caencoder.c
|
|
|
8ac090b |
+++ b/src/caencoder.c
|
|
|
8ac090b |
@@ -2850,7 +2850,7 @@ int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret) {
|
|
|
8ac090b |
return 0;
|
|
|
8ac090b |
}
|
|
|
8ac090b |
|
|
|
8ac090b |
-int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret) {
|
|
|
c0e983a |
+int ca_encoder_current_chattr(CaEncoder *e, int *ret) {
|
|
|
8ac090b |
CaEncoderNode *n;
|
|
|
8ac090b |
|
|
|
8ac090b |
if (!e)
|
|
|
8ac090b |
diff --git a/src/caencoder.h b/src/caencoder.h
|
|
|
c0e983a |
index 26388261bd..e270cc0b1a 100644
|
|
|
8ac090b |
--- a/src/caencoder.h
|
|
|
8ac090b |
+++ b/src/caencoder.h
|
|
|
8ac090b |
@@ -49,7 +49,7 @@ int ca_encoder_current_gid(CaEncoder *e, gid_t *ret);
|
|
|
8ac090b |
int ca_encoder_current_user(CaEncoder *e, const char **ret);
|
|
|
8ac090b |
int ca_encoder_current_group(CaEncoder *e, const char **ret);
|
|
|
8ac090b |
int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret);
|
|
|
8ac090b |
-int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret);
|
|
|
c0e983a |
+int ca_encoder_current_chattr(CaEncoder *e, int *ret);
|
|
|
8ac090b |
int ca_encoder_current_fat_attrs(CaEncoder *e, uint32_t *ret);
|
|
|
8ac090b |
int ca_encoder_current_xattr(CaEncoder *e, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size);
|
|
|
8ac090b |
|
|
|
8ac090b |
diff --git a/src/caformat-util.c b/src/caformat-util.c
|
|
|
c0e983a |
index 332c6793a9..0b7512f353 100644
|
|
|
8ac090b |
--- a/src/caformat-util.c
|
|
|
8ac090b |
+++ b/src/caformat-util.c
|
|
|
8ac090b |
@@ -279,8 +279,8 @@ uint64_t ca_feature_flags_from_chattr(unsigned flags) {
|
|
|
8ac090b |
return f;
|
|
|
8ac090b |
}
|
|
|
8ac090b |
|
|
|
8ac090b |
-unsigned ca_feature_flags_to_chattr(uint64_t flags) {
|
|
|
8ac090b |
- unsigned f = 0;
|
|
|
c0e983a |
+int ca_feature_flags_to_chattr(uint64_t flags) {
|
|
|
c0e983a |
+ int f = 0;
|
|
|
8ac090b |
size_t i;
|
|
|
8ac090b |
|
|
|
8ac090b |
for (i = 0; i < ELEMENTSOF(chattr_map); i++)
|
|
|
8ac090b |
diff --git a/src/caformat-util.h b/src/caformat-util.h
|
|
|
c0e983a |
index 68741203fe..2e5db2bd19 100644
|
|
|
8ac090b |
--- a/src/caformat-util.h
|
|
|
8ac090b |
+++ b/src/caformat-util.h
|
|
|
8ac090b |
@@ -14,7 +14,7 @@ int ca_feature_flags_normalize(uint64_t flags, uint64_t *ret);
|
|
|
8ac090b |
int ca_feature_flags_time_granularity_nsec(uint64_t flags, uint64_t *ret);
|
|
|
8ac090b |
|
|
|
8ac090b |
uint64_t ca_feature_flags_from_chattr(unsigned flags);
|
|
|
8ac090b |
-unsigned ca_feature_flags_to_chattr(uint64_t flags);
|
|
|
c0e983a |
+int ca_feature_flags_to_chattr(uint64_t flags);
|
|
|
8ac090b |
|
|
|
8ac090b |
uint64_t ca_feature_flags_from_fat_attrs(uint32_t flags);
|
|
|
8ac090b |
uint32_t ca_feature_flags_to_fat_attrs(uint64_t flags);
|
|
|
8ac090b |
diff --git a/src/casync-tool.c b/src/casync-tool.c
|
|
|
c0e983a |
index 1650028a1a..97e33d5b5b 100644
|
|
|
8ac090b |
--- a/src/casync-tool.c
|
|
|
8ac090b |
+++ b/src/casync-tool.c
|
|
|
8ac090b |
@@ -2058,7 +2058,7 @@ static int verb_list(int argc, char *argv[]) {
|
|
|
8ac090b |
uid_t uid = UID_INVALID;
|
|
|
8ac090b |
gid_t gid = GID_INVALID;
|
|
|
8ac090b |
dev_t rdev = (dev_t) -1;
|
|
|
8ac090b |
- unsigned flags = (unsigned) -1;
|
|
|
c0e983a |
+ int flags = -1;
|
|
|
8ac090b |
uint32_t fat_attrs = (uint32_t) -1;
|
|
|
8ac090b |
char *escaped = NULL;
|
|
|
8ac090b |
const char *xname;
|
|
|
8ac090b |
@@ -2093,7 +2093,7 @@ static int verb_list(int argc, char *argv[]) {
|
|
|
8ac090b |
|
|
|
8ac090b |
escaped = mfree(escaped);
|
|
|
8ac090b |
|
|
|
8ac090b |
- if (flags != (unsigned) -1)
|
|
|
8ac090b |
+ if (flags != -1)
|
|
|
8ac090b |
printf("FileAttr: %s\n", strna(ls_format_chattr(flags, ls_flags)));
|
|
|
8ac090b |
|
|
|
8ac090b |
if (fat_attrs != (uint32_t) -1)
|
|
|
8ac090b |
diff --git a/src/casync.c b/src/casync.c
|
|
|
c0e983a |
index ceac46dc7b..c73d9396ca 100644
|
|
|
8ac090b |
--- a/src/casync.c
|
|
|
8ac090b |
+++ b/src/casync.c
|
|
|
8ac090b |
@@ -2943,7 +2943,7 @@ int ca_sync_current_rdev(CaSync *s, dev_t *ret) {
|
|
|
8ac090b |
return -ENOTTY;
|
|
|
8ac090b |
}
|
|
|
8ac090b |
|
|
|
8ac090b |
-int ca_sync_current_chattr(CaSync *s, unsigned *ret) {
|
|
|
c0e983a |
+int ca_sync_current_chattr(CaSync *s, int *ret) {
|
|
|
8ac090b |
CaSeed *seed;
|
|
|
8ac090b |
|
|
|
8ac090b |
if (!s)
|
|
|
8ac090b |
diff --git a/src/casync.h b/src/casync.h
|
|
|
c0e983a |
index 62818d13e3..afab401e01 100644
|
|
|
8ac090b |
--- a/src/casync.h
|
|
|
8ac090b |
+++ b/src/casync.h
|
|
|
8ac090b |
@@ -96,7 +96,7 @@ int ca_sync_current_group(CaSync *sync, const char **ret);
|
|
|
8ac090b |
int ca_sync_current_mtime(CaSync *sync, uint64_t *nsec);
|
|
|
8ac090b |
int ca_sync_current_size(CaSync *sync, uint64_t *ret);
|
|
|
8ac090b |
int ca_sync_current_rdev(CaSync *sync, dev_t *ret);
|
|
|
8ac090b |
-int ca_sync_current_chattr(CaSync *sync, unsigned *ret);
|
|
|
c0e983a |
+int ca_sync_current_chattr(CaSync *sync, int *ret);
|
|
|
8ac090b |
int ca_sync_current_fat_attrs(CaSync *sync, uint32_t *ret);
|
|
|
8ac090b |
int ca_sync_current_xattr(CaSync *sync, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size);
|
|
|
8ac090b |
|
|
|
8ac090b |
diff --git a/src/util.c b/src/util.c
|
|
|
c0e983a |
index b0f3138254..67e480a379 100644
|
|
|
8ac090b |
--- a/src/util.c
|
|
|
8ac090b |
+++ b/src/util.c
|
|
|
8ac090b |
@@ -672,10 +672,10 @@ char* ls_format_mode(mode_t m, char ret[LS_FORMAT_MODE_MAX]) {
|
|
|
8ac090b |
return ret;
|
|
|
8ac090b |
}
|
|
|
8ac090b |
|
|
|
8ac090b |
-char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]) {
|
|
|
c0e983a |
+char *ls_format_chattr(int flags, char ret[LS_FORMAT_CHATTR_MAX]) {
|
|
|
8ac090b |
|
|
|
8ac090b |
static const struct {
|
|
|
8ac090b |
- unsigned flag;
|
|
|
c0e983a |
+ int flag;
|
|
|
8ac090b |
char code;
|
|
|
8ac090b |
} table[] = {
|
|
|
8ac090b |
{ FS_SYNC_FL, 'S' },
|
|
|
8ac090b |
@@ -692,7 +692,7 @@ char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]) {
|
|
|
8ac090b |
|
|
|
8ac090b |
size_t i;
|
|
|
8ac090b |
|
|
|
8ac090b |
- if (flags == (unsigned) -1)
|
|
|
8ac090b |
+ if (flags == -1)
|
|
|
8ac090b |
return NULL;
|
|
|
8ac090b |
|
|
|
8ac090b |
assert(ELEMENTSOF(table) == LS_FORMAT_CHATTR_MAX-1);
|
|
|
8ac090b |
diff --git a/src/util.h b/src/util.h
|
|
|
c0e983a |
index 2d82cc2c4e..16891ec80c 100644
|
|
|
8ac090b |
--- a/src/util.h
|
|
|
8ac090b |
+++ b/src/util.h
|
|
|
c0e983a |
@@ -46,6 +46,15 @@
|
|
|
c0e983a |
UNIQ_T(A,aq) < UNIQ_T(B,bq) ? UNIQ_T(A,aq) : UNIQ_T(B,bq); \
|
|
|
c0e983a |
})
|
|
|
c0e983a |
|
|
|
c0e983a |
+
|
|
|
c0e983a |
+/* "linux/fs.h" contains wrong definitions of FS_IOC_[GS]ETFLAGS.
|
|
|
c0e983a |
+ * This problem has been known for at least 14 years. To avoid a spurious
|
|
|
c0e983a |
+ * warning from valgrind, let's override the kernel definitions. */
|
|
|
c0e983a |
+#undef FS_IOC_GETFLAGS
|
|
|
c0e983a |
+#undef FS_IOC_SETFLAGS
|
|
|
c0e983a |
+#define FS_IOC_GETFLAGS _IOR('f', 1, int)
|
|
|
c0e983a |
+#define FS_IOC_SETFLAGS _IOW('f', 2, int)
|
|
|
c0e983a |
+
|
|
|
c0e983a |
static inline uint64_t timespec_to_nsec(struct timespec t) {
|
|
|
c0e983a |
|
|
|
c0e983a |
if (t.tv_sec == (time_t) -1 &&
|
|
|
c0e983a |
@@ -285,7 +294,7 @@ char *strjoin_real(const char *x, ...) _sentinel_;
|
|
|
8ac090b |
char* ls_format_mode(mode_t m, char ret[LS_FORMAT_MODE_MAX]);
|
|
|
8ac090b |
|
|
|
8ac090b |
#define LS_FORMAT_CHATTR_MAX 11
|
|
|
8ac090b |
-char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]);
|
|
|
c0e983a |
+char *ls_format_chattr(int flags, char ret[LS_FORMAT_CHATTR_MAX]);
|
|
|
8ac090b |
|
|
|
8ac090b |
#define LS_FORMAT_FAT_ATTRS_MAX 4
|
|
|
8ac090b |
char *ls_format_fat_attrs(unsigned flags, char ret[LS_FORMAT_FAT_ATTRS_MAX]);
|
|
|
8ac090b |
--
|
|
|
8ac090b |
2.13.0
|
|
|
8ac090b |
|