osf.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. int osf_partition(struct parsed_partitions *state, struct block_device *bdev)
  12. {
  13. int i;
  14. int slot = 1;
  15. Sector sect;
  16. unsigned char *data;
  17. struct disklabel {
  18. __le32 d_magic;
  19. __le16 d_type,d_subtype;
  20. u8 d_typename[16];
  21. u8 d_packname[16];
  22. __le32 d_secsize;
  23. __le32 d_nsectors;
  24. __le32 d_ntracks;
  25. __le32 d_ncylinders;
  26. __le32 d_secpercyl;
  27. __le32 d_secprtunit;
  28. __le16 d_sparespertrack;
  29. __le16 d_sparespercyl;
  30. __le32 d_acylinders;
  31. __le16 d_rpm, d_interleave, d_trackskew, d_cylskew;
  32. __le32 d_headswitch, d_trkseek, d_flags;
  33. __le32 d_drivedata[5];
  34. __le32 d_spare[5];
  35. __le32 d_magic2;
  36. __le16 d_checksum;
  37. __le16 d_npartitions;
  38. __le32 d_bbsize, d_sbsize;
  39. struct d_partition {
  40. __le32 p_size;
  41. __le32 p_offset;
  42. __le32 p_fsize;
  43. u8 p_fstype;
  44. u8 p_frag;
  45. __le16 p_cpg;
  46. } d_partitions[8];
  47. } * label;
  48. struct d_partition * partition;
  49. data = read_dev_sector(bdev, 0, &sect);
  50. if (!data)
  51. return -1;
  52. label = (struct disklabel *) (data+64);
  53. partition = label->d_partitions;
  54. if (le32_to_cpu(label->d_magic) != DISKLABELMAGIC) {
  55. put_dev_sector(sect);
  56. return 0;
  57. }
  58. if (le32_to_cpu(label->d_magic2) != DISKLABELMAGIC) {
  59. put_dev_sector(sect);
  60. return 0;
  61. }
  62. for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {
  63. if (slot == state->limit)
  64. break;
  65. if (le32_to_cpu(partition->p_size))
  66. put_partition(state, slot,
  67. le32_to_cpu(partition->p_offset),
  68. le32_to_cpu(partition->p_size));
  69. slot++;
  70. }
  71. printk("\n");
  72. put_dev_sector(sect);
  73. return 1;
  74. }