osf.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * fs/partitions/osf.c
  3. *
  4. * Code extracted from drivers/block/genhd.c
  5. *
  6. * Copyright (C) 1991-1998 Linus Torvalds
  7. * Re-organised Feb 1998 Russell King
  8. */
  9. #include "check.h"
  10. #include "osf.h"
  11. #define MAX_OSF_PARTITIONS 18
  12. int osf_partition(struct parsed_partitions *state)
  13. {
  14. int i;
  15. int slot = 1;
  16. unsigned int npartitions;
  17. Sector sect;
  18. unsigned char *data;
  19. struct disklabel {
  20. __le32 d_magic;
  21. __le16 d_type,d_subtype;
  22. u8 d_typename[16];
  23. u8 d_packname[16];
  24. __le32 d_secsize;
  25. __le32 d_nsectors;
  26. __le32 d_ntracks;
  27. __le32 d_ncylinders;
  28. __le32 d_secpercyl;
  29. __le32 d_secprtunit;
  30. __le16 d_sparespertrack;
  31. __le16 d_sparespercyl;
  32. __le32 d_acylinders;
  33. __le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
  34. __le32 d_headswitch, d_trkseek, d_flags;
  35. __le32 d_drivedata[5];
  36. __le32 d_spare[5];
  37. __le32 d_magic2;
  38. __le16 d_checksum;
  39. __le16 d_npartitions;
  40. __le32 d_bbsize, d_sbsize;
  41. struct d_partition {
  42. __le32 p_size;
  43. __le32 p_offset;
  44. __le32 p_fsize;
  45. u8 p_fstype;
  46. u8 p_frag;
  47. __le16 p_cpg;
  48. } d_partitions[MAX_OSF_PARTITIONS];
  49. } * label;
  50. struct d_partition * partition;
  51. data = read_part_sector(state, 0, &sect);
  52. if (!data)
  53. return -1;
  54. label = (struct disklabel *) (data+64);
  55. partition = label->d_partitions;
  56. if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
  57. put_dev_sector(sect);
  58. return 0;
  59. }
  60. if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
  61. put_dev_sector(sect);
  62. return 0;
  63. }
  64. npartitions = le16_to_cpu(label->d_npartitions);
  65. if (npartitions > MAX_OSF_PARTITIONS) {
  66. put_dev_sector(sect);
  67. return 0;
  68. }
  69. for (i = 0 ; i < npartitions; i++, partition++) {
  70. if (slot == state->limit)
  71. break;
  72. if (le32_to_cpu(partition->p_size))
  73. put_partition(state, slot,
  74. le32_to_cpu(partition->p_offset),
  75. le32_to_cpu(partition->p_size));
  76. slot++;
  77. }
  78. strlcat(state->pp_buf, "\n", PAGE_SIZE);
  79. put_dev_sector(sect);
  80. return 1;
  81. }