blob: 4aaa81043ca0a998e0becf89631071689ad13cee [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * fs/partitions/ultrix.c
4 *
5 * Code extracted from drivers/block/genhd.c
6 *
7 * Re-organised Jul 1999 Russell King
8 */
9
10#include "check.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Tejun Heo1493bf22010-05-15 20:09:30 +020012int ultrix_partition(struct parsed_partitions *state)
Linus Torvalds1da177e2005-04-16 15:20:36 -070013{
14 int i;
15 Sector sect;
16 unsigned char *data;
17 struct ultrix_disklabel {
18 s32 pt_magic; /* magic no. indicating part. info exits */
19 s32 pt_valid; /* set by driver if pt is current */
20 struct pt_info {
21 s32 pi_nblocks; /* no. of sectors */
22 u32 pi_blkoff; /* block offset for start */
23 } pt_part[8];
24 } *label;
25
26#define PT_MAGIC 0x032957 /* Partition magic number */
27#define PT_VALID 1 /* Indicates if struct is valid */
28
Tejun Heo1493bf22010-05-15 20:09:30 +020029 data = read_part_sector(state, (16384 - sizeof(*label))/512, &sect);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 if (!data)
31 return -1;
32
33 label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
34
35 if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
36 for (i=0; i<8; i++)
37 if (label->pt_part[i].pi_nblocks)
38 put_partition(state, i+1,
39 label->pt_part[i].pi_blkoff,
40 label->pt_part[i].pi_nblocks);
41 put_dev_sector(sect);
Alexey Dobriyan9c867fb2010-08-10 18:03:14 -070042 strlcat(state->pp_buf, "\n", PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 return 1;
44 } else {
45 put_dev_sector(sect);
46 return 0;
47 }
48}