]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
minix: add version 3 layout
authorDavidlohr Bueso <dave@gnu.org>
Wed, 29 Jun 2011 16:55:18 +0000 (12:55 -0400)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Jul 2011 08:32:36 +0000 (10:32 +0200)
Create a specific minix v3 superblock structure and adjust the attribute
wrapper functions to handle it.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
disk-utils/minix.h

index 0ebaa261e41df706d171eea8c31e10f97f5659d7..fc1d1c05e94d3c24aa5798c6bba8ec339854ae1e 100644 (file)
@@ -47,10 +47,29 @@ struct minix_super_block {
         u32 s_zones;
 };
 
+/* V3 minix super-block data on disk */
+struct minix3_super_block {
+       u32 s_ninodes;
+       u16 s_pad0;
+       u16 s_imap_blocks;
+       u16 s_zmap_blocks;
+       u16 s_firstdatazone;
+       u16 s_log_zone_size;
+       u16 s_pad1;
+       u32 s_max_size;
+       u32 s_zones;
+       u16 s_magic;
+       u16 s_pad2;
+       u16 s_blocksize;
+       u8  s_disk_version;
+        u16 s_state;
+};
+
 #define BLOCK_SIZE_BITS 10
 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
 
-#define NAME_MAX         255   /* # chars in a file name */
+#define NAME_MAX   255   /* # chars in a file name */
+#define MAX_INODES 65535
 
 #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
 #define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
@@ -62,6 +81,7 @@ struct minix_super_block {
 #define MINIX_SUPER_MAGIC2   0x138F          /* minix fs, 30 char names */
 #define MINIX2_SUPER_MAGIC   0x2468         /* minix V2 fs */
 #define MINIX2_SUPER_MAGIC2  0x2478         /* minix V2 fs, 30 char names */
+#define MINIX3_SUPER_MAGIC   0x4d5a          /* minix V3 fs (60 char names) */
 
 #endif /* KERNEL_INCLUDES_ARE_CLEAN */
 
@@ -71,7 +91,7 @@ struct minix_super_block {
 #define INODE_SIZE (sizeof(struct minix_inode))
 #define INODE2_SIZE (sizeof(struct minix2_inode))
 
-int fs_version = 1;
+int fs_version = 1; /* this default value needs to change in a near future */
 char *super_block_buffer, *inode_buffer = NULL;
 
 static char *inode_map;
@@ -85,48 +105,89 @@ static char *zone_map;
  * wrappers to different superblock attributes
  */
 #define Super (*(struct minix_super_block *)super_block_buffer)
+#define Super3 (*(struct minix3_super_block *)super_block_buffer)
 
 static inline unsigned long get_ninodes(void)
 {
-       return (unsigned long) Super.s_ninodes;
+       switch (fs_version) {
+       case 3:
+               return Super3.s_ninodes;
+       default:
+               return (unsigned long) Super.s_ninodes;
+       }
 }
 
 static inline unsigned long get_nzones(void)
 {
-       return (unsigned long) fs_version == 2 ? Super.s_zones : Super.s_nzones;
+       switch (fs_version) {
+       case 3:
+               return (unsigned long) Super3.s_zones;
+       case 2:
+               return (unsigned long) Super.s_zones;
+       default:
+               return (unsigned long) Super.s_nzones;
+       }
 }
 
 static inline unsigned long get_nimaps(void)
 {
-       return (unsigned long)Super.s_imap_blocks;
+       switch (fs_version) {
+       case 3:
+               return (unsigned long) Super3.s_imap_blocks;
+       default:
+               return (unsigned long) Super.s_imap_blocks;
+       }
 }
 
 static inline unsigned long get_nzmaps(void)
 {
-       return (unsigned long)Super.s_zmap_blocks;
+       switch (fs_version) {
+       case 3:
+               return (unsigned long) Super3.s_zmap_blocks;
+       default:
+               return (unsigned long) Super.s_zmap_blocks;
+       }
 }
 
 static inline unsigned long get_first_zone(void)
 {
-       return (unsigned long)Super.s_firstdatazone;
+       switch (fs_version) {
+       case 3:
+               return (unsigned long) Super3.s_firstdatazone;
+       default:
+               return (unsigned long) Super.s_firstdatazone;
+       }
 }
 
 static inline unsigned long get_zone_size(void)
 {
-       return (unsigned long)Super.s_log_zone_size;
+       switch (fs_version) {
+       case 3:
+               return (unsigned long) Super3.s_log_zone_size;
+       default:
+               return (unsigned long) Super.s_log_zone_size;
+       }
 }
 
 static inline unsigned long get_max_size(void)
 {
-       return (unsigned long)Super.s_max_size;
+       switch (fs_version) {
+       case 3:
+               return (unsigned long) Super3.s_max_size;
+       default:
+               return (unsigned long) Super.s_max_size;
+       }
 }
 
 static unsigned long inode_blocks(void)
 {
-       if (fs_version == 2)
+       switch (fs_version) {
+       case 3:
+       case 2:
                return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
-       else
+       default:
                return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
+       }
 }
 
 static inline unsigned long first_zone_data(void)