Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] libfdisk: (gpt) fix attributes endianess
@ 2015-05-08 11:39 Ruediger Meier
  2015-05-08 13:44 ` Ruediger Meier
  2015-05-11 10:25 ` Karel Zak
  0 siblings, 2 replies; 7+ messages in thread
From: Ruediger Meier @ 2015-05-08 11:39 UTC (permalink / raw)
  To: util-linux; +Cc: Michael Marineau

From: Ruediger Meier <ruediger.meier@ga-group.nl>

The new libfdisk/gpt test (4a4a0927) discovered that we read and write
partition attributes wrongly on BE systems.

Our temporarily used char[8] bits are always LE and do not need to be
converted.

CC: Michael Marineau <michael.marineau@coreos.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 libfdisk/src/gpt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index a7ec539..3db81be 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -1415,7 +1415,7 @@ static int gpt_entry_attrs_to_string(struct gpt_entry *e, char **res)
 	assert(res);
 
 	*res = NULL;
-	attrs = le64_to_cpu(e->attrs);
+	attrs = e->attrs;
 	if (!attrs)
 		return 0;	/* no attributes at all */
 
@@ -1530,7 +1530,7 @@ static int gpt_entry_attrs_from_string(
 			p++;
 	}
 
-	e->attrs = cpu_to_le64(attrs);
+	e->attrs = attrs;
 	return 0;
 }
 
@@ -2517,7 +2517,7 @@ static int gpt_toggle_partition_flag(
 	if ((uint32_t) i >= le32_to_cpu(gpt->pheader->npartition_entries))
 		return -EINVAL;
 
-	attrs = le64_to_cpu(gpt->ents[i].attrs);
+	attrs = gpt->ents[i].attrs;
 	bits = (char *) &attrs;
 
 	switch (flag) {
@@ -2558,7 +2558,7 @@ static int gpt_toggle_partition_flag(
 	else
 		clrbit(bits, bit);
 
-	gpt->ents[i].attrs = cpu_to_le64(attrs);
+	gpt->ents[i].attrs = attrs;
 
 	if (flag == GPT_FLAG_GUIDSPECIFIC)
 		fdisk_info(cxt, isset(bits, bit) ?
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-05-13 11:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-08 11:39 [PATCH] libfdisk: (gpt) fix attributes endianess Ruediger Meier
2015-05-08 13:44 ` Ruediger Meier
2015-05-11 10:25 ` Karel Zak
2015-05-12  6:47   ` Ruediger Meier
2015-05-13  9:17     ` Karel Zak
2015-05-13  9:58       ` Ruediger Meier
2015-05-13 11:16         ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox