karma.c 1.1 KB

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