0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "check.h"
0012
0013 #define MAX_OSF_PARTITIONS 18
0014 #define DISKLABELMAGIC (0x82564557UL)
0015
0016 int osf_partition(struct parsed_partitions *state)
0017 {
0018 int i;
0019 int slot = 1;
0020 unsigned int npartitions;
0021 Sector sect;
0022 unsigned char *data;
0023 struct disklabel {
0024 __le32 d_magic;
0025 __le16 d_type,d_subtype;
0026 u8 d_typename[16];
0027 u8 d_packname[16];
0028 __le32 d_secsize;
0029 __le32 d_nsectors;
0030 __le32 d_ntracks;
0031 __le32 d_ncylinders;
0032 __le32 d_secpercyl;
0033 __le32 d_secprtunit;
0034 __le16 d_sparespertrack;
0035 __le16 d_sparespercyl;
0036 __le32 d_acylinders;
0037 __le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
0038 __le32 d_headswitch, d_trkseek, d_flags;
0039 __le32 d_drivedata[5];
0040 __le32 d_spare[5];
0041 __le32 d_magic2;
0042 __le16 d_checksum;
0043 __le16 d_npartitions;
0044 __le32 d_bbsize, d_sbsize;
0045 struct d_partition {
0046 __le32 p_size;
0047 __le32 p_offset;
0048 __le32 p_fsize;
0049 u8 p_fstype;
0050 u8 p_frag;
0051 __le16 p_cpg;
0052 } d_partitions[MAX_OSF_PARTITIONS];
0053 } * label;
0054 struct d_partition * partition;
0055
0056 data = read_part_sector(state, 0, §);
0057 if (!data)
0058 return -1;
0059
0060 label = (struct disklabel *) (data+64);
0061 partition = label->d_partitions;
0062 if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
0063 put_dev_sector(sect);
0064 return 0;
0065 }
0066 if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
0067 put_dev_sector(sect);
0068 return 0;
0069 }
0070 npartitions = le16_to_cpu(label->d_npartitions);
0071 if (npartitions > MAX_OSF_PARTITIONS) {
0072 put_dev_sector(sect);
0073 return 0;
0074 }
0075 for (i = 0 ; i < npartitions; i++, partition++) {
0076 if (slot == state->limit)
0077 break;
0078 if (le32_to_cpu(partition->p_size))
0079 put_partition(state, slot,
0080 le32_to_cpu(partition->p_offset),
0081 le32_to_cpu(partition->p_size));
0082 slot++;
0083 }
0084 strlcat(state->pp_buf, "\n", PAGE_SIZE);
0085 put_dev_sector(sect);
0086 return 1;
0087 }