Skip to contentSkip to conversation

allow to create a minix3fs with a blocksize != 1K

PATCH In review Vladimir 'φ-coder/phcoder' Serbinenko 4 participants 10 messages May 9, 2012 – Jun 11, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 allow to create a minix3fs with a blocksize != 1K

Have used it to test minixfs support with various block sizes.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
disk-utils/fsck.minix.c +22 -12
index 139ab7a..7d1a737 100644
@@ -497,9 +497,11 @@ write_super_block(void) {
 	else
 		Super.s_state &= ~MINIX_ERROR_FS;
 
-	if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
+	if (MINIX_SUPERBLOCK_OFFSET != lseek(IN, MINIX_SUPERBLOCK_OFFSET,
+					     SEEK_SET))
 		die(_("seek failed in write_super_block"));
-	if (MINIX_BLOCK_SIZE != write(IN, super_block_buffer, MINIX_BLOCK_SIZE))
+	if (MINIX_SUPERBLOCK_SIZE != write(IN, super_block_buffer,
+					   MINIX_SUPERBLOCK_SIZE))
 		die(_("unable to write super-block"));
 	return;
 }
@@ -543,33 +545,41 @@ get_dirsize(void) {
 	/* use defaults */
 }
 
+int MINIX_BLOCK_SIZE = 0;
+
 static void
 read_superblock(void) {
-	if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
+	if (MINIX_SUPERBLOCK_OFFSET != lseek(IN, MINIX_SUPERBLOCK_OFFSET,
+					     SEEK_SET))
 		die(_("seek failed"));
 
-	super_block_buffer = calloc(1, MINIX_BLOCK_SIZE);
+	super_block_buffer = calloc(1, MINIX_SUPERBLOCK_SIZE);
 	if (!super_block_buffer)
 		die(_("unable to alloc buffer for superblock"));
 
-	if (MINIX_BLOCK_SIZE != read(IN, super_block_buffer, MINIX_BLOCK_SIZE))
+	if (MINIX_SUPERBLOCK_SIZE
+	    != read(IN, super_block_buffer, MINIX_SUPERBLOCK_SIZE))
 		die(_("unable to read super block"));
 	if (MAGIC == MINIX_SUPER_MAGIC) {
 		namelen = 14;
 		dirsize = 16;
 		fs_version = 1;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else if (MAGIC == MINIX_SUPER_MAGIC2) {
 		namelen = 30;
 		dirsize = 32;
 		fs_version = 1;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else if (MAGIC == MINIX2_SUPER_MAGIC) {
 		namelen = 14;
 		dirsize = 16;
 		fs_version = 2;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else if (MAGIC == MINIX2_SUPER_MAGIC2) {
 		namelen = 30;
 		dirsize = 32;
 		fs_version = 2;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else
 		die(_("bad magic number in super-block"));
 	if (get_zone_size() != 0 || MINIX_BLOCK_SIZE != 1024)
@@ -812,7 +822,7 @@ add_zone2(unsigned int *znr, int *corrected) {
 
 static void
 add_zone_ind(unsigned short *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, chg_blk = 0;
 	int block;
 
@@ -828,7 +838,7 @@ add_zone_ind(unsigned short *znr, int *corrected) {
 
 static void
 add_zone_ind2(unsigned int *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, chg_blk = 0;
 	int block;
 
@@ -844,7 +854,7 @@ add_zone_ind2(unsigned int *znr, int *corrected) {
 
 static void
 add_zone_dind(unsigned short *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, blk_chg = 0;
 	int block;
 
@@ -860,7 +870,7 @@ add_zone_dind(unsigned short *znr, int *corrected) {
 
 static void
 add_zone_dind2(unsigned int *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, blk_chg = 0;
 	int block;
 
@@ -876,7 +886,7 @@ add_zone_dind2(unsigned int *znr, int *corrected) {
 
 static void
 add_zone_tind2(unsigned int *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, blk_chg = 0;
 	int block;
 
@@ -929,7 +939,7 @@ check_zones2(unsigned int i) {
 
 static void
 check_file(struct minix_inode *dir, unsigned int offset) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	struct minix_inode *inode;
 	unsigned int ino;
 	char *name;
@@ -997,7 +1007,7 @@ check_file(struct minix_inode *dir, unsigned int offset) {
 
 static void
 check_file2(struct minix2_inode *dir, unsigned int offset) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	struct minix2_inode *inode;
 	unsigned long ino;
 	char *name;
disk-utils/minix_programs.h +1 -0
index 4af1a34..8fced46 100644
@@ -8,6 +8,7 @@
  */
 extern int fs_version;
 extern char *super_block_buffer;
+extern int MINIX_BLOCK_SIZE;
 
 #define Super (*(struct minix_super_block *) super_block_buffer)
 #define Super3 (*(struct minix3_super_block *) super_block_buffer)
disk-utils/mkfs.minix.c +33 -6
index 051cd5f..fd68fc9 100644
@@ -123,7 +123,7 @@ static size_t namelen = 30;
 static size_t dirsize = 32;
 static int magic = MINIX_SUPER_MAGIC2;
 
-static char root_block[MINIX_BLOCK_SIZE];
+static char root_block[MAX_MINIX_BLOCK_SIZE];
 
 static char boot_block_buffer[512];
 
@@ -146,7 +146,7 @@ static char *zone_map;
 
 static void __attribute__((__noreturn__))
 usage(void) {
-	errx(MKFS_EX_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]"),
+	errx(MKFS_EX_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-BXX] [-iXX] /dev/name [blocks]"),
 	     program_name);
 }
 
@@ -189,6 +189,13 @@ static void write_tables(void) {
 	unsigned long imaps = get_nimaps();
 	unsigned long zmaps = get_nzmaps();
 	unsigned long buffsz = get_inode_buffer_size();
+	unsigned pad;
+	char padbuffer[2 * MINIX_BLOCK_SIZE];
+
+	memset (padbuffer, 0, 2 * MINIX_BLOCK_SIZE);
+
+	pad = 2 * MINIX_BLOCK_SIZE - (MINIX_SUPERBLOCK_OFFSET
+				      + MINIX_SUPERBLOCK_SIZE);
 
 	/* Mark the super block valid. */
 	super_set_state();
@@ -198,12 +205,16 @@ static void write_tables(void) {
 				   " in write_tables"), device_name);
 	if (write_all(DEV, boot_block_buffer, 512))
 		err(MKFS_EX_ERROR, _("%s: unable to clear boot sector"), device_name);
-	if (MINIX_BLOCK_SIZE != lseek(DEV, MINIX_BLOCK_SIZE, SEEK_SET))
+	if (MINIX_SUPERBLOCK_OFFSET != lseek(DEV, MINIX_SUPERBLOCK_OFFSET,
+					     SEEK_SET))
 		err(MKFS_EX_ERROR, _("%s: seek failed in write_tables"), device_name);
 
-	if (write_all(DEV, super_block_buffer, MINIX_BLOCK_SIZE))
+	if (write_all(DEV, super_block_buffer, MINIX_SUPERBLOCK_SIZE))
 		err(MKFS_EX_ERROR, _("%s: unable to write super-block"), device_name);
 
+	if (write_all(DEV, padbuffer, pad))
+		err(MKFS_EX_ERROR, _("%s: unable to write super-block"), device_name);	
+
 	if (write_all(DEV, inode_map, imaps * MINIX_BLOCK_SIZE))
 		err(MKFS_EX_ERROR, _("%s: unable to write inode map"), device_name);
 
@@ -588,7 +600,7 @@ static void alarm_intr(int alnum __attribute__ ((__unused__))) {
 
 static void check_blocks(void) {
 	int try,got;
-	static char buffer[MINIX_BLOCK_SIZE * TEST_BUFFER_BLOCKS];
+	static char buffer[MAX_MINIX_BLOCK_SIZE * TEST_BUFFER_BLOCKS];
 	unsigned long zones = get_nzones();
 	unsigned long first_zone = get_first_zone();
 
@@ -646,6 +658,8 @@ static void get_list_blocks(char *filename) {
 		printf(_("one bad block\n"));
 }
 
+int MINIX_BLOCK_SIZE = 0;
+
 int main(int argc, char ** argv) {
 	int i;
 	char * tmp;
@@ -653,6 +667,8 @@ int main(int argc, char ** argv) {
 	char * listfile = NULL;
 	char * p;
 
+	MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
+
 	if (argc && *argv)
 		program_name = *argv;
 	if ((p = strrchr(program_name, '/')) != NULL)
@@ -675,8 +691,13 @@ int main(int argc, char ** argv) {
 		errx(MKFS_EX_ERROR, _("%s: bad inode size"), device_name);
 
 	opterr = 0;
-	while ((i = getopt(argc, argv, "ci:l:n:v123")) != -1)
+	while ((i = getopt(argc, argv, "ci:l:n:v123B:")) != -1)
 		switch (i) {
+		case 'B':
+			MINIX_BLOCK_SIZE = strtoul(optarg,&tmp,0);
+			if (*tmp)
+				usage();
+			break;
 		case 'c':
 			check=1; break;
 		case 'i':
@@ -727,6 +748,13 @@ int main(int argc, char ** argv) {
 		}
 	}
 
+	if (fs_version != 3 && MINIX_BLOCK_SIZE != MINIX12_BLOCK_SIZE)
+		usage();
+
+	if (MINIX_BLOCK_SIZE % 512 || MINIX_BLOCK_SIZE < 1024
+	    || MINIX_BLOCK_SIZE >= 65536)
+		usage();
+
 	if (!device_name) {
 		usage();
 	}
include/minix.h +4 -3
index 57be239..059c050 100644
@@ -60,12 +60,13 @@ struct minix3_super_block {
  */
 #define MINIX_MAXPARTITIONS  4
 
-#define MINIX_BLOCK_SIZE_BITS 10
-#define MINIX_BLOCK_SIZE     (1 << MINIX_BLOCK_SIZE_BITS)
-
 #define MINIX_NAME_MAX       255             /* # chars in a file name */
 #define MINIX_MAX_INODES     65535
 
+#define MAX_MINIX_BLOCK_SIZE 65536
+#define MINIX12_BLOCK_SIZE   1024
+#define MINIX_SUPERBLOCK_OFFSET 1024
+#define MINIX_SUPERBLOCK_SIZE  512
 #define MINIX_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix_inode)))
 #define MINIX2_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix2_inode)))
 
libblkid/src/superblocks/minix.c +2 -2
index 54e7139..7bf9089 100644
@@ -45,9 +45,9 @@ static int probe_minix(blkid_probe pr, const struct blkid_idmag *mag)
 		zones = version == 2 ? sb->s_zones : sb->s_nzones;
 
 		/* sanity checks to be sure that the FS is really minix */
-		if (sb->s_imap_blocks * MINIX_BLOCK_SIZE * 8 < sb->s_ninodes + 1)
+		if (sb->s_imap_blocks * MINIX12_BLOCK_SIZE * 8 < sb->s_ninodes + 1)
 			return -1;
-		if (sb->s_zmap_blocks * MINIX_BLOCK_SIZE * 8 < zones - sb->s_firstdatazone + 1)
+		if (sb->s_zmap_blocks * MINIX12_BLOCK_SIZE * 8 < zones - sb->s_firstdatazone + 1)
 			return -1;
 
 	} else if (version == 3) {
#1 lore raw

PATCH 1/1 allow to create a minix3fs with a blocksize != 1K

Have used it to test minixfs support with various block sizes.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
disk-utils/fsck.minix.c +22 -12
index 139ab7a..7d1a737 100644
@@ -497,9 +497,11 @@ write_super_block(void) {
 	else
 		Super.s_state &= ~MINIX_ERROR_FS;
 
-	if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
+	if (MINIX_SUPERBLOCK_OFFSET != lseek(IN, MINIX_SUPERBLOCK_OFFSET,
+					     SEEK_SET))
 		die(_("seek failed in write_super_block"));
-	if (MINIX_BLOCK_SIZE != write(IN, super_block_buffer, MINIX_BLOCK_SIZE))
+	if (MINIX_SUPERBLOCK_SIZE != write(IN, super_block_buffer,
+					   MINIX_SUPERBLOCK_SIZE))
 		die(_("unable to write super-block"));
 	return;
 }
@@ -543,33 +545,41 @@ get_dirsize(void) {
 	/* use defaults */
 }
 
+int MINIX_BLOCK_SIZE = 0;
+
 static void
 read_superblock(void) {
-	if (MINIX_BLOCK_SIZE != lseek(IN, MINIX_BLOCK_SIZE, SEEK_SET))
+	if (MINIX_SUPERBLOCK_OFFSET != lseek(IN, MINIX_SUPERBLOCK_OFFSET,
+					     SEEK_SET))
 		die(_("seek failed"));
 
-	super_block_buffer = calloc(1, MINIX_BLOCK_SIZE);
+	super_block_buffer = calloc(1, MINIX_SUPERBLOCK_SIZE);
 	if (!super_block_buffer)
 		die(_("unable to alloc buffer for superblock"));
 
-	if (MINIX_BLOCK_SIZE != read(IN, super_block_buffer, MINIX_BLOCK_SIZE))
+	if (MINIX_SUPERBLOCK_SIZE
+	    != read(IN, super_block_buffer, MINIX_SUPERBLOCK_SIZE))
 		die(_("unable to read super block"));
 	if (MAGIC == MINIX_SUPER_MAGIC) {
 		namelen = 14;
 		dirsize = 16;
 		fs_version = 1;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else if (MAGIC == MINIX_SUPER_MAGIC2) {
 		namelen = 30;
 		dirsize = 32;
 		fs_version = 1;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else if (MAGIC == MINIX2_SUPER_MAGIC) {
 		namelen = 14;
 		dirsize = 16;
 		fs_version = 2;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else if (MAGIC == MINIX2_SUPER_MAGIC2) {
 		namelen = 30;
 		dirsize = 32;
 		fs_version = 2;
+		MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
 	} else
 		die(_("bad magic number in super-block"));
 	if (get_zone_size() != 0 || MINIX_BLOCK_SIZE != 1024)
@@ -812,7 +822,7 @@ add_zone2(unsigned int *znr, int *corrected) {
 
 static void
 add_zone_ind(unsigned short *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, chg_blk = 0;
 	int block;
 
@@ -828,7 +838,7 @@ add_zone_ind(unsigned short *znr, int *corrected) {
 
 static void
 add_zone_ind2(unsigned int *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, chg_blk = 0;
 	int block;
 
@@ -844,7 +854,7 @@ add_zone_ind2(unsigned int *znr, int *corrected) {
 
 static void
 add_zone_dind(unsigned short *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, blk_chg = 0;
 	int block;
 
@@ -860,7 +870,7 @@ add_zone_dind(unsigned short *znr, int *corrected) {
 
 static void
 add_zone_dind2(unsigned int *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, blk_chg = 0;
 	int block;
 
@@ -876,7 +886,7 @@ add_zone_dind2(unsigned int *znr, int *corrected) {
 
 static void
 add_zone_tind2(unsigned int *znr, int *corrected) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	int i, blk_chg = 0;
 	int block;
 
@@ -929,7 +939,7 @@ check_zones2(unsigned int i) {
 
 static void
 check_file(struct minix_inode *dir, unsigned int offset) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	struct minix_inode *inode;
 	unsigned int ino;
 	char *name;
@@ -997,7 +1007,7 @@ check_file(struct minix_inode *dir, unsigned int offset) {
 
 static void
 check_file2(struct minix2_inode *dir, unsigned int offset) {
-	static char blk[MINIX_BLOCK_SIZE];
+	static char blk[MAX_MINIX_BLOCK_SIZE];
 	struct minix2_inode *inode;
 	unsigned long ino;
 	char *name;
disk-utils/minix_programs.h +1 -0
index 4af1a34..8fced46 100644
@@ -8,6 +8,7 @@
  */
 extern int fs_version;
 extern char *super_block_buffer;
+extern int MINIX_BLOCK_SIZE;
 
 #define Super (*(struct minix_super_block *) super_block_buffer)
 #define Super3 (*(struct minix3_super_block *) super_block_buffer)
disk-utils/mkfs.minix.c +33 -6
index 051cd5f..fd68fc9 100644
@@ -123,7 +123,7 @@ static size_t namelen = 30;
 static size_t dirsize = 32;
 static int magic = MINIX_SUPER_MAGIC2;
 
-static char root_block[MINIX_BLOCK_SIZE];
+static char root_block[MAX_MINIX_BLOCK_SIZE];
 
 static char boot_block_buffer[512];
 
@@ -146,7 +146,7 @@ static char *zone_map;
 
 static void __attribute__((__noreturn__))
 usage(void) {
-	errx(MKFS_EX_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]"),
+	errx(MKFS_EX_USAGE, _("Usage: %s [-c | -l filename] [-nXX] [-BXX] [-iXX] /dev/name [blocks]"),
 	     program_name);
 }
 
@@ -189,6 +189,13 @@ static void write_tables(void) {
 	unsigned long imaps = get_nimaps();
 	unsigned long zmaps = get_nzmaps();
 	unsigned long buffsz = get_inode_buffer_size();
+	unsigned pad;
+	char padbuffer[2 * MINIX_BLOCK_SIZE];
+
+	memset (padbuffer, 0, 2 * MINIX_BLOCK_SIZE);
+
+	pad = 2 * MINIX_BLOCK_SIZE - (MINIX_SUPERBLOCK_OFFSET
+				      + MINIX_SUPERBLOCK_SIZE);
 
 	/* Mark the super block valid. */
 	super_set_state();
@@ -198,12 +205,16 @@ static void write_tables(void) {
 				   " in write_tables"), device_name);
 	if (write_all(DEV, boot_block_buffer, 512))
 		err(MKFS_EX_ERROR, _("%s: unable to clear boot sector"), device_name);
-	if (MINIX_BLOCK_SIZE != lseek(DEV, MINIX_BLOCK_SIZE, SEEK_SET))
+	if (MINIX_SUPERBLOCK_OFFSET != lseek(DEV, MINIX_SUPERBLOCK_OFFSET,
+					     SEEK_SET))
 		err(MKFS_EX_ERROR, _("%s: seek failed in write_tables"), device_name);
 
-	if (write_all(DEV, super_block_buffer, MINIX_BLOCK_SIZE))
+	if (write_all(DEV, super_block_buffer, MINIX_SUPERBLOCK_SIZE))
 		err(MKFS_EX_ERROR, _("%s: unable to write super-block"), device_name);
 
+	if (write_all(DEV, padbuffer, pad))
+		err(MKFS_EX_ERROR, _("%s: unable to write super-block"), device_name);	
+
 	if (write_all(DEV, inode_map, imaps * MINIX_BLOCK_SIZE))
 		err(MKFS_EX_ERROR, _("%s: unable to write inode map"), device_name);
 
@@ -588,7 +600,7 @@ static void alarm_intr(int alnum __attribute__ ((__unused__))) {
 
 static void check_blocks(void) {
 	int try,got;
-	static char buffer[MINIX_BLOCK_SIZE * TEST_BUFFER_BLOCKS];
+	static char buffer[MAX_MINIX_BLOCK_SIZE * TEST_BUFFER_BLOCKS];
 	unsigned long zones = get_nzones();
 	unsigned long first_zone = get_first_zone();
 
@@ -646,6 +658,8 @@ static void get_list_blocks(char *filename) {
 		printf(_("one bad block\n"));
 }
 
+int MINIX_BLOCK_SIZE = 0;
+
 int main(int argc, char ** argv) {
 	int i;
 	char * tmp;
@@ -653,6 +667,8 @@ int main(int argc, char ** argv) {
 	char * listfile = NULL;
 	char * p;
 
+	MINIX_BLOCK_SIZE = MINIX12_BLOCK_SIZE;
+
 	if (argc && *argv)
 		program_name = *argv;
 	if ((p = strrchr(program_name, '/')) != NULL)
@@ -675,8 +691,13 @@ int main(int argc, char ** argv) {
 		errx(MKFS_EX_ERROR, _("%s: bad inode size"), device_name);
 
 	opterr = 0;
-	while ((i = getopt(argc, argv, "ci:l:n:v123")) != -1)
+	while ((i = getopt(argc, argv, "ci:l:n:v123B:")) != -1)
 		switch (i) {
+		case 'B':
+			MINIX_BLOCK_SIZE = strtoul(optarg,&tmp,0);
+			if (*tmp)
+				usage();
+			break;
 		case 'c':
 			check=1; break;
 		case 'i':
@@ -727,6 +748,13 @@ int main(int argc, char ** argv) {
 		}
 	}
 
+	if (fs_version != 3 && MINIX_BLOCK_SIZE != MINIX12_BLOCK_SIZE)
+		usage();
+
+	if (MINIX_BLOCK_SIZE % 512 || MINIX_BLOCK_SIZE < 1024
+	    || MINIX_BLOCK_SIZE >= 65536)
+		usage();
+
 	if (!device_name) {
 		usage();
 	}
include/minix.h +4 -3
index 57be239..059c050 100644
@@ -60,12 +60,13 @@ struct minix3_super_block {
  */
 #define MINIX_MAXPARTITIONS  4
 
-#define MINIX_BLOCK_SIZE_BITS 10
-#define MINIX_BLOCK_SIZE     (1 << MINIX_BLOCK_SIZE_BITS)
-
 #define MINIX_NAME_MAX       255             /* # chars in a file name */
 #define MINIX_MAX_INODES     65535
 
+#define MAX_MINIX_BLOCK_SIZE 65536
+#define MINIX12_BLOCK_SIZE   1024
+#define MINIX_SUPERBLOCK_OFFSET 1024
+#define MINIX_SUPERBLOCK_SIZE  512
 #define MINIX_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix_inode)))
 #define MINIX2_INODES_PER_BLOCK ((MINIX_BLOCK_SIZE)/(sizeof (struct minix2_inode)))
 
libblkid/src/superblocks/minix.c +2 -2
index 54e7139..7bf9089 100644
@@ -45,9 +45,9 @@ static int probe_minix(blkid_probe pr, const struct blkid_idmag *mag)
 		zones = version == 2 ? sb->s_zones : sb->s_nzones;
 
 		/* sanity checks to be sure that the FS is really minix */
-		if (sb->s_imap_blocks * MINIX_BLOCK_SIZE * 8 < sb->s_ninodes + 1)
+		if (sb->s_imap_blocks * MINIX12_BLOCK_SIZE * 8 < sb->s_ninodes + 1)
 			return -1;
-		if (sb->s_zmap_blocks * MINIX_BLOCK_SIZE * 8 < zones - sb->s_firstdatazone + 1)
+		if (sb->s_zmap_blocks * MINIX12_BLOCK_SIZE * 8 < zones - sb->s_firstdatazone + 1)
 			return -1;
 
 	} else if (version == 3) {
maintainer
#2 lore raw
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

Have used it to test minixfs support with various block sizes.

Looks good, but

Quoted 1 line

+int MINIX_BLOCK_SIZE = 0;

is dirty, what about

   int block_size = 0;

Vladimir, use also 'Signed-off-by:' in commit message for your patches, please.

Thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#3 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Have used it to test minixfs support with various block sizes.

Hi Vladimir,

A few comments:

+ if (MINIX_BLOCK_SIZE % 512 || MINIX_BLOCK_SIZE < 1024
+ || MINIX_BLOCK_SIZE >= 65536)
+ usage();

This check should be part of the switch statement, perhaps in its own function.
+ if (*tmp && ...)

+ if (fs_version != 3 && MINIX_BLOCK_SIZE != MINIX12_BLOCK_SIZE)
+ usage();

We should set -1/-2 options to be mutually exclusive with -B.

+#define MAX_MINIX_BLOCK_SIZE 65536
Isn't the max minix block size 4096?

+#define MINIX12_BLOCK_SIZE 1024
This is the minimal block size, including v3. MINIX12_ doesn't describe it well.

Also, please send the patches in the body of the message - just as with the lkml.

Thanks,
Davidlohr

#4 lore raw
Quoted 13 lines · Davidlohr Bueso
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Have used it to test minixfs support with various block sizes.

Hi Vladimir,

A few comments:

disk-utils/mkfs.minix.c +3 -0
+       if (MINIX_BLOCK_SIZE % 512 || MINIX_BLOCK_SIZE < 1024
+           || MINIX_BLOCK_SIZE >= 65536)
+               usage();
Quoted 5 lines

This check should be part of the switch statement, perhaps in its own function.
+ if (*tmp && ...)

Ok

Quoted 5 lines
(quoted diff) +2 -0
+       if (fs_version != 3 && MINIX_BLOCK_SIZE != MINIX12_BLOCK_SIZE)
+               usage();

We should set -1/-2 options to be mutually exclusive with -B.

Ok

Quoted 3 lines

+#define MAX_MINIX_BLOCK_SIZE 65536
Isn't the max minix block size 4096?

No, Maximum for the on-disk format is 65535. Minix itself supports everything from 1025 to 65536-512 as long as it's divisible by 512. Linux driver is limited to 1024, 2048 and 4096

Quoted 4 lines

+#define MINIX12_BLOCK_SIZE 1024
This is the minimal block size, including v3. MINIX12_ doesn't describe it well.

I use this constant specifically in places which only relate to v1 and v2

Quoted 4 lines

Also, please send the patches in the body of the message - just as with the lkml.

Ok

Quoted 4 lines

Thanks,
Davidlohr

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#5 lore raw
Quoted 31 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 13 lines · Davidlohr Bueso
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Have used it to test minixfs support with various block sizes.

Hi Vladimir,

A few comments:

disk-utils/mkfs.minix.c +3 -0
+       if (MINIX_BLOCK_SIZE % 512 || MINIX_BLOCK_SIZE < 1024
+           || MINIX_BLOCK_SIZE >= 65536)
+               usage();
Quoted 5 lines

This check should be part of the switch statement, perhaps in its own function.
+ if (*tmp && ...)

Ok

Quoted 5 lines
(quoted diff) +2 -0
+       if (fs_version != 3 && MINIX_BLOCK_SIZE != MINIX12_BLOCK_SIZE)
+               usage();

We should set -1/-2 options to be mutually exclusive with -B.

Ok

Quoted 7 lines
Quoted 3 lines

+#define MAX_MINIX_BLOCK_SIZE 65536
Isn't the max minix block size 4096?

No, Maximum for the on-disk format is 65535. Minix itself supports everything from 1025 to 65536-512 as long as it's divisible by 512. Linux driver is limited to 1024, 2048 and 4096

hmmm, do you have any documentation I can look at? Both the native mkfs minix tool and the mfs server, also set the max block size to 4K. Unfortunately I don't have a copy of ast's minix book.

Quoted 22 lines
Quoted 5 lines

+#define MINIX12_BLOCK_SIZE 1024
This is the minimal block size, including v3. MINIX12_ doesn't describe it well.

I use this constant specifically in places which only relate to v1 and v2

Quoted 4 lines

Also, please send the patches in the body of the message - just as with the lkml.

Ok

Quoted 4 lines

Thanks,
Davidlohr

#7 lore raw
Quoted 6 lines · richard -rw- weinberger
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Have used it to test minixfs support with various block sizes.

Isn't this patch against disk-utils?
Why are you sending it to linux-kernel@..?

Yes, I've already noticed this and resent it to the util-linux list. Do you know if linux-kernel is the right list for my other patches like wrong minixfs block allocation check or AFFS race condition? It seems they've all been ignored.
I have few other bugfixes or feature improvements for lesser filesystems but I don't want to send them unless I feel like the patches are going to somewhere else than /dev/null.

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#8 lore raw
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Yes, I've already noticed this and resent it to the util-linux list. Do you know if linux-kernel is the right list for my other patches like wrong minixfs block allocation check or AFFS race condition? It seems they've all been ignored.

Not really.
At least send them to linux-fsdevel too.
Please read MAINTAINERS and Documentation/SubmittingPatches and use checkpatch.pl/get_maintainer.pl.

Signature · 2 lines
Thanks,
//richard
#9 lore raw
Quoted 8 lines · richard -rw- weinberger
Quoted 4 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Yes, I've already noticed this and resent it to the util-linux list. Do you know if linux-kernel is the right list for my other patches like wrong minixfs block allocation check or AFFS race condition? It seems they've all been ignored.

Not really.
At least send them to linux-fsdevel too.

Done

Quoted 2 lines

Please read MAINTAINERS and Documentation/SubmittingPatches and use checkpatch.pl/get_maintainer.pl.

get_maintainer pointed to this list for minix and ufs (output at the end of message). And for UFS the maintainer e-mail is likely to be abandoned (mail.ru e-mails were popular in 90's but are mostly abandoned now). If noone answers the patches on linux-fsdevel I'll try CC maintainers directly. Will read files when time permits.
Thank you very much for the info.

$ ./scripts/get_maintainer.pl -f fs/ufs/
Evgeniy Dushistov <[email protected]> (maintainer:UFS FILESYSTEM)
[email protected] (open list)
$ ./scripts/get_maintainer.pl -f fs/affs/
Al Viro <[email protected]> (commit_signer:9/11=82%)
Sage Weil <[email protected]> (commit_signer:3/11=27%)
Christoph Hellwig <[email protected]> (commit_signer:3/11=27%)
Miklos Szeredi <[email protected]> (commit_signer:2/11=18%)
Josef Bacik <[email protected]> (commit_signer:1/11=9%)
[email protected] (open list:AFFS FILE SYSTEM)
[email protected] (open list)
$ ./scripts/get_maintainer.pl -f fs/minix/
Al Viro <[email protected]> (commit_signer:14/16=88%)
Sage Weil <[email protected]> (commit_signer:3/16=19%)
Christoph Hellwig <[email protected]> (commit_signer:3/16=19%)
Josh Boyer <[email protected]> (commit_signer:2/16=12%)
Miklos Szeredi <[email protected]> (commit_signer:1/16=6%)
[email protected] (open list)
Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko