13
13
#include <stdint.h>
15
15
#include "partitions.h"
17
#define SGI_MAXPARTITIONS 16
20
#define SGI_TYPE_VOLHDR 0x00
21
#define SGI_TYPE_VOLULME 0x06 /* entire disk */
23
struct sgi_device_parameter {
27
unsigned char sparecyl;
31
uint16_t ntrks; /* tracks in cyl 0 or vol 0 */
33
unsigned char cmd_tag_queue_depth;
34
unsigned char unused0;
37
uint16_t nsect; /* sectors/tracks in cyl 0 or vol 0 */
40
uint32_t flags; /* controller flags */
42
uint32_t retries_on_error;
44
uint16_t xylogics_gap1;
45
uint16_t xylogics_syncdelay;
46
uint16_t xylogics_readdelay;
47
uint16_t xylogics_gap2;
48
uint16_t xylogics_readgate;
49
uint16_t xylogics_writecont;
50
} __attribute__((packed));
52
struct sgi_disklabel {
53
uint32_t magic; /* magic number */
54
uint16_t root_part_num; /* # root partition */
55
uint16_t swap_part_num; /* # swap partition */
56
unsigned char boot_file[16]; /* name of boot file */
58
struct sgi_device_parameter devparam; /* not used now */
61
unsigned char name[8]; /* name of volume */
62
uint32_t block_num; /* logical block number */
63
uint32_t num_bytes; /* how big, in bytes */
64
} __attribute__((packed)) volume[15];
66
struct sgi_partition {
67
uint32_t num_blocks; /* size in logical blocks */
68
uint32_t first_block; /* first logical block */
69
uint32_t type; /* type of this partition */
70
} __attribute__((packed)) partitions[SGI_MAXPARTITIONS];
72
/* checksum is the 32bit 2's complement sum of the disklabel */
73
uint32_t csum; /* disk label checksum */
74
uint32_t padding; /* padding */
75
} __attribute__((packed));
77
static uint32_t count_checksum(struct sgi_disklabel *label)
80
uint32_t *ptr = (uint32_t *) label;
83
i = sizeof(*label) / sizeof(*ptr);
86
sum += be32_to_cpu(ptr[i]);
92
18
static int probe_sgi_pt(blkid_probe pr,
93
19
const struct blkid_idmag *mag __attribute__((__unused__)))
101
27
l = (struct sgi_disklabel *) blkid_probe_get_sector(pr, 0);
105
if (count_checksum(l)) {
106
DBG(DEBUG_LOWPROBE, printf(
107
"detected corrupted sgi disk label -- ignore\n"));
34
if (sgi_pt_checksum(l)) {
35
DBG(LOWPROBE, ul_debug(
36
"detected corrupted sgi disk label -- ignore"));
111
40
if (blkid_partitions_need_typeonly(pr))
112
41
/* caller does not ask for details about partitions */
42
return BLKID_PROBE_OK;
115
44
ls = blkid_probe_get_partlist(pr);
119
48
tab = blkid_partlist_new_parttable(ls, "sgi", 0);