minix.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * volume_id - reads filesystem label and uuid
  3. *
  4. * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. //config:config FEATURE_VOLUMEID_MINIX
  21. //config: bool "minix filesystem"
  22. //config: default y
  23. //config: depends on VOLUMEID
  24. //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_MINIX) += minix.o
  25. #include "volume_id_internal.h"
  26. struct minix_super_block {
  27. uint16_t s_ninodes;
  28. uint16_t s_nzones;
  29. uint16_t s_imap_blocks;
  30. uint16_t s_zmap_blocks;
  31. uint16_t s_firstdatazone;
  32. uint16_t s_log_zone_size;
  33. uint32_t s_max_size;
  34. uint16_t s_magic;
  35. uint16_t s_state;
  36. uint32_t s_zones;
  37. } PACKED;
  38. /* V3 minix super-block data on disk */
  39. struct minix3_super_block {
  40. uint32_t s_ninodes;
  41. uint16_t s_pad0;
  42. uint16_t s_imap_blocks;
  43. uint16_t s_zmap_blocks;
  44. uint16_t s_firstdatazone;
  45. uint16_t s_log_zone_size;
  46. uint16_t s_pad1;
  47. uint32_t s_max_size;
  48. uint32_t s_zones;
  49. uint16_t s_magic;
  50. uint16_t s_pad2;
  51. uint16_t s_blocksize;
  52. uint8_t s_disk_version;
  53. } PACKED;
  54. #define MINIX_SUPERBLOCK_OFFSET 0x400
  55. int FAST_FUNC volume_id_probe_minix(struct volume_id *id /*, uint64_t off*/)
  56. {
  57. #define off ((uint64_t)0)
  58. struct minix_super_block *ms;
  59. struct minix3_super_block *ms3;
  60. dbg("probing at offset 0x%llx", (unsigned long long) off);
  61. ms = volume_id_get_buffer(id, off + MINIX_SUPERBLOCK_OFFSET, 0x200);
  62. if (ms == NULL)
  63. return -1;
  64. if (ms->s_magic == cpu_to_le16(0x137F)) /* minix V1 fs, 14 char names */
  65. goto found;
  66. if (ms->s_magic == cpu_to_le16(0x138F)) /* minix V1 fs, 30 char names */
  67. goto found;
  68. if (ms->s_magic == cpu_to_le16(0x2468)) /* minix V2 fs, 14 char names */
  69. goto found;
  70. if (ms->s_magic == cpu_to_le16(0x2478)) /* minix V2 fs, 30 char names */
  71. goto found;
  72. ms3 = (void*)ms;
  73. if (ms3->s_magic == cpu_to_le16(0x4d5a)) /* minix V3 fs, 60 char names */
  74. goto found;
  75. return -1;
  76. found:
  77. // volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
  78. IF_FEATURE_BLKID_TYPE(id->type = "minix";)
  79. return 0;
  80. }