sysv68.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * fs/partitions/sysv68.c
  3. *
  4. * Copyright (C) 2007 Philippe De Muyter <phdm@macqel.be>
  5. */
  6. #include "check.h"
  7. #include "sysv68.h"
  8. /*
  9. * Volume ID structure: on first 256-bytes sector of disk
  10. */
  11. struct volumeid {
  12. u8 vid_unused[248];
  13. u8 vid_mac[8]; /* ASCII string "MOTOROLA" */
  14. };
  15. /*
  16. * config block: second 256-bytes sector on disk
  17. */
  18. struct dkconfig {
  19. u8 ios_unused0[128];
  20. __be32 ios_slcblk; /* Slice table block number */
  21. __be16 ios_slccnt; /* Number of entries in slice table */
  22. u8 ios_unused1[122];
  23. };
  24. /*
  25. * combined volumeid and dkconfig block
  26. */
  27. struct dkblk0 {
  28. struct volumeid dk_vid;
  29. struct dkconfig dk_ios;
  30. };
  31. /*
  32. * Slice Table Structure
  33. */
  34. struct slice {
  35. __be32 nblocks; /* slice size (in blocks) */
  36. __be32 blkoff; /* block offset of slice */
  37. };
  38. int sysv68_partition(struct parsed_partitions *state)
  39. {
  40. int i, slices;
  41. int slot = 1;
  42. Sector sect;
  43. unsigned char *data;
  44. struct dkblk0 *b;
  45. struct slice *slice;
  46. char tmp[64];
  47. data = read_part_sector(state, 0, &sect);
  48. if (!data)
  49. return -1;
  50. b = (struct dkblk0 *)data;
  51. if (memcmp(b->dk_vid.vid_mac, "MOTOROLA", sizeof(b->dk_vid.vid_mac))) {
  52. put_dev_sector(sect);
  53. return 0;
  54. }
  55. slices = be16_to_cpu(b->dk_ios.ios_slccnt);
  56. i = be32_to_cpu(b->dk_ios.ios_slcblk);
  57. put_dev_sector(sect);
  58. data = read_part_sector(state, i, &sect);
  59. if (!data)
  60. return -1;
  61. slices -= 1; /* last slice is the whole disk */
  62. snprintf(tmp, sizeof(tmp), "sysV68: %s(s%u)", state->name, slices);
  63. strlcat(state->pp_buf, tmp, PAGE_SIZE);
  64. slice = (struct slice *)data;
  65. for (i = 0; i < slices; i++, slice++) {
  66. if (slot == state->limit)
  67. break;
  68. if (be32_to_cpu(slice->nblocks)) {
  69. put_partition(state, slot,
  70. be32_to_cpu(slice->blkoff),
  71. be32_to_cpu(slice->nblocks));
  72. snprintf(tmp, sizeof(tmp), "(s%u)", i);
  73. strlcat(state->pp_buf, tmp, PAGE_SIZE);
  74. }
  75. slot++;
  76. }
  77. strlcat(state->pp_buf, "\n", PAGE_SIZE);
  78. put_dev_sector(sect);
  79. return 1;
  80. }