Util-Linux package development
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave.bueso@gmail.com>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: [PATCH] mkfs.minix: add -{1,2,3} options
Date: Thu, 07 Apr 2011 16:43:07 -0300	[thread overview]
Message-ID: <1302205387.19659.4.camel@offworld> (raw)

To be applied on top of the die removal patch.

From: Davidlohr Bueso <dave@gnu.org>
Date: Thu, 7 Apr 2011 16:39:37 -0300	
Subject: [PATCH] mkfs.minix: add -{1,2,3} options

Specify by intuitive arguments which fs version to create. For v3 an exit message is shown that the feature is not yet available.
This patch also gets rid of the version2 variable, replaced by 'fs_version'.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 disk-utils/mkfs.minix.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 53b5900..ff50d4d 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -88,7 +88,7 @@
 #define INODE_SIZE (sizeof(struct minix_inode))
 
 #define INODE_SIZE2 (sizeof(struct minix2_inode))
-#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \
+#define INODE_BLOCKS UPPER(INODES, (fs_version == 2 ? MINIX2_INODES_PER_BLOCK \
 				    : MINIX_INODES_PER_BLOCK))
 #define INODE_BUFFER_SIZE (INODE_BLOCKS * BLOCK_SIZE)
 
@@ -106,7 +106,7 @@ static int namelen = 30;	/* default (changed to 30, per Linus's
 				   suggestion, Sun Nov 21 08:05:07 1993) */
 static int dirsize = 32;
 static int magic = MINIX_SUPER_MAGIC2;
-static int version2 = 0;
+static int fs_version = 1; /* v1 by default */
 
 static char root_block[BLOCK_SIZE] = "\0";
 
@@ -118,7 +118,7 @@ static char *super_block_buffer;
 static char boot_block_buffer[512];
 #define Super (*(struct minix_super_block *)super_block_buffer)
 #define INODES ((unsigned long)Super.s_ninodes)
-#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones))
+#define ZONES ((unsigned long)(fs_version == 2 ? Super.s_zones : Super.s_nzones))
 #define IMAPS ((unsigned long)Super.s_imap_blocks)
 #define ZMAPS ((unsigned long)Super.s_zmap_blocks)
 #define FIRSTZONE ((unsigned long)Super.s_firstdatazone)
@@ -392,8 +392,8 @@ setup_tables(void) {
 	memset(boot_block_buffer,0,512);
 	Super.s_magic = magic;
 	Super.s_log_zone_size = 0;
-	Super.s_max_size = version2 ? 0x7fffffff : (7+512+512*512)*1024;
-	if (version2)
+	Super.s_max_size = fs_version == 2 ? 0x7fffffff : (7+512+512*512)*1024;
+	if (fs_version == 2)
 		Super.s_zones = BLOCKS;
 	else
 		Super.s_nzones = BLOCKS;
@@ -404,7 +404,7 @@ setup_tables(void) {
 	else
 		inodes = req_nr_inodes;
 	/* Round up inode count to fill block size */
-	if (version2)
+	if (fs_version == 2)
 		inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) &
 			  ~(MINIX2_INODES_PER_BLOCK - 1));
 	else
@@ -570,7 +570,7 @@ main(int argc, char ** argv) {
 		errx(8, _("bad inode size"), device_name);
 
 	opterr = 0;
-	while ((i = getopt(argc, argv, "ci:l:n:v")) != -1)
+	while ((i = getopt(argc, argv, "ci:l:n:v123")) != -1)
 		switch (i) {
 		case 'c':
 			check=1; break;
@@ -592,9 +592,15 @@ main(int argc, char ** argv) {
 			namelen = i;
 			dirsize = i+2;
 			break;
+		case '1':
+			fs_version = 1;
+			break;
+		case '2':
 		case 'v':
-			version2 = 1;
+			fs_version = 2;
 			break;
+		case '3':
+			errx(8, _("cannot create mkfs v3 - unsupported feature"));
 		default:
 			usage();
 		}
@@ -654,7 +660,7 @@ main(int argc, char ** argv) {
 		errx(8, _("will not try to make filesystem on '%s'"), device_name);
 	if (BLOCKS < 10)
 		errx(8, _("number of blocks too small"), device_name);
-	if (version2) {
+	if (fs_version == 2) {
 		if (namelen == 14)
 			magic = MINIX2_SUPER_MAGIC;
 		else
@@ -667,7 +673,7 @@ main(int argc, char ** argv) {
 		check_blocks();
 	else if (listfile)
 		get_list_blocks(listfile);
-	if (version2) {
+	if (fs_version == 2) {
 		make_root_inode2 ();
 		make_bad_inode2 ();
 	} else {
-- 
1.7.1




                 reply	other threads:[~2011-04-07 19:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302205387.19659.4.camel@offworld \
    --to=dave.bueso@gmail.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox