]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: move SGI disklabel definitions to include/
authorKarel Zak <kzak@redhat.com>
Wed, 29 May 2013 11:17:06 +0000 (13:17 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:46:57 +0000 (16:46 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/Makemodule.am
include/pt-sgi.h [new file with mode: 0644]
libblkid/src/partitions/sgi.c

index c072af0f10ee074822085e6a3d775e11cf658c12..5a1ea3b851dfbd0a7878a952fa70ec08562e40f5 100644 (file)
@@ -48,4 +48,5 @@ dist_noinst_HEADERS += \
        include/widechar.h \
        include/xalloc.h \
        include/xgetpass.h \
+       include/pt-sgi.h \
        include/pt-sun.h
diff --git a/include/pt-sgi.h b/include/pt-sgi.h
new file mode 100644 (file)
index 0000000..60df11b
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef UTIL_LINUX_PT_SUN_H
+#define UTIL_LINUX_PT_SUN_H
+
+#include <stdint.h>
+
+#define SGI_MAXPARTITIONS      16
+
+/* partition types */
+enum {
+       SGI_TYPE_VOLHDR         = 0x00,
+       SGI_TYPE_SWAP           = 0x03,
+       SGI_TYPE_ENTIRE_DISK    = 0x06,
+       SGI_TYPE_EFS            = 0x07,
+       SGI_TYPE_LVOL           = 0x08,
+       SGI_TYPE_RLVOL          = 0x09,
+       SGI_TYPE_XFS            = 0x0a,
+       SGI_TYPE_XFSLOG         = 0x0b,
+       SGI_TYPE_XLV            = 0x0c,
+       SGI_TYPE_XVM            = 0x0d
+};
+
+struct sgi_device_parameter {
+       unsigned char skew;
+       unsigned char gap1;
+       unsigned char gap2;
+       unsigned char sparecyl;
+
+       uint16_t pcylcount;
+       uint16_t head_vol0;
+       uint16_t ntrks;         /* tracks in cyl 0 or vol 0 */
+
+       unsigned char cmd_tag_queue_depth;
+       unsigned char unused0;
+
+       uint16_t unused1;
+       uint16_t nsect;         /* sectors/tracks in cyl 0 or vol 0 */
+       uint16_t bytes;
+       uint16_t ilfact;
+       uint32_t flags;         /* controller flags */
+       uint32_t datarate;
+       uint32_t retries_on_error;
+       uint32_t ms_per_word;
+       uint16_t xylogics_gap1;
+       uint16_t xylogics_syncdelay;
+       uint16_t xylogics_readdelay;
+       uint16_t xylogics_gap2;
+       uint16_t xylogics_readgate;
+       uint16_t xylogics_writecont;
+} __attribute__((packed));
+
+struct sgi_disklabel {
+       uint32_t magic;                 /* magic number */
+       uint16_t root_part_num;         /* # root partition */
+       uint16_t swap_part_num;         /* # swap partition */
+       unsigned char boot_file[16];    /* name of boot file */
+
+       struct sgi_device_parameter     devparam;       /* not used now */
+
+       struct sgi_volume {
+               unsigned char name[8];  /* name of volume */
+               uint32_t block_num;     /* logical block number */
+               uint32_t num_bytes;     /* how big, in bytes */
+       } __attribute__((packed)) volume[15];
+
+       struct sgi_partition {
+               uint32_t num_blocks;    /* size in logical blocks */
+               uint32_t first_block;   /* first logical block */
+               uint32_t type;          /* type of this partition */
+       } __attribute__((packed)) partitions[SGI_MAXPARTITIONS];
+
+       /* checksum is the 32bit 2's complement sum of the disklabel */
+       uint32_t csum;                  /* disk label checksum */
+       uint32_t padding;               /* padding */
+} __attribute__((packed));
+
+static inline uint32_t sgi_pt_checksum(struct sgi_disklabel *label)
+{
+       int i;
+       uint32_t *ptr = (uint32_t *) label;
+       uint32_t sum = 0;
+
+       i = sizeof(*label) / sizeof(*ptr);
+
+       while (i--)
+               sum += be32_to_cpu(ptr[i]);
+
+       return sum;
+}
+
+#endif /* UTIL_LINUX_PT_SUN_H */
index b292e71502cfc63706855fc1878182e0088b5798..bcde84f2a10bd27c9a0c6cfd1a91855f3a0e8b71 100644 (file)
 #include <stdint.h>
 
 #include "partitions.h"
-
-#define SGI_MAXPARTITIONS      16
-
-/* partition type */
-#define SGI_TYPE_VOLHDR                0x00
-#define SGI_TYPE_VOLULME       0x06    /* entire disk */
-
-struct sgi_device_parameter {
-       unsigned char skew;
-       unsigned char gap1;
-       unsigned char gap2;
-       unsigned char sparecyl;
-
-       uint16_t pcylcount;
-       uint16_t head_vol0;
-       uint16_t ntrks;         /* tracks in cyl 0 or vol 0 */
-
-       unsigned char cmd_tag_queue_depth;
-       unsigned char unused0;
-
-       uint16_t unused1;
-       uint16_t nsect;         /* sectors/tracks in cyl 0 or vol 0 */
-       uint16_t bytes;
-       uint16_t ilfact;
-       uint32_t flags;         /* controller flags */
-       uint32_t datarate;
-       uint32_t retries_on_error;
-       uint32_t ms_per_word;
-       uint16_t xylogics_gap1;
-       uint16_t xylogics_syncdelay;
-       uint16_t xylogics_readdelay;
-       uint16_t xylogics_gap2;
-       uint16_t xylogics_readgate;
-       uint16_t xylogics_writecont;
-} __attribute__((packed));
-
-struct sgi_disklabel {
-       uint32_t magic;                 /* magic number */
-       uint16_t root_part_num;         /* # root partition */
-       uint16_t swap_part_num;         /* # swap partition */
-       unsigned char boot_file[16];    /* name of boot file */
-
-       struct sgi_device_parameter     devparam;       /* not used now */
-
-       struct sgi_volume {
-               unsigned char name[8];  /* name of volume */
-               uint32_t block_num;     /* logical block number */
-               uint32_t num_bytes;     /* how big, in bytes */
-       } __attribute__((packed)) volume[15];
-
-       struct sgi_partition {
-               uint32_t num_blocks;    /* size in logical blocks */
-               uint32_t first_block;   /* first logical block */
-               uint32_t type;          /* type of this partition */
-       } __attribute__((packed)) partitions[SGI_MAXPARTITIONS];
-
-       /* checksum is the 32bit 2's complement sum of the disklabel */
-       uint32_t csum;                  /* disk label checksum */
-       uint32_t padding;               /* padding */
-} __attribute__((packed));
-
-static uint32_t count_checksum(struct sgi_disklabel *label)
-{
-       int i;
-       uint32_t *ptr = (uint32_t *) label;
-       uint32_t sum = 0;
-
-       i = sizeof(*label) / sizeof(*ptr);
-
-       while (i--)
-               sum += be32_to_cpu(ptr[i]);
-
-       return sum;
-}
-
+#include "pt-sgi.h"
 
 static int probe_sgi_pt(blkid_probe pr,
                const struct blkid_idmag *mag __attribute__((__unused__)))
@@ -102,7 +28,7 @@ static int probe_sgi_pt(blkid_probe pr,
        if (!l)
                goto nothing;
 
-       if (count_checksum(l)) {
+       if (sgi_pt_checksum(l)) {
                DBG(LOWPROBE, blkid_debug(
                        "detected corrupted sgi disk label -- ignore"));
                goto nothing;
@@ -126,7 +52,7 @@ static int probe_sgi_pt(blkid_probe pr,
                uint32_t type = be32_to_cpu(p->type);
                blkid_partition par;
 
-               if (size == 0 || type == SGI_TYPE_VOLULME ||
+               if (size == 0 || type == SGI_TYPE_ENTIRE_DISK ||
                                 type == SGI_TYPE_VOLHDR) {
                        blkid_partlist_increment_partno(ls);
                        continue;