]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: move sun PT definition to include/
authorKarel Zak <kzak@redhat.com>
Mon, 4 Feb 2013 16:46:30 +0000 (17:46 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Mar 2013 12:00:55 +0000 (13:00 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/Makemodule.am
include/pt-sun.h [new file with mode: 0644]
libblkid/src/partitions/sun.c

index 358a351e1a21214313a5157eca04f47191bff495..0c1656d2d043854d7c2dc5e9f369e77a67bf7338 100644 (file)
@@ -44,4 +44,5 @@ dist_noinst_HEADERS += \
        include/wholedisk.h \
        include/widechar.h \
        include/xalloc.h \
-       include/xgetpass.h
+       include/xgetpass.h \
+       include/pt-sun.h
diff --git a/include/pt-sun.h b/include/pt-sun.h
new file mode 100644 (file)
index 0000000..5528dd3
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef UTIL_LINUX_PT_SUN_H
+#define UTIL_LINUX_PT_SUN_H
+
+#include <stdint.h>
+
+/* Supported VTOC setting */
+#define SUN_VTOC_SANITY                0x600DDEEE      /* magic number */
+#define SUN_VTOC_VERSION       1
+
+#define SUN_MAXPARTITIONS      8
+
+/* Partition IDs */
+#define SUN_TAG_WHOLEDISK          0x05
+
+struct sun_disklabel {
+       unsigned char info[128];   /* Informative text string */
+
+       struct sun_vtoc {
+               uint32_t version;     /* version */
+               char     volume[8];   /* volume name */
+               uint16_t nparts;      /* num of partitions */
+
+               struct sun_info {     /* partition information */
+                       uint16_t id;  /* tag */
+                       uint16_t flags;
+               } __attribute__ ((packed)) infos[8];
+
+               uint16_t padding;      /* padding */
+               uint32_t bootinfo[3];  /* info needed by mboot */
+               uint32_t sanity;       /* magic number */
+               uint32_t reserved[10]; /* padding */
+               uint32_t timestamp[8]; /* partition timestamp */
+       } __attribute__ ((packed)) vtoc;
+
+       uint32_t write_reinstruct;     /* sectors to skip, writes */
+       uint32_t read_reinstruct;      /* sectors to skip, reads */
+       unsigned char spare[148];      /* padding */
+       uint16_t rspeed;               /* disk rotational speed */
+       uint16_t pcylcount;            /* physical cylinder count */
+       uint16_t sparecyl;             /* extra sects per cylinder */
+       uint16_t obs1;
+       uint16_t obs2;
+       uint16_t ilfact;               /* interleave factor */
+       uint16_t ncyl;                 /* data cylinder count */
+       uint16_t nacyl;                /* alt. cylinder count */
+       uint16_t ntrks;                /* tracks per cylinder   <---- */
+       uint16_t nsect;                /* sectors per track     <---- */
+       uint16_t obs3;
+       uint16_t obs4;
+
+       struct sun_partition {         /* partitions */
+               uint32_t start_cylinder;
+               uint32_t num_sectors;
+       } __attribute__ ((packed)) partitions[8];
+
+       uint16_t magic;                /* magic number */
+       uint16_t csum;                 /* label xor'd checksum */
+} __attribute__ ((packed));
+
+
+static inline uint16_t sun_pt_checksum(struct sun_disklabel *label)
+{
+       uint16_t *ptr = ((uint16_t *) (label + 1)) - 1;
+       uint16_t sum;
+
+       for (sum = 0; ptr >= ((uint16_t *) label);)
+               sum ^= *ptr--;
+
+       return sum;
+}
+
+#endif /* UTIL_LINUX_PT_SUN_H */
index f151f46ae4589ad24c6d619c3a9d851dfaf85d85..f1b839258a9df173156f8ba70d3e70317182c381 100644 (file)
 #include <stdint.h>
 #include <stddef.h>
 
+#include "pt-sun.h"
 #include "partitions.h"
 
-/* Supported VTOC setting */
-#define SUN_VTOC_SANITY                0x600DDEEE      /* magic number */
-#define SUN_VTOC_VERSION       1
-
-#define SUN_MAXPARTITIONS      8
-
-/* Partition IDs */
-#define SUN_TAG_WHOLEDISK          0x05
-
-struct sun_disklabel {
-       unsigned char info[128];   /* Informative text string */
-
-       struct sun_vtoc {
-               uint32_t version;     /* version */
-               char     volume[8];   /* volume name */
-               uint16_t nparts;      /* num of partitions */
-
-               struct sun_info {     /* partition information */
-                       uint16_t id;  /* tag */
-                       uint16_t flags;
-               } __attribute__ ((packed)) infos[8];
-
-               uint16_t padding;      /* padding */
-               uint32_t bootinfo[3];  /* info needed by mboot */
-               uint32_t sanity;       /* magic number */
-               uint32_t reserved[10]; /* padding */
-               uint32_t timestamp[8]; /* partition timestamp */
-       } __attribute__ ((packed)) vtoc;
-
-       uint32_t write_reinstruct;     /* sectors to skip, writes */
-       uint32_t read_reinstruct;      /* sectors to skip, reads */
-       unsigned char spare[148];      /* padding */
-       uint16_t rspeed;               /* disk rotational speed */
-       uint16_t pcylcount;            /* physical cylinder count */
-       uint16_t sparecyl;             /* extra sects per cylinder */
-       uint16_t obs1;
-       uint16_t obs2;
-       uint16_t ilfact;               /* interleave factor */
-       uint16_t ncyl;                 /* data cylinder count */
-       uint16_t nacyl;                /* alt. cylinder count */
-       uint16_t ntrks;                /* tracks per cylinder   <---- */
-       uint16_t nsect;                /* sectors per track     <---- */
-       uint16_t obs3;
-       uint16_t obs4;
-
-       struct sun_partition {         /* partitions */
-               uint32_t start_cylinder;
-               uint32_t num_sectors;
-       } __attribute__ ((packed)) partitions[8];
-
-       uint16_t magic;                /* magic number */
-       uint16_t csum;                 /* label xor'd checksum */
-} __attribute__ ((packed));
-
-
-uint16_t count_checksum(struct sun_disklabel *label)
-{
-       uint16_t *ptr = ((uint16_t *) (label + 1)) - 1;
-       uint16_t sum;
-
-       for (sum = 0; ptr >= ((uint16_t *) label);)
-               sum ^= *ptr--;
-
-       return sum;
-}
-
 static int probe_sun_pt(blkid_probe pr,
                const struct blkid_idmag *mag __attribute__((__unused__)))
 {
@@ -95,7 +30,7 @@ static int probe_sun_pt(blkid_probe pr,
        if (!l)
                goto nothing;
 
-       if (count_checksum(l)) {
+       if (sun_pt_checksum(l)) {
                DBG(DEBUG_LOWPROBE, printf(
                        "detected corrupted sun disk label -- ignore\n"));
                goto nothing;