^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * fs/partitions/ultrix.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Code extracted from drivers/block/genhd.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Re-organised Jul 1999 Russell King
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "check.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int ultrix_partition(struct parsed_partitions *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Sector sect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) unsigned char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct ultrix_disklabel {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) s32 pt_magic; /* magic no. indicating part. info exits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) s32 pt_valid; /* set by driver if pt is current */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct pt_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) s32 pi_nblocks; /* no. of sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u32 pi_blkoff; /* block offset for start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) } pt_part[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) } *label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define PT_MAGIC 0x032957 /* Partition magic number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define PT_VALID 1 /* Indicates if struct is valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) data = read_part_sector(state, (16384 - sizeof(*label))/512, §);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) for (i=0; i<8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (label->pt_part[i].pi_nblocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) put_partition(state, i+1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) label->pt_part[i].pi_blkoff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) label->pt_part[i].pi_nblocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) put_dev_sector(sect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) strlcat(state->pp_buf, "\n", PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) put_dev_sector(sect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }