]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (gpt) fix attributes endianess
authorRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 8 May 2015 11:39:53 +0000 (13:39 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 11 May 2015 08:51:15 +0000 (10:51 +0200)
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

index a7ec5397a4e7e53fe2daf7e384a158d57f99de79..3db81bedfb9c16632cbc8ec09af2d7ffab83374c 100644 (file)
@@ -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) ?