sysv68.c 1.9 KB

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