From c0e983a6aef5ddab4bd0845b4ce7ea6c3f76b307 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Jun 20 2017 22:59:28 +0000 Subject: A better set of patches --- diff --git a/0001-Drop-some-unnecessary-braces.patch b/0001-Drop-some-unnecessary-braces.patch index e9f19cd..5beb4aa 100644 --- a/0001-Drop-some-unnecessary-braces.patch +++ b/0001-Drop-some-unnecessary-braces.patch @@ -1,7 +1,7 @@ -From 4455473b39039ecd151ae6012a9a0aa405468eb3 Mon Sep 17 00:00:00 2001 +From 7fd1a2ac4d1a47647b7864f765ab89054a387927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 20 Jun 2017 13:59:27 -0400 -Subject: [PATCH] Drop some unnecessary braces +Subject: [PATCH 1/4] Drop some unnecessary braces --- src/caformat-util.c | 6 ++---- diff --git a/0001-ioctl-FS_IOC_-SG-ETFLAGS-takes-a-long.patch b/0001-ioctl-FS_IOC_-SG-ETFLAGS-takes-a-long.patch deleted file mode 100644 index 7181830..0000000 --- a/0001-ioctl-FS_IOC_-SG-ETFLAGS-takes-a-long.patch +++ /dev/null @@ -1,229 +0,0 @@ -From 61339c608d8a80df8be858a6f6db4be4cda2bad4 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= -Date: Tue, 20 Jun 2017 14:48:38 -0400 -Subject: [PATCH 1/4] ioctl(FS_IOC_[SG]ETFLAGS) takes a long * -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -/usr/include/linux/fs.h: #define FS_IOC_SETFLAGS _IOW('f', 2, long) - -ioctl_list(2) is wrong… - -==31046== Syscall param ioctl(generic) points to uninitialised byte(s) -==31046== at 0x5BB18C7: ioctl (syscall-template.S:84) -==31046== by 0x41B791: ca_decoder_finalize_child (cadecoder.c:3656) -==31046== by 0x41C0BE: ca_decoder_step_node (cadecoder.c:3875) -==31046== by 0x41C9ED: ca_decoder_step (cadecoder.c:4109) -==31046== by 0x408496: ca_sync_step_decode (casync.c:1988) -==31046== by 0x4094F6: ca_sync_step (casync.c:2482) -==31046== by 0x40366B: main (test-casync.c:75) -==31046== Address 0xffefff5fc is on thread 1's stack -==31046== in frame #1, created by ca_decoder_finalize_child (cadecoder.c:3252) ---- - src/cadecoder.c | 4 ++-- - src/cadecoder.h | 2 +- - src/caencoder.c | 2 +- - src/caencoder.h | 2 +- - src/caformat-util.c | 4 ++-- - src/caformat-util.h | 2 +- - src/cafuse.c | 2 +- - src/casync-tool.c | 4 ++-- - src/casync.c | 2 +- - src/casync.h | 2 +- - src/util.c | 6 +++--- - src/util.h | 2 +- - 12 files changed, 17 insertions(+), 17 deletions(-) - -diff --git a/src/cadecoder.c b/src/cadecoder.c -index 6a59e02968..d3167348fa 100644 ---- a/src/cadecoder.c -+++ b/src/cadecoder.c -@@ -3642,7 +3642,7 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo - } - - if ((d->feature_flags & CA_FORMAT_WITH_CHATTR) != 0 && child->fd >= 0) { -- unsigned new_attr, old_attr; -+ long new_attr, old_attr; - - new_attr = ca_feature_flags_to_chattr(read_le64(&child->entry->flags) & d->feature_flags); - -@@ -4471,7 +4471,7 @@ int ca_decoder_current_rdev(CaDecoder *d, dev_t *ret) { - return 0; - } - --int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret) { -+int ca_decoder_current_chattr(CaDecoder *d, long *ret) { - CaDecoderNode *n; - mode_t mode; - -diff --git a/src/cadecoder.h b/src/cadecoder.h -index d658676c88..1ae91aa6fa 100644 ---- a/src/cadecoder.h -+++ b/src/cadecoder.h -@@ -89,7 +89,7 @@ int ca_decoder_current_user(CaDecoder *d, const char **user); - int ca_decoder_current_group(CaDecoder *d, const char **user); - int ca_decoder_current_rdev(CaDecoder *d, dev_t *ret); - int ca_decoder_current_offset(CaDecoder *d, uint64_t *ret); --int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret); -+int ca_decoder_current_chattr(CaDecoder *d, long *ret); - int ca_decoder_current_fat_attrs(CaDecoder *d, uint32_t *ret); - int ca_decoder_current_xattr(CaDecoder *d, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size); - -diff --git a/src/caencoder.c b/src/caencoder.c -index 4bea8adae9..36c8a3c9db 100644 ---- a/src/caencoder.c -+++ b/src/caencoder.c -@@ -2850,7 +2850,7 @@ int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret) { - return 0; - } - --int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret) { -+int ca_encoder_current_chattr(CaEncoder *e, long *ret) { - CaEncoderNode *n; - - if (!e) -diff --git a/src/caencoder.h b/src/caencoder.h -index 26388261bd..11c80c103c 100644 ---- a/src/caencoder.h -+++ b/src/caencoder.h -@@ -49,7 +49,7 @@ int ca_encoder_current_gid(CaEncoder *e, gid_t *ret); - int ca_encoder_current_user(CaEncoder *e, const char **ret); - int ca_encoder_current_group(CaEncoder *e, const char **ret); - int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret); --int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret); -+int ca_encoder_current_chattr(CaEncoder *e, long *ret); - int ca_encoder_current_fat_attrs(CaEncoder *e, uint32_t *ret); - int ca_encoder_current_xattr(CaEncoder *e, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size); - -diff --git a/src/caformat-util.c b/src/caformat-util.c -index 332c6793a9..e9751812a0 100644 ---- a/src/caformat-util.c -+++ b/src/caformat-util.c -@@ -279,8 +279,8 @@ uint64_t ca_feature_flags_from_chattr(unsigned flags) { - return f; - } - --unsigned ca_feature_flags_to_chattr(uint64_t flags) { -- unsigned f = 0; -+long ca_feature_flags_to_chattr(uint64_t flags) { -+ long f = 0; - size_t i; - - for (i = 0; i < ELEMENTSOF(chattr_map); i++) -diff --git a/src/caformat-util.h b/src/caformat-util.h -index 68741203fe..f46812cc25 100644 ---- a/src/caformat-util.h -+++ b/src/caformat-util.h -@@ -14,7 +14,7 @@ int ca_feature_flags_normalize(uint64_t flags, uint64_t *ret); - int ca_feature_flags_time_granularity_nsec(uint64_t flags, uint64_t *ret); - - uint64_t ca_feature_flags_from_chattr(unsigned flags); --unsigned ca_feature_flags_to_chattr(uint64_t flags); -+long ca_feature_flags_to_chattr(uint64_t flags); - - uint64_t ca_feature_flags_from_fat_attrs(uint32_t flags); - uint32_t ca_feature_flags_to_fat_attrs(uint64_t flags); -diff --git a/src/cafuse.c b/src/cafuse.c -index 5f1a22b2b4..8032e796ec 100644 ---- a/src/cafuse.c -+++ b/src/cafuse.c -@@ -505,7 +505,7 @@ static int casync_ioctl( - switch (cmd) { - - case FS_IOC_GETFLAGS: { -- unsigned chattr; -+ long chattr; - - r = ca_sync_current_chattr(instance, &chattr); - if (r < 0) -diff --git a/src/casync-tool.c b/src/casync-tool.c -index 1650028a1a..1615ff048d 100644 ---- a/src/casync-tool.c -+++ b/src/casync-tool.c -@@ -2058,7 +2058,7 @@ static int verb_list(int argc, char *argv[]) { - uid_t uid = UID_INVALID; - gid_t gid = GID_INVALID; - dev_t rdev = (dev_t) -1; -- unsigned flags = (unsigned) -1; -+ long flags = -1; - uint32_t fat_attrs = (uint32_t) -1; - char *escaped = NULL; - const char *xname; -@@ -2093,7 +2093,7 @@ static int verb_list(int argc, char *argv[]) { - - escaped = mfree(escaped); - -- if (flags != (unsigned) -1) -+ if (flags != -1) - printf("FileAttr: %s\n", strna(ls_format_chattr(flags, ls_flags))); - - if (fat_attrs != (uint32_t) -1) -diff --git a/src/casync.c b/src/casync.c -index ceac46dc7b..8989031323 100644 ---- a/src/casync.c -+++ b/src/casync.c -@@ -2943,7 +2943,7 @@ int ca_sync_current_rdev(CaSync *s, dev_t *ret) { - return -ENOTTY; - } - --int ca_sync_current_chattr(CaSync *s, unsigned *ret) { -+int ca_sync_current_chattr(CaSync *s, long *ret) { - CaSeed *seed; - - if (!s) -diff --git a/src/casync.h b/src/casync.h -index 62818d13e3..93dbba165e 100644 ---- a/src/casync.h -+++ b/src/casync.h -@@ -96,7 +96,7 @@ int ca_sync_current_group(CaSync *sync, const char **ret); - int ca_sync_current_mtime(CaSync *sync, uint64_t *nsec); - int ca_sync_current_size(CaSync *sync, uint64_t *ret); - int ca_sync_current_rdev(CaSync *sync, dev_t *ret); --int ca_sync_current_chattr(CaSync *sync, unsigned *ret); -+int ca_sync_current_chattr(CaSync *sync, long *ret); - int ca_sync_current_fat_attrs(CaSync *sync, uint32_t *ret); - int ca_sync_current_xattr(CaSync *sync, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size); - -diff --git a/src/util.c b/src/util.c -index b0f3138254..1f03c8678e 100644 ---- a/src/util.c -+++ b/src/util.c -@@ -672,10 +672,10 @@ char* ls_format_mode(mode_t m, char ret[LS_FORMAT_MODE_MAX]) { - return ret; - } - --char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]) { -+char *ls_format_chattr(long flags, char ret[LS_FORMAT_CHATTR_MAX]) { - - static const struct { -- unsigned flag; -+ long flag; - char code; - } table[] = { - { FS_SYNC_FL, 'S' }, -@@ -692,7 +692,7 @@ char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]) { - - size_t i; - -- if (flags == (unsigned) -1) -+ if (flags == -1) - return NULL; - - assert(ELEMENTSOF(table) == LS_FORMAT_CHATTR_MAX-1); -diff --git a/src/util.h b/src/util.h -index 2d82cc2c4e..e5e94b5c8a 100644 ---- a/src/util.h -+++ b/src/util.h -@@ -285,7 +285,7 @@ char *strjoin_real(const char *x, ...) _sentinel_; - char* ls_format_mode(mode_t m, char ret[LS_FORMAT_MODE_MAX]); - - #define LS_FORMAT_CHATTR_MAX 11 --char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]); -+char *ls_format_chattr(long flags, char ret[LS_FORMAT_CHATTR_MAX]); - - #define LS_FORMAT_FAT_ATTRS_MAX 4 - char *ls_format_fat_attrs(unsigned flags, char ret[LS_FORMAT_FAT_ATTRS_MAX]); --- -2.13.0 - diff --git a/0002-Redefine-ioctl-FS_IOC_-SG-ETFLAGS-to-take-an-int.patch b/0002-Redefine-ioctl-FS_IOC_-SG-ETFLAGS-to-take-an-int.patch new file mode 100644 index 0000000..b83c496 --- /dev/null +++ b/0002-Redefine-ioctl-FS_IOC_-SG-ETFLAGS-to-take-an-int.patch @@ -0,0 +1,235 @@ +From 37d5f80d3942af462ca7e88055388a16739a3b52 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 20 Jun 2017 14:48:38 -0400 +Subject: [PATCH 2/4] Redefine ioctl(FS_IOC_[SG]ETFLAGS) to take an int* + +/usr/include/linux/fs.h: #define FS_IOC_SETFLAGS _IOW('f', 2, long) + +Apparently this is known issue [1], but a fix does not seem to be +in sight. Let's fix it on our end, so that valgrind does not throw +false positives: + +==31046== Syscall param ioctl(generic) points to uninitialised byte(s) +==31046== at 0x5BB18C7: ioctl (syscall-template.S:84) +==31046== by 0x41B791: ca_decoder_finalize_child (cadecoder.c:3656) +==31046== by 0x41C0BE: ca_decoder_step_node (cadecoder.c:3875) +==31046== by 0x41C9ED: ca_decoder_step (cadecoder.c:4109) +==31046== by 0x408496: ca_sync_step_decode (casync.c:1988) +==31046== by 0x4094F6: ca_sync_step (casync.c:2482) +==31046== by 0x40366B: main (test-casync.c:75) +==31046== Address 0xffefff5fc is on thread 1's stack +==31046== in frame #1, created by ca_decoder_finalize_child (cadecoder.c:3252) + +While at it, let's change the internal type from unsigned to int, since that's +what the kernel really uses. + +[1] http://linux-fsdevel.vger.kernel.narkive.com/eUZdzNjw/argument-type-for-fs-ioc-getflags-fs-ioc-setflags-ioctls +--- + src/cadecoder.c | 4 ++-- + src/cadecoder.h | 2 +- + src/caencoder.c | 2 +- + src/caencoder.h | 2 +- + src/caformat-util.c | 4 ++-- + src/caformat-util.h | 2 +- + src/casync-tool.c | 4 ++-- + src/casync.c | 2 +- + src/casync.h | 2 +- + src/util.c | 6 +++--- + src/util.h | 11 ++++++++++- + 11 files changed, 25 insertions(+), 16 deletions(-) + +diff --git a/src/cadecoder.c b/src/cadecoder.c +index 6a59e02968..deba462a47 100644 +--- a/src/cadecoder.c ++++ b/src/cadecoder.c +@@ -3642,7 +3642,7 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo + } + + if ((d->feature_flags & CA_FORMAT_WITH_CHATTR) != 0 && child->fd >= 0) { +- unsigned new_attr, old_attr; ++ int new_attr, old_attr; + + new_attr = ca_feature_flags_to_chattr(read_le64(&child->entry->flags) & d->feature_flags); + +@@ -4471,7 +4471,7 @@ int ca_decoder_current_rdev(CaDecoder *d, dev_t *ret) { + return 0; + } + +-int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret) { ++int ca_decoder_current_chattr(CaDecoder *d, int *ret) { + CaDecoderNode *n; + mode_t mode; + +diff --git a/src/cadecoder.h b/src/cadecoder.h +index d658676c88..48f81e7c1a 100644 +--- a/src/cadecoder.h ++++ b/src/cadecoder.h +@@ -89,7 +89,7 @@ int ca_decoder_current_user(CaDecoder *d, const char **user); + int ca_decoder_current_group(CaDecoder *d, const char **user); + int ca_decoder_current_rdev(CaDecoder *d, dev_t *ret); + int ca_decoder_current_offset(CaDecoder *d, uint64_t *ret); +-int ca_decoder_current_chattr(CaDecoder *d, unsigned *ret); ++int ca_decoder_current_chattr(CaDecoder *d, int *ret); + int ca_decoder_current_fat_attrs(CaDecoder *d, uint32_t *ret); + int ca_decoder_current_xattr(CaDecoder *d, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size); + +diff --git a/src/caencoder.c b/src/caencoder.c +index 4bea8adae9..bcae40b289 100644 +--- a/src/caencoder.c ++++ b/src/caencoder.c +@@ -2850,7 +2850,7 @@ int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret) { + return 0; + } + +-int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret) { ++int ca_encoder_current_chattr(CaEncoder *e, int *ret) { + CaEncoderNode *n; + + if (!e) +diff --git a/src/caencoder.h b/src/caencoder.h +index 26388261bd..e270cc0b1a 100644 +--- a/src/caencoder.h ++++ b/src/caencoder.h +@@ -49,7 +49,7 @@ int ca_encoder_current_gid(CaEncoder *e, gid_t *ret); + int ca_encoder_current_user(CaEncoder *e, const char **ret); + int ca_encoder_current_group(CaEncoder *e, const char **ret); + int ca_encoder_current_rdev(CaEncoder *e, dev_t *ret); +-int ca_encoder_current_chattr(CaEncoder *e, unsigned *ret); ++int ca_encoder_current_chattr(CaEncoder *e, int *ret); + int ca_encoder_current_fat_attrs(CaEncoder *e, uint32_t *ret); + int ca_encoder_current_xattr(CaEncoder *e, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size); + +diff --git a/src/caformat-util.c b/src/caformat-util.c +index 332c6793a9..0b7512f353 100644 +--- a/src/caformat-util.c ++++ b/src/caformat-util.c +@@ -279,8 +279,8 @@ uint64_t ca_feature_flags_from_chattr(unsigned flags) { + return f; + } + +-unsigned ca_feature_flags_to_chattr(uint64_t flags) { +- unsigned f = 0; ++int ca_feature_flags_to_chattr(uint64_t flags) { ++ int f = 0; + size_t i; + + for (i = 0; i < ELEMENTSOF(chattr_map); i++) +diff --git a/src/caformat-util.h b/src/caformat-util.h +index 68741203fe..2e5db2bd19 100644 +--- a/src/caformat-util.h ++++ b/src/caformat-util.h +@@ -14,7 +14,7 @@ int ca_feature_flags_normalize(uint64_t flags, uint64_t *ret); + int ca_feature_flags_time_granularity_nsec(uint64_t flags, uint64_t *ret); + + uint64_t ca_feature_flags_from_chattr(unsigned flags); +-unsigned ca_feature_flags_to_chattr(uint64_t flags); ++int ca_feature_flags_to_chattr(uint64_t flags); + + uint64_t ca_feature_flags_from_fat_attrs(uint32_t flags); + uint32_t ca_feature_flags_to_fat_attrs(uint64_t flags); +diff --git a/src/casync-tool.c b/src/casync-tool.c +index 1650028a1a..97e33d5b5b 100644 +--- a/src/casync-tool.c ++++ b/src/casync-tool.c +@@ -2058,7 +2058,7 @@ static int verb_list(int argc, char *argv[]) { + uid_t uid = UID_INVALID; + gid_t gid = GID_INVALID; + dev_t rdev = (dev_t) -1; +- unsigned flags = (unsigned) -1; ++ int flags = -1; + uint32_t fat_attrs = (uint32_t) -1; + char *escaped = NULL; + const char *xname; +@@ -2093,7 +2093,7 @@ static int verb_list(int argc, char *argv[]) { + + escaped = mfree(escaped); + +- if (flags != (unsigned) -1) ++ if (flags != -1) + printf("FileAttr: %s\n", strna(ls_format_chattr(flags, ls_flags))); + + if (fat_attrs != (uint32_t) -1) +diff --git a/src/casync.c b/src/casync.c +index ceac46dc7b..c73d9396ca 100644 +--- a/src/casync.c ++++ b/src/casync.c +@@ -2943,7 +2943,7 @@ int ca_sync_current_rdev(CaSync *s, dev_t *ret) { + return -ENOTTY; + } + +-int ca_sync_current_chattr(CaSync *s, unsigned *ret) { ++int ca_sync_current_chattr(CaSync *s, int *ret) { + CaSeed *seed; + + if (!s) +diff --git a/src/casync.h b/src/casync.h +index 62818d13e3..afab401e01 100644 +--- a/src/casync.h ++++ b/src/casync.h +@@ -96,7 +96,7 @@ int ca_sync_current_group(CaSync *sync, const char **ret); + int ca_sync_current_mtime(CaSync *sync, uint64_t *nsec); + int ca_sync_current_size(CaSync *sync, uint64_t *ret); + int ca_sync_current_rdev(CaSync *sync, dev_t *ret); +-int ca_sync_current_chattr(CaSync *sync, unsigned *ret); ++int ca_sync_current_chattr(CaSync *sync, int *ret); + int ca_sync_current_fat_attrs(CaSync *sync, uint32_t *ret); + int ca_sync_current_xattr(CaSync *sync, CaIterate where, const char **ret_name, const void **ret_value, size_t *ret_size); + +diff --git a/src/util.c b/src/util.c +index b0f3138254..67e480a379 100644 +--- a/src/util.c ++++ b/src/util.c +@@ -672,10 +672,10 @@ char* ls_format_mode(mode_t m, char ret[LS_FORMAT_MODE_MAX]) { + return ret; + } + +-char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]) { ++char *ls_format_chattr(int flags, char ret[LS_FORMAT_CHATTR_MAX]) { + + static const struct { +- unsigned flag; ++ int flag; + char code; + } table[] = { + { FS_SYNC_FL, 'S' }, +@@ -692,7 +692,7 @@ char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]) { + + size_t i; + +- if (flags == (unsigned) -1) ++ if (flags == -1) + return NULL; + + assert(ELEMENTSOF(table) == LS_FORMAT_CHATTR_MAX-1); +diff --git a/src/util.h b/src/util.h +index 2d82cc2c4e..16891ec80c 100644 +--- a/src/util.h ++++ b/src/util.h +@@ -46,6 +46,15 @@ + UNIQ_T(A,aq) < UNIQ_T(B,bq) ? UNIQ_T(A,aq) : UNIQ_T(B,bq); \ + }) + ++ ++/* "linux/fs.h" contains wrong definitions of FS_IOC_[GS]ETFLAGS. ++ * This problem has been known for at least 14 years. To avoid a spurious ++ * warning from valgrind, let's override the kernel definitions. */ ++#undef FS_IOC_GETFLAGS ++#undef FS_IOC_SETFLAGS ++#define FS_IOC_GETFLAGS _IOR('f', 1, int) ++#define FS_IOC_SETFLAGS _IOW('f', 2, int) ++ + static inline uint64_t timespec_to_nsec(struct timespec t) { + + if (t.tv_sec == (time_t) -1 && +@@ -285,7 +294,7 @@ char *strjoin_real(const char *x, ...) _sentinel_; + char* ls_format_mode(mode_t m, char ret[LS_FORMAT_MODE_MAX]); + + #define LS_FORMAT_CHATTR_MAX 11 +-char *ls_format_chattr(unsigned flags, char ret[LS_FORMAT_CHATTR_MAX]); ++char *ls_format_chattr(int flags, char ret[LS_FORMAT_CHATTR_MAX]); + + #define LS_FORMAT_FAT_ATTRS_MAX 4 + char *ls_format_fat_attrs(unsigned flags, char ret[LS_FORMAT_FAT_ATTRS_MAX]); +-- +2.13.0 + diff --git a/0002-cadecoder-only-try-to-set-settable-chattr-bits.patch b/0002-cadecoder-only-try-to-set-settable-chattr-bits.patch deleted file mode 100644 index f11de17..0000000 --- a/0002-cadecoder-only-try-to-set-settable-chattr-bits.patch +++ /dev/null @@ -1,53 +0,0 @@ -From b6ebd172912d298223990487f14460faf3e959df Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= -Date: Tue, 20 Jun 2017 15:21:07 -0400 -Subject: [PATCH 2/4] cadecoder: only try to set settable chattr bits -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -It seems that after all, FS_IOC_GETFLAGS should take an int*. -It does not set the high bits in the long argument. By explicitly -initalizing it to 0, we avoid garbage there. I'm not sure how this -will play out on a big-endian system… - -Independently, we shouldn't be trying to set bits like FS_EXTENT_FL, -which chattr(1) says "cannot be set by chattr", i.e. presumably also -not by us. ---- - src/cadecoder.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/src/cadecoder.c b/src/cadecoder.c -index d3167348fa..d65938e839 100644 ---- a/src/cadecoder.c -+++ b/src/cadecoder.c -@@ -3642,18 +3642,22 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo - } - - if ((d->feature_flags & CA_FORMAT_WITH_CHATTR) != 0 && child->fd >= 0) { -- long new_attr, old_attr; -+ long new_attr, -+ old_attr = 0; /* Initialize, 'cuz ioctl() does not set the high bits. */; - - new_attr = ca_feature_flags_to_chattr(read_le64(&child->entry->flags) & d->feature_flags); -+ assert((new_attr & ~FS_FL_USER_MODIFIABLE) == 0); - - if (ioctl(child->fd, FS_IOC_GETFLAGS, &old_attr) < 0) { - - if (new_attr != 0 || !IN_SET(errno, ENOTTY, ENOSYS, EBADF, EOPNOTSUPP)) - return -errno; - -- } else if (old_attr != new_attr) { -+ } else if ((old_attr & FS_FL_USER_MODIFIABLE) != new_attr) { -+ long final_attr; - -- if (ioctl(child->fd, FS_IOC_SETFLAGS, &new_attr) < 0) -+ final_attr = (old_attr & !FS_FL_USER_MODIFIABLE) | new_attr; -+ if (ioctl(child->fd, FS_IOC_SETFLAGS, &final_attr) < 0) - return -errno; - } - } --- -2.13.0 - diff --git a/0003-cadecoder-only-try-to-set-settable-chattr-bits.patch b/0003-cadecoder-only-try-to-set-settable-chattr-bits.patch new file mode 100644 index 0000000..df452d2 --- /dev/null +++ b/0003-cadecoder-only-try-to-set-settable-chattr-bits.patch @@ -0,0 +1,42 @@ +From e4928f0ab2b16ded55316cfc44a32f542b88c81f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 20 Jun 2017 15:21:07 -0400 +Subject: [PATCH 3/4] cadecoder: only try to set settable chattr bits + +We shouldn't be trying to set bits like FS_EXTENT_FL, which chattr(1) says +"cannot be set by chattr", i.e. presumably also not by us. Only compare +and try to set bits which under the FS_FL_USER_MODIFIABLE mask. + +Fixes #27. +--- + src/cadecoder.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/cadecoder.c b/src/cadecoder.c +index deba462a47..93f8ebf392 100644 +--- a/src/cadecoder.c ++++ b/src/cadecoder.c +@@ -3645,15 +3645,18 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo + int new_attr, old_attr; + + new_attr = ca_feature_flags_to_chattr(read_le64(&child->entry->flags) & d->feature_flags); ++ assert((new_attr & ~FS_FL_USER_MODIFIABLE) == 0); + + if (ioctl(child->fd, FS_IOC_GETFLAGS, &old_attr) < 0) { + + if (new_attr != 0 || !IN_SET(errno, ENOTTY, ENOSYS, EBADF, EOPNOTSUPP)) + return -errno; + +- } else if (old_attr != new_attr) { ++ } else if ((old_attr & FS_FL_USER_MODIFIABLE) != new_attr) { ++ int final_attr; + +- if (ioctl(child->fd, FS_IOC_SETFLAGS, &new_attr) < 0) ++ final_attr = (old_attr & !FS_FL_USER_MODIFIABLE) | new_attr; ++ if (ioctl(child->fd, FS_IOC_SETFLAGS, &final_attr) < 0) + return -errno; + } + } +-- +2.13.0 + diff --git a/0003-debug-stmt.patch b/0003-debug-stmt.patch deleted file mode 100644 index b05b90e..0000000 --- a/0003-debug-stmt.patch +++ /dev/null @@ -1,34 +0,0 @@ -From b458724e7c6e83d34500f1e7cc95559313c58f22 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= -Date: Tue, 20 Jun 2017 15:28:22 -0400 -Subject: [PATCH 3/4] debug stmt - ---- - src/cadecoder.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/src/cadecoder.c b/src/cadecoder.c -index d65938e839..2066d9cf2e 100644 ---- a/src/cadecoder.c -+++ b/src/cadecoder.c -@@ -3656,10 +3656,16 @@ static int ca_decoder_finalize_child(CaDecoder *d, CaDecoderNode *n, CaDecoderNo - } else if ((old_attr & FS_FL_USER_MODIFIABLE) != new_attr) { - long final_attr; - -+ fprintf(stderr, "old_attr=%lx, settable=%lx, new_attr=%lx\n", -+ old_attr, old_attr & FS_FL_USER_MODIFIABLE, new_attr); -+ - final_attr = (old_attr & !FS_FL_USER_MODIFIABLE) | new_attr; - if (ioctl(child->fd, FS_IOC_SETFLAGS, &final_attr) < 0) - return -errno; -- } -+ } else -+ fprintf(stderr, "old_attr=%lx, settable=%lx, new_attr=%lx\n", -+ old_attr, old_attr & FS_FL_USER_MODIFIABLE, new_attr); -+ - } - - if ((d->feature_flags & CA_FORMAT_WITH_FAT_ATTRS) != 0 && child->fd >= 0) { --- -2.13.0 - diff --git a/0004-util-define-__NR_renameat2-for-ppc64.patch b/0004-util-define-__NR_renameat2-for-ppc64.patch index 71896e3..753e7bf 100644 --- a/0004-util-define-__NR_renameat2-for-ppc64.patch +++ b/0004-util-define-__NR_renameat2-for-ppc64.patch @@ -1,4 +1,4 @@ -From d6b59ed1353f3d451dfa95d35450cde588e9d8c5 Mon Sep 17 00:00:00 2001 +From 2e01d2a1858ff792c24a90d9e79007e657c4815b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 20 Jun 2017 15:39:38 -0400 Subject: [PATCH 4/4] util: define __NR_renameat2 for ppc64 @@ -8,10 +8,10 @@ Subject: [PATCH 4/4] util: define __NR_renameat2 for ppc64 1 file changed, 2 insertions(+) diff --git a/src/util.h b/src/util.h -index e5e94b5c8a..9497528987 100644 +index 16891ec80c..f439171dce 100644 --- a/src/util.h +++ b/src/util.h -@@ -476,6 +476,8 @@ static inline bool strv_isempty(char **l) { +@@ -485,6 +485,8 @@ static inline bool strv_isempty(char **l) { # endif # elif defined __i386__ # define __NR_renameat2 353 diff --git a/0005-util-define-__NR_renameat2-for-s390-x.patch b/0005-util-define-__NR_renameat2-for-s390-x.patch new file mode 100644 index 0000000..bf3f978 --- /dev/null +++ b/0005-util-define-__NR_renameat2-for-s390-x.patch @@ -0,0 +1,25 @@ +From 3d4011dab372fed434737cc1bcbb3ab9cfafb8f3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 20 Jun 2017 18:23:10 -0400 +Subject: [PATCH] util: define __NR_renameat2 for s390[x] + +--- + src/util.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/util.h b/src/util.h +index f439171dce..bcc1713591 100644 +--- a/src/util.h ++++ b/src/util.h +@@ -487,6 +487,8 @@ static inline bool strv_isempty(char **l) { + # define __NR_renameat2 353 + # elif defined __powerpc64__ + # define __NR_renameat2 357 ++# elif defined __s390__ || defined __s390__ ++# define __NR_renameat2 347 + # else + # warning "__NR_renameat2 unknown for your architecture" + # endif +-- +2.13.0 + diff --git a/0006-tests-fix-tests-when-the-source-directory-is-not-cal.patch b/0006-tests-fix-tests-when-the-source-directory-is-not-cal.patch new file mode 100644 index 0000000..6bf3675 --- /dev/null +++ b/0006-tests-fix-tests-when-the-source-directory-is-not-cal.patch @@ -0,0 +1,55 @@ +From 92c01a4b53a74c66173863eb0f28bd9465d007c0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 20 Jun 2017 18:43:51 -0400 +Subject: [PATCH] tests: fix tests when the source directory is not called + "casync" + +test-script.sh would fail when the top source dir was called e.g. casync-1. +--- + test/test-script.sh.in | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/test/test-script.sh.in b/test/test-script.sh.in +index a36e7b3d05..6bb7099034 100755 +--- a/test/test-script.sh.in ++++ b/test/test-script.sh.in +@@ -13,10 +13,10 @@ SCRATCH_DIR=/var/tmp/test-casync.$RANDOM + mkdir -p $SCRATCH_DIR/src + + if [ `id -u` == 0 ] ; then +- cp -a @top_srcdir@ $SCRATCH_DIR/src ++ cp -a @top_srcdir@/test-files $SCRATCH_DIR/src/ + else + # If we lack privileges we use rsync rather than cp to copy, as it will just skip over device nodes +- rsync -a @top_srcdir@ $SCRATCH_DIR/src ++ rsync -a @top_srcdir@/test-files $SCRATCH_DIR/src/ + fi + + cd $SCRATCH_DIR/src +@@ -101,17 +101,17 @@ diff -q $SCRATCH_DIR/test.digest $SCRATCH_DIR/test.extract-caidx2.digest + @top_builddir@/casync $PARAMS make $SCRATCH_DIR/seek.catar + @top_builddir@/casync $PARAMS make $SCRATCH_DIR/seek.caidx + +-@top_builddir@/casync $PARAMS extract $SCRATCH_DIR/seek.catar $SCRATCH_DIR/extract-seek-catar casync/test-files +-@top_builddir@/casync $PARAMS extract $SCRATCH_DIR/seek.caidx $SCRATCH_DIR/extract-seek-caidx casync/test-files ++@top_builddir@/casync $PARAMS extract $SCRATCH_DIR/seek.catar $SCRATCH_DIR/extract-seek-catar test-files ++@top_builddir@/casync $PARAMS extract $SCRATCH_DIR/seek.caidx $SCRATCH_DIR/extract-seek-caidx test-files + +-@top_builddir@/casync $PARAMS mtree casync/test-files > $SCRATCH_DIR/original-seek.mtree +-@top_builddir@/casync $PARAMS digest casync/test-files > $SCRATCH_DIR/original-seek.digest ++@top_builddir@/casync $PARAMS mtree test-files > $SCRATCH_DIR/original-seek.mtree ++@top_builddir@/casync $PARAMS digest test-files > $SCRATCH_DIR/original-seek.digest + @top_builddir@/casync $PARAMS mtree $SCRATCH_DIR/extract-seek-catar/test-files > $SCRATCH_DIR/extract-seek-catar.mtree + @top_builddir@/casync $PARAMS digest $SCRATCH_DIR/extract-seek-catar/test-files > $SCRATCH_DIR/extract-seek-catar.digest + @top_builddir@/casync $PARAMS mtree $SCRATCH_DIR/extract-seek-caidx/test-files > $SCRATCH_DIR/extract-seek-caidx.mtree + @top_builddir@/casync $PARAMS digest $SCRATCH_DIR/extract-seek-caidx/test-files > $SCRATCH_DIR/extract-seek-caidx.digest +-@top_builddir@/casync $PARAMS digest $SCRATCH_DIR/seek.catar casync/test-files > $SCRATCH_DIR/extract-seek-catar-direct.digest +-@top_builddir@/casync $PARAMS digest $SCRATCH_DIR/seek.caidx casync/test-files > $SCRATCH_DIR/extract-seek-caidx-direct.digest ++@top_builddir@/casync $PARAMS digest $SCRATCH_DIR/seek.catar test-files > $SCRATCH_DIR/extract-seek-catar-direct.digest ++@top_builddir@/casync $PARAMS digest $SCRATCH_DIR/seek.caidx test-files > $SCRATCH_DIR/extract-seek-caidx-direct.digest + + diff -q $SCRATCH_DIR/original-seek.digest $SCRATCH_DIR/extract-seek-catar.digest + diff -q $SCRATCH_DIR/original-seek.digest $SCRATCH_DIR/extract-seek-caidx.digest +-- +2.13.0 + diff --git a/casync.spec b/casync.spec index 552d017..e7a4446 100644 --- a/casync.spec +++ b/casync.spec @@ -1,6 +1,6 @@ Name: casync Version: 1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Content Addressable Data Synchronizer License: LGPLv2+ @@ -17,11 +17,12 @@ BuildRequires: libacl-devel # for tests BuildRequires: rsync -Patch0: 0001-Drop-some-unnecessary-braces.patch -Patch1: 0001-ioctl-FS_IOC_-SG-ETFLAGS-takes-a-long.patch -Patch2: 0002-cadecoder-only-try-to-set-settable-chattr-bits.patch -Patch3: 0003-debug-stmt.patch -Patch4: 0004-util-define-__NR_renameat2-for-ppc64.patch +Patch0001: 0001-Drop-some-unnecessary-braces.patch +Patch0002: 0002-Redefine-ioctl-FS_IOC_-SG-ETFLAGS-to-take-an-int.patch +Patch0003: 0003-cadecoder-only-try-to-set-settable-chattr-bits.patch +Patch0004: 0004-util-define-__NR_renameat2-for-ppc64.patch +Patch0005: 0005-util-define-__NR_renameat2-for-s390-x.patch +Patch0006: 0006-tests-fix-tests-when-the-source-directory-is-not-cal.patch %description casync provides a way to efficiently transfer files which change over