ultrix.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * fs/partitions/ultrix.c
  4. *
  5. * Code extracted from drivers/block/genhd.c
  6. *
  7. * Re-organised Jul 1999 Russell King
  8. */
  9. #include "check.h"
  10. #include "ultrix.h"
  11. int ultrix_partition(struct parsed_partitions *state)
  12. {
  13. int i;
  14. Sector sect;
  15. unsigned char *data;
  16. struct ultrix_disklabel {
  17. s32 pt_magic; /* magic no. indicating part. info exits */
  18. s32 pt_valid; /* set by driver if pt is current */
  19. struct pt_info {
  20. s32 pi_nblocks; /* no. of sectors */
  21. u32 pi_blkoff; /* block offset for start */
  22. } pt_part[8];
  23. } *label;
  24. #define PT_MAGIC 0x032957 /* Partition magic number */
  25. #define PT_VALID 1 /* Indicates if struct is valid */
  26. data = read_part_sector(state, (16384 - sizeof(*label))/512, &sect);
  27. if (!data)
  28. return -1;
  29. label = (struct ultrix_disklabel *)(data + 512 - sizeof(*label));
  30. if (label->pt_magic == PT_MAGIC && label->pt_valid == PT_VALID) {
  31. for (i=0; i<8; i++)
  32. if (label->pt_part[i].pi_nblocks)
  33. put_partition(state, i+1,
  34. label->pt_part[i].pi_blkoff,
  35. label->pt_part[i].pi_nblocks);
  36. put_dev_sector(sect);
  37. strlcat(state->pp_buf, "\n", PAGE_SIZE);
  38. return 1;
  39. } else {
  40. put_dev_sector(sect);
  41. return 0;
  42. }
  43. }