src/t_attr_corruption: covert value to little endian order
authorZorro Lang <zlang@redhat.com>
Tue, 9 Apr 2019 04:54:04 +0000 (12:54 +0800)
committerEryu Guan <guaneryu@gmail.com>
Tue, 9 Apr 2019 08:14:08 +0000 (16:14 +0800)
generic/529 always fails on ppc64 or s390x big-endian machine as:

  set posix acl: Operation not supported

Due to the members of struct posix_acl_xattr_entry/header need to be
little-endian byte order, so use htole*() helper to make sure that.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
src/t_attr_corruption.c

index 9101024e6c8888cb160b487529e540ac5b773338..e7d435b1791f3f4fbcb53618ab1abecdc4f9573c 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <sys/xattr.h>
+#include <endian.h>
 
 void die(const char *msg)
 {
@@ -52,13 +53,14 @@ struct myacl {
 
 int main(int argc, char *argv[])
 {
+       /* posix_acl_xattr_entry/header need little-endian order */
        struct myacl acl = {
-               .d = 2,
+               .d = htole32(2),
                .e = {
-                       {1, 0, 0},
-                       {4, 0, 0},
-                       {0x10, 0, 0},
-                       {0x20, 0, 0},
+                       {htole16(1), 0, 0},
+                       {htole16(4), 0, 0},
+                       {htole16(0x10), 0, 0},
+                       {htole16(0x20), 0, 0},
                },
        };
        char buf[64];