Skip to contentSkip to conversation

src/t_attr_corruption: covert value to little endian order

PATCH In review Zorro Lang 2 participants 2 messages Apr 9, 2019

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 src/t_attr_corruption: covert value to little endian order

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.

---
 src/t_attr_corruption.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
src/t_attr_corruption.c +7 -5
index 9101024e..e7d435b1 100644
@@ -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];
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Zorro Lang

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.

Heh, seems ok... :)

--D

Quoted 39 lines
---
 src/t_attr_corruption.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
src/t_attr_corruption.c +7 -5
index 9101024e..e7d435b1 100644
@@ -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];
Signature · 1 line
2.17.2