Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 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" |
Adrian Bunk | a70cf17 | 2005-11-08 16:49:14 +0100 | [diff] [blame] | 11 | #include "ultrix.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Tejun Heo | 1493bf2 | 2010-05-15 20:09:30 +0200 | [diff] [blame] | 13 | int ultrix_partition(struct parsed_partitions *state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | { |
| 15 | int i; |
| 16 | Sector sect; |
| 17 | unsigned char *data; |
| 18 | struct ultrix_disklabel { |
| 19 | s32 pt_magic; /* magic no. indicating part. info exits */ |
| 20 | s32 pt_valid; /* set by driver if pt is current */ |
| 21 | struct pt_info { |
| 22 | s32 pi_nblocks; /* no. of sectors */ |
| 23 | u32 pi_blkoff; /* block offset for start */ |
| 24 | } pt_part[8]; |
| 25 | } *label; |
| 26 | |
| 27 | #define PT_MAGIC 0x032957 /* Partition magic number */ |
| 28 | #define PT_VALID 1 /* Indicates if struct is valid */ |
| 29 | |
Tejun Heo | 1493bf2 | 2010-05-15 20:09:30 +0200 | [diff] [blame] | 30 | data = read_part_sector(state, (16384 - sizeof(*label))/512, §); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | if (!data) |
| 32 | return -1; |
| 33 | |
| 34 | label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label)); |
| 35 | |
| 36 | if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) { |
| 37 | for (i=0; i<8; i++) |
| 38 | if (label->pt_part[i].pi_nblocks) |
| 39 | put_partition(state, i+1, |
| 40 | label->pt_part[i].pi_blkoff, |
| 41 | label->pt_part[i].pi_nblocks); |
| 42 | put_dev_sector(sect); |
Alexey Dobriyan | 9c867fb | 2010-08-10 18:03:14 -0700 | [diff] [blame] | 43 | strlcat(state->pp_buf, "\n", PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | return 1; |
| 45 | } else { |
| 46 | put_dev_sector(sect); |
| 47 | return 0; |
| 48 | } |
| 49 | } |