minix filesystem: Update to V3
This patch is the exact copy of the patch posted by me to comp.os.minix on January 11:
http://groups.google.com/group/comp.os.minix/browse_thread/thread/dcb26c98757137de
That post was complemented on January 14 for 2.4.x kernels:
Since then, no feedback at all has come up to me. So I optimistically adhere to the principle "no news, good news", because I know that the patch works!
I submit this patch to the members of the list and kernel mantainers for their evaluation and comments, and if found appropiate, to include it into the kernel sources.
The modifications I have made to the preexistent code have been four:
1.- The layout of the superblock variables is different in version V3.
2.- Disable writings to "s_state" because it has been droped out from the superblock, and its former address is now used by another parameter.
3.- Change the references to the constant "BLOCK_SIZE" to the variables "s_blocksize" or "b_size", so allowing for multiple size blocks.
4.- Introduce the new structure "minix3_dir_entry" to cope with the padding that is needed to employ 60 characters long names in the new directory entries of 64 bytes.
Both patches follow, attached as text files: "V3_2dot6_patch.txt" and "V3_2dot4_patch.txt"
fs/minix/bitmap.c +5 -5
@@ -26,14 +26,14 @@for (i=0 ; i<numblocks-1 ; i++) {if (!(bh=map[i]))return (0 ); -for (j=0 ; j<BLOCK_SIZE ; j++) +for (j=0 ; j<bh->b_size; j++) sum += nibblemap[bh->b_data[j] &0xf ] + nibblemap[(bh->b_data[j]>>4 ) &0xf ]; }if (numblocks==0 || !(bh=map[numblocks-1 ]))return (0 ); - i = ((numbits-(numblocks-1 )*BLOCK_SIZE *8 )/16 )*2 ; + i = ((numbits-(numblocks-1 )*bh->b_size*8 )/16 )*2 ;for (j=0 ; j<i; j++) { sum += nibblemap[bh->b_data[j] &0xf ] + nibblemap[(bh->b_data[j]>>4 ) &0xf ];
@@ -145,15 +145,15 @@return NULL ; } ino--; - block =2 + sbi->s_imap_blocks + sbi->s_zmap_blocks + - ino /MINIX2_INODES_PER_BLOCK ; + block =2 + sbi->s_imap_blocks + sbi->s_zmap_blocks + + ino /MINIX2_INODES_PER_BLOCK (sb->s_blocksize); *bh =sb_bread (sb, block);if (!*bh) {printk ("unable to read i-node block\n" );return NULL ; } p = (void *)(*bh)->b_data; -return p + ino %MINIX2_INODES_PER_BLOCK ; +return p + ino %MINIX2_INODES_PER_BLOCK (sb->s_blocksize); }/* Clear the link count and mode of a deleted inode on disk. */
fs/minix/dir.c +84 -31
208 lines not on this page · raw message
fs/minix/inode.c +45 -21
120 lines not on this page · raw message
fs/minix/itree_common.c +4 -3
@@ -23,7 +23,7 @@static inline block_t *block_end (struct buffer_head *bh) { -return (block_t *)((char *)bh->b_data +BLOCK_SIZE ); +return (block_t *)((char *)bh->b_data + bh->b_size); } static inline Indirect *get_branch(struct inode *inode,
@@ -85,7 +85,7 @@ branch[n].key =cpu_to_block (nr); bh =sb_getblk (inode->i_sb, parent);lock_buffer (bh); -memset (bh->b_data,0 ,BLOCK_SIZE ); +memset (bh->b_data,0 , bh->b_size); branch[n].bh = bh; branch[n].p = (block_t *) bh->b_data + offsets[n]; *branch[n].p = branch[n].key;
@@ -292,6 +292,7 @@static inline void truncate (struct inode * inode) { +struct super_block * sb = inode->i_sb;block_t *idata =i_data (inode);int offsets[DEPTH ];Indirect chain[DEPTH ];
@@ -301,7 +302,7 @@int first_whole;long iblock; - iblock = (inode->i_size +BLOCK_SIZE -1 ) >>10 ; + iblock = (inode->i_size + sb->s_blocksize -1 ) >>10 ;block_truncate_page (inode->i_mapping, inode->i_size, get_block); n =block_to_path (inode, iblock, offsets);
fs/minix/minix.h +1 -0
@@ -12,6 +12,7 @@#define MINIX_V1 0x0001/* original minix fs */ #define MINIX_V2 0x0002/* minix V2 fs */ +#define MINIX_V3 0x0003/* minix V3 fs */ /* * minix fs inode data in memory
include/linux/minix_fs.h +7 -1
@@ -23,11 +23,12 @@#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 */ #define MINIX_VALID_FS 0x0001/* Clean fs. */ #define MINIX_ERROR_FS 0x0002/* fs has errors. */ #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) -#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode))) +#define MINIX2_INODES_PER_BLOCK (b) ((b)/(sizeof (struct minix2_inode)))/* * This is the original minix inode layout on disk.
@@ -82,4 +83,9 @@ char name[0]; }; +struct minix3_dir_entry { +__u16 inode; +__u16 padding; +char name[0 ]; +};#endif
fs/minix/bitmap.c +4 -4
@@ -27,14 +27,14 @@for (i=0 ; i<numblocks-1 ; i++) {if (!(bh=map[i]))return (0 ); -for (j=0 ; j<BLOCK_SIZE ; j++) +for (j=0 ; j<bh->b_size; j++) sum += nibblemap[bh->b_data[j] &0xf ] + nibblemap[(bh->b_data[j]>>4 ) &0xf ]; }if (numblocks==0 || !(bh=map[numblocks-1 ]))return (0 ); - i = ((numbits-(numblocks-1 )*BLOCK_SIZE *8 )/16 )*2 ; + i = ((numbits-(numblocks-1 )*bh->b_size*8 )/16 )*2 ;for (j=0 ; j<i; j++) { sum += nibblemap[bh->b_data[j] &0xf ] + nibblemap[(bh->b_data[j]>>4 ) &0xf ];
@@ -157,14 +157,14 @@ } ino--; block =2 + sbi->s_imap_blocks + sbi->s_zmap_blocks + - ino /MINIX2_INODES_PER_BLOCK ; + ino /MINIX2_INODES_PER_BLOCK (sb->s_blocksize); *bh =sb_bread (sb, block);if (!*bh) {printk ("unable to read i-node block\n" );return NULL ; } p = (void *)(*bh)->b_data; -return p + ino %MINIX2_INODES_PER_BLOCK ; +return p + ino %MINIX2_INODES_PER_BLOCK (sb->s_blocksize); }/* Clear the link count and mode of a deleted inode on disk. */
fs/minix/dir.c +86 -32
206 lines not on this page · raw message
fs/minix/inode.c +47 -26
144 lines not on this page · raw message
fs/minix/itree_common.c +4 -3
@@ -21,7 +21,7 @@static inline block_t *block_end (struct buffer_head *bh) { -return (block_t *)((char *)bh->b_data +BLOCK_SIZE ); +return (block_t *)((char *)bh->b_data + bh->b_size); } static inline Indirect *get_branch(struct inode *inode,
@@ -81,7 +81,7 @@ branch[n].key =cpu_to_block (nr); bh =sb_getblk (inode->i_sb, parent);lock_buffer (bh); -memset (bh->b_data,0 ,BLOCK_SIZE ); +memset (bh->b_data,0 , bh->b_size); branch[n].bh = bh; branch[n].p = (block_t *) bh->b_data + offsets[n]; *branch[n].p = branch[n].key;
@@ -292,6 +292,7 @@static inline void truncate (struct inode * inode) { +struct super_block * sb = inode->i_sb;block_t *idata =i_data (inode);int offsets[DEPTH ];Indirect chain[DEPTH ];
@@ -301,7 +302,7 @@int first_whole;long iblock; - iblock = (inode->i_size +BLOCK_SIZE -1 ) >>10 ; + iblock = (inode->i_size + sb->s_blocksize -1 ) >>10 ;block_truncate_page (inode->i_mapping, inode->i_size, get_block); n =block_to_path (inode, iblock, offsets);
include/linux/minix_fs.h +9 -1
@@ -23,14 +23,16 @@#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 */ #define MINIX_VALID_FS 0x0001/* Clean fs. */ #define MINIX_ERROR_FS 0x0002/* fs has errors. */ #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) -#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode))) +#define MINIX2_INODES_PER_BLOCK (b) ((b)/(sizeof (struct minix2_inode)))#define MINIX_V1 0x0001/* original minix fs */ #define MINIX_V2 0x0002/* minix V2 fs */ +#define MINIX_V3 0x0003/* minix V3 fs */ #define INODE_VERSION (inode) inode->i_sb->u.minix_sb.s_version
@@ -87,6 +89,12 @@char name[0 ]; }; +struct minix3_dir_entry { +__u16 inode; +__u16 padding; +char name[0 ]; +}; +#ifdef __KERNEL__/*