2
* unixware partition parsing code
4
* Copyright (C) 2009 Karel Zak <kzak@redhat.com>
6
* This file may be redistributed under the terms of the
7
* GNU Lesser General Public License.
10
* The intersting information about unixware PT:
11
* - Linux kernel / partx
12
* - vtoc(7) SCO UNIX command man page
13
* - evms source code (http://evms.sourceforge.net/)
14
* - vxtools source code (http://martin.hinner.info/fs/vxfs/)
21
#include "partitions.h"
23
/* disklabel location */
24
#define UNIXWARE_SECTOR 29
25
#define UNIXWARE_OFFSET (UNIXWARE_SECTOR << 9) /* offset in bytes */
26
#define UNIXWARE_KBOFFSET (UNIXWARE_OFFSET >> 10) /* offset in 1024-blocks */
28
/* disklabel->d_magic offset within the last 1024 block */
29
#define UNIXWARE_MAGICOFFSET (UNIXWARE_OFFSET - UNIXWARE_KBOFFSET + 4)
31
#define UNIXWARE_VTOCMAGIC 0x600DDEEEUL
32
#define UNIXWARE_MAXPARTITIONS 16
34
/* unixware_partition->s_label flags */
35
#define UNIXWARE_TAG_UNUSED 0x0000 /* unused partition */
36
#define UNIXWARE_TAG_BOOT 0x0001 /* boot fs */
37
#define UNIXWARE_TAG_ROOT 0x0002 /* root fs */
38
#define UNIXWARE_TAG_SWAP 0x0003 /* swap fs */
39
#define UNIXWARE_TAG_USER 0x0004 /* user fs */
40
#define UNIXWARE_TAG_ENTIRE_DISK 0x0005 /* whole disk */
41
#define UNIXWARE_TAG_ALT_S 0x0006 /* alternate sector space */
42
#define UNIXWARE_TAG_OTHER 0x0007 /* non unix */
43
#define UNIXWARE_TAG_ALT_T 0x0008 /* alternate track space */
44
#define UNIXWARE_TAG_STAND 0x0009 /* stand partition */
45
#define UNIXWARE_TAG_VAR 0x000a /* var partition */
46
#define UNIXWARE_TAG_HOME 0x000b /* home partition */
47
#define UNIXWARE_TAG_DUMP 0x000c /* dump partition */
48
#define UNIXWARE_TAG_ALT_ST 0x000d /* alternate sector track */
49
#define UNIXWARE_TAG_VM_PUBLIC 0x000e /* volume mgt public partition */
50
#define UNIXWARE_TAG_VM_PRIVATE 0x000f /* volume mgt private partition */
53
/* unixware_partition->s_flags flags */
54
#define UNIXWARE_FLAG_VALID 0x0200
56
struct unixware_partition {
57
uint16_t s_label; /* partition label (tag) */
58
uint16_t s_flags; /* permission flags */
59
uint32_t start_sect; /* starting sector */
60
uint32_t nr_sects; /* number of sectors */
61
} __attribute__((packed));
63
struct unixware_disklabel {
64
uint32_t d_type; /* drive type */
65
uint32_t d_magic; /* the magic number */
66
uint32_t d_version; /* version number */
67
char d_serial[12]; /* serial number of the device */
68
uint32_t d_ncylinders; /* # of data cylinders per device */
69
uint32_t d_ntracks; /* # of tracks per cylinder */
70
uint32_t d_nsectors; /* # of data sectors per track */
71
uint32_t d_secsize; /* # of bytes per sector */
72
uint32_t d_part_start; /* # of first sector of this partition */
73
uint32_t d_unknown1[12]; /* ? */
74
uint32_t d_alt_tbl; /* byte offset of alternate table */
75
uint32_t d_alt_len; /* byte length of alternate table */
76
uint32_t d_phys_cyl; /* # of physical cylinders per device */
77
uint32_t d_phys_trk; /* # of physical tracks per cylinder */
78
uint32_t d_phys_sec; /* # of physical sectors per track */
79
uint32_t d_phys_bytes; /* # of physical bytes per sector */
80
uint32_t d_unknown2; /* ? */
81
uint32_t d_unknown3; /* ? */
82
uint32_t d_pad[8]; /* pad */
84
struct unixware_vtoc {
85
uint32_t v_magic; /* the magic number */
86
uint32_t v_version; /* version number */
87
char v_name[8]; /* volume name */
88
uint16_t v_nslices; /* # of partitions */
89
uint16_t v_unknown1; /* ? */
90
uint32_t v_reserved[10]; /* reserved */
92
struct unixware_partition
93
v_slice[UNIXWARE_MAXPARTITIONS]; /* partition */
94
} __attribute__((packed)) vtoc;
97
static int probe_unixware_pt(blkid_probe pr, const struct blkid_idmag *mag)
99
struct unixware_disklabel *l;
100
struct unixware_partition *p;
101
blkid_parttable tab = NULL;
102
blkid_partition parent;
106
l = (struct unixware_disklabel *)
107
blkid_probe_get_sector(pr, UNIXWARE_SECTOR);
111
if (le32_to_cpu(l->vtoc.v_magic) != UNIXWARE_VTOCMAGIC)
114
if (blkid_partitions_need_typeonly(pr))
115
/* caller does not ask for details about partitions */
118
ls = blkid_probe_get_partlist(pr);
122
parent = blkid_partlist_get_parent(ls);
124
tab = blkid_partlist_new_parttable(ls, "unixware", UNIXWARE_OFFSET);
128
/* Skip the first partition that describe whole disk
130
for (i = 1, p = &l->vtoc.v_slice[1];
131
i < UNIXWARE_MAXPARTITIONS; i++, p++) {
133
uint32_t start, size;
137
tag = le16_to_cpu(p->s_label);
138
flg = le16_to_cpu(p->s_flags);
140
if (tag == UNIXWARE_TAG_UNUSED ||
141
tag == UNIXWARE_TAG_ENTIRE_DISK ||
142
flg != UNIXWARE_FLAG_VALID)
145
start = le32_to_cpu(p->start_sect);
146
size = le32_to_cpu(p->nr_sects);
148
if (parent && !blkid_is_nested_dimension(parent, start, size)) {
149
DBG(DEBUG_LOWPROBE, printf(
150
"WARNING: unixware partition (%d) overflow "
151
"detected, ignore\n", i));
155
par = blkid_partlist_add_partition(ls, tab, start, size);
159
blkid_partition_set_type(par, tag);
160
blkid_partition_set_flags(par, flg);
173
* The unixware partition table is within primary DOS partition. The PT is
174
* located on 29 sector, PT magic string is d_magic member of 'struct
175
* unixware_disklabel'.
177
const struct blkid_idinfo unixware_pt_idinfo =
180
.probefunc = probe_unixware_pt,
181
.minsz = 1024 * 1440 + 1, /* ignore floppies */
185
.magic = "\x0D\x60\xE5\xCA", /* little-endian magic string */
186
.len = 4, /* d_magic size in bytes */
187
.kboff = UNIXWARE_KBOFFSET,
188
.sboff = UNIXWARE_MAGICOFFSET