karma.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. int karma_partition(struct parsed_partitions *state, struct block_device *bdev)
  11. {
  12. int i;
  13. int slot = 1;
  14. Sector sect;
  15. unsigned char *data;
  16. struct disklabel {
  17. u8 d_reserved[270];
  18. struct d_partition {
  19. __le32 p_res;
  20. u8 p_fstype;
  21. u8 p_res2[3];
  22. __le32 p_offset;
  23. __le32 p_size;
  24. } d_partitions[2];
  25. u8 d_blank[208];
  26. __le16 d_magic;
  27. } __attribute__((packed)) *label;
  28. struct d_partition *p;
  29. data = read_dev_sector(bdev, 0, &sect);
  30. if (!data)
  31. return -1;
  32. label = (struct disklabel *)data;
  33. if (le16_to_cpu(label->d_magic) != KARMA_LABEL_MAGIC) {
  34. put_dev_sector(sect);
  35. return 0;
  36. }
  37. p = label->d_partitions;
  38. for (i = 0 ; i < 2; i++, p++) {
  39. if (slot == state->limit)
  40. break;
  41. if (p->p_fstype == 0x4d && le32_to_cpu(p->p_size)) {
  42. put_partition(state, slot, le32_to_cpu(p->p_offset),
  43. le32_to_cpu(p->p_size));
  44. }
  45. slot++;
  46. }
  47. printk("\n");
  48. put_dev_sector(sect);
  49. return 1;
  50. }