karma.c 1.1 KB

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