diff options
author | Karel Zak | 2010-04-07 11:31:37 +0200 |
---|---|---|
committer | Karel Zak | 2010-04-07 11:31:37 +0200 |
commit | dad504d97c69793a1012dd83897ca530d2160973 (patch) | |
tree | cc3d598727985b65cec9292dc4fe03676d556a4a /shlibs/blkid/src/partitions | |
parent | libblkid: fix 'partno' usage (diff) | |
download | kernel-qcow2-util-linux-dad504d97c69793a1012dd83897ca530d2160973.tar.gz kernel-qcow2-util-linux-dad504d97c69793a1012dd83897ca530d2160973.tar.xz kernel-qcow2-util-linux-dad504d97c69793a1012dd83897ca530d2160973.zip |
libblkid: add ultrix PT support
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/partitions')
-rw-r--r-- | shlibs/blkid/src/partitions/Makefile.am | 1 | ||||
-rw-r--r-- | shlibs/blkid/src/partitions/partitions.c | 1 | ||||
-rw-r--r-- | shlibs/blkid/src/partitions/partitions.h | 1 | ||||
-rw-r--r-- | shlibs/blkid/src/partitions/ultrix.c | 88 |
4 files changed, 91 insertions, 0 deletions
diff --git a/shlibs/blkid/src/partitions/Makefile.am b/shlibs/blkid/src/partitions/Makefile.am index 6af2022ea..f617389d8 100644 --- a/shlibs/blkid/src/partitions/Makefile.am +++ b/shlibs/blkid/src/partitions/Makefile.am @@ -18,4 +18,5 @@ libblkid_partitions_la_SOURCES = partitions.c \ dos.c \ dos.h \ minix.c \ + ultrix.c \ gpt.c diff --git a/shlibs/blkid/src/partitions/partitions.c b/shlibs/blkid/src/partitions/partitions.c index 219a19732..ad0c2f8cf 100644 --- a/shlibs/blkid/src/partitions/partitions.c +++ b/shlibs/blkid/src/partitions/partitions.c @@ -114,6 +114,7 @@ static const struct blkid_idinfo *idinfos[] = &dos_pt_idinfo, &gpt_pt_idinfo, &mac_pt_idinfo, + &ultrix_pt_idinfo, &bsd_pt_idinfo, &unixware_pt_idinfo, &solaris_x86_pt_idinfo, diff --git a/shlibs/blkid/src/partitions/partitions.h b/shlibs/blkid/src/partitions/partitions.h index 2a4d20af5..c4ccd3b65 100644 --- a/shlibs/blkid/src/partitions/partitions.h +++ b/shlibs/blkid/src/partitions/partitions.h @@ -57,5 +57,6 @@ extern const struct blkid_idinfo mac_pt_idinfo; extern const struct blkid_idinfo dos_pt_idinfo; extern const struct blkid_idinfo minix_pt_idinfo; extern const struct blkid_idinfo gpt_pt_idinfo; +extern const struct blkid_idinfo ultrix_pt_idinfo; #endif /* BLKID_PARTITIONS_H */ diff --git a/shlibs/blkid/src/partitions/ultrix.c b/shlibs/blkid/src/partitions/ultrix.c new file mode 100644 index 000000000..cc848d0a6 --- /dev/null +++ b/shlibs/blkid/src/partitions/ultrix.c @@ -0,0 +1,88 @@ +/* + * uktrix partition parsing code + * + * Copyright (C) 2010 Karel Zak <kzak@redhat.com> + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + * + */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdint.h> + +#include "partitions.h" + +#define ULTRIX_MAXPARTITIONS 8 +#define ULTRIX_MAGIC 0x032957 + +/* sector with partition table */ +#define ULTRIX_SECTOR ((16384 - sizeof(struct ultrix_disklabel)) >> 9) +/* position of partition table within ULTRIX_SECTOR */ +#define ULTRIX_OFFSET (512 - sizeof(struct ultrix_disklabel)) + +struct ultrix_disklabel { + int32_t pt_magic; /* magic no. indicating part. info exits */ + int32_t pt_valid; /* set by driver if pt is current */ + struct pt_info { + int32_t pi_nblocks; /* no. of sectors */ + uint32_t pi_blkoff; /* block offset for start */ + } pt_part[ULTRIX_MAXPARTITIONS]; +} __attribute__((packed)); + + +static int probe_ultrix_pt(blkid_probe pr, const struct blkid_idmag *mag) +{ + unsigned char *data; + struct ultrix_disklabel *l; + blkid_parttable tab = NULL; + blkid_partlist ls; + int i; + + data = blkid_probe_get_sector(pr, ULTRIX_SECTOR); + if (!data) + goto nothing; + + l = (struct ultrix_disklabel *) (data + ULTRIX_OFFSET); + + if (l->pt_magic != ULTRIX_MAGIC || l->pt_valid != 1) + goto nothing; + + if (blkid_partitions_need_typeonly(pr)) + /* caller does not ask for details about partitions */ + return 0; + + ls = blkid_probe_get_partlist(pr); + if (!ls) + goto err; + + tab = blkid_partlist_new_parttable(ls, "ultrix", 0); + if (!tab) + goto err; + + for (i = 0; i < ULTRIX_MAXPARTITIONS; i++) { + if (!l->pt_part[i].pi_nblocks) + blkid_partlist_increment_partno(ls); + else { + if (!blkid_partlist_add_partition(ls, tab, + l->pt_part[i].pi_blkoff, + l->pt_part[i].pi_nblocks)) + goto err; + } + } + + return 0; +nothing: + return 1; +err: + return -1; +} + +const struct blkid_idinfo ultrix_pt_idinfo = +{ + .name = "ultrix", + .probefunc = probe_ultrix_pt, + .magics = BLKID_NONE_MAGIC +}; + |