^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/karma.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Rio Karma partition info.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2006 Bob Copeland (me@bobcopeland.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * based on osf.c
^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) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define KARMA_LABEL_MAGIC 0xAB56
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int karma_partition(struct parsed_partitions *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) int slot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) Sector sect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) unsigned char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct disklabel {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) u8 d_reserved[270];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct d_partition {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) __le32 p_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) u8 p_fstype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) u8 p_res2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) __le32 p_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __le32 p_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) } d_partitions[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u8 d_blank[208];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) __le16 d_magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) } __packed *label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct d_partition *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) data = read_part_sector(state, 0, §);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) label = (struct disklabel *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (le16_to_cpu(label->d_magic) != KARMA_LABEL_MAGIC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) put_dev_sector(sect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) p = label->d_partitions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) for (i = 0 ; i < 2; i++, p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (slot == state->limit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) if (p->p_fstype == 0x4d && le32_to_cpu(p->p_size)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) put_partition(state, slot, le32_to_cpu(p->p_offset),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) le32_to_cpu(p->p_size));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) slot++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) strlcat(state->pp_buf, "\n", PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) put_dev_sector(sect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)