mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeremy Bingham <jbingham@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, brauner@kernel.org,
	jkoolstra@xs4all.nl, jack@suse.cz,
	Jeremy Bingham <jbingham@gmail.com>
Subject: [PATCH 1/2] minix: define constants for dirsize and namelen
Date: Mon,  6 Jul 2026 11:22:43 -0700	[thread overview]
Message-ID: <7d62598a8be99c6218d05bfca56bc37f1e634a49.1783360491.git.jbingham@gmail.com> (raw)
In-Reply-To: <cover.1783360491.git.jbingham@gmail.com>

The different versions of the minix fs have different values for
directory size and name length. Versions 1 and 2 each have two possible
values for each of those, while version 3 has one set of values for
each. Add defines for all of these to minix.h so we don't need to set
those values as magic numbers in minix_fill_super() in inode.c

Before:
	sbi->s_dirsize = 16;
After:
	sbi->s_dirsize = MINIX_V1_DIRSIZE;

There are no functional changes with this patch.

Signed-off-by: Jeremy Bingham <jbingham@gmail.com>
---
 fs/minix/inode.c | 20 ++++++++++----------
 fs/minix/minix.h | 23 ++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index c30cc590698d..95fa8371e4ea 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -258,25 +258,25 @@ static int minix_fill_super(struct super_block *s, struct fs_context *fc)
 	s->s_magic = ms->s_magic;
 	if (s->s_magic == MINIX_SUPER_MAGIC) {
 		sbi->s_version = MINIX_V1;
-		sbi->s_dirsize = 16;
-		sbi->s_namelen = 14;
+		sbi->s_dirsize = MINIX_V1_DIRSIZE;
+		sbi->s_namelen = MINIX_V1_NAMELEN;
 		s->s_max_links = MINIX_LINK_MAX;
 	} else if (s->s_magic == MINIX_SUPER_MAGIC2) {
 		sbi->s_version = MINIX_V1;
-		sbi->s_dirsize = 32;
-		sbi->s_namelen = 30;
+		sbi->s_dirsize = MINIX_V1_DIRSIZE2;
+		sbi->s_namelen = MINIX_V1_NAMELEN2;
 		s->s_max_links = MINIX_LINK_MAX;
 	} else if (s->s_magic == MINIX2_SUPER_MAGIC) {
 		sbi->s_version = MINIX_V2;
 		sbi->s_nzones = ms->s_zones;
-		sbi->s_dirsize = 16;
-		sbi->s_namelen = 14;
+		sbi->s_dirsize = MINIX_V2_DIRSIZE;
+		sbi->s_namelen = MINIX_V2_NAMELEN;
 		s->s_max_links = MINIX2_LINK_MAX;
 	} else if (s->s_magic == MINIX2_SUPER_MAGIC2) {
 		sbi->s_version = MINIX_V2;
 		sbi->s_nzones = ms->s_zones;
-		sbi->s_dirsize = 32;
-		sbi->s_namelen = 30;
+		sbi->s_dirsize = MINIX_V2_DIRSIZE2;
+		sbi->s_namelen = MINIX_V2_NAMELEN2;
 		s->s_max_links = MINIX2_LINK_MAX;
 	} else if ( *(__u16 *)(bh->b_data + 24) == MINIX3_SUPER_MAGIC) {
 		m3s = (struct minix3_super_block *) bh->b_data;
@@ -288,8 +288,8 @@ static int minix_fill_super(struct super_block *s, struct fs_context *fc)
 		s->s_maxbytes = m3s->s_max_size;
 		sbi->s_ninodes = m3s->s_ninodes;
 		sbi->s_nzones = m3s->s_zones;
-		sbi->s_dirsize = 64;
-		sbi->s_namelen = 60;
+		sbi->s_dirsize = MINIX_V3_DIRSIZE;
+		sbi->s_namelen = MINIX_V3_NAMELEN;
 		sbi->s_version = MINIX_V3;
 		sbi->s_mount_state = MINIX_VALID_FS;
 		if (!sb_set_blocksize(s, m3s->s_blocksize))
diff --git a/fs/minix/minix.h b/fs/minix/minix.h
index f2025c9b5825..972a71c5b481 100644
--- a/fs/minix/minix.h
+++ b/fs/minix/minix.h
@@ -11,6 +11,27 @@
 #define MINIX_V2		0x0002		/* minix V2 fs */
 #define MINIX_V3		0x0003		/* minix V3 fs */
 
+/* Define version and sub-version specific values for dirsize and name length.
+ * These are not as clear-cut as having different values for versions 1, 2, and
+ * 3, unfortunately, but rather there two possible values for each for versions
+ * 1 and 2 and one possible set of values for version 3.
+ *
+ * These have separate defines for each subversion value for versions 1 and 2,
+ * though; even though they duplicate each other, it will be more clear to have
+ * them separate than trying to come up with a name that encompasses both
+ * versions yet not be totally confusing.
+ */
+#define MINIX_V1_DIRSIZE	16
+#define MINIX_V1_NAMELEN	14
+#define MINIX_V1_DIRSIZE2	32
+#define MINIX_V1_NAMELEN2	30
+#define MINIX_V2_DIRSIZE	16
+#define MINIX_V2_NAMELEN	14
+#define MINIX_V2_DIRSIZE2	32
+#define MINIX_V2_NAMELEN2	30
+#define MINIX_V3_DIRSIZE	64
+#define MINIX_V3_NAMELEN	60
+
 /*
  * minix fs inode data in memory
  */
-- 
2.47.3


  reply	other threads:[~2026-07-06 18:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 18:22 [PATCH 0/2] minix: modernize function declarations and eliminating some magic numbers Jeremy Bingham
2026-07-06 18:22 ` Jeremy Bingham [this message]
2026-07-06 20:47   ` [PATCH 1/2] minix: define constants for dirsize and namelen Jori Koolstra
2026-07-07 16:54     ` Jeremy Bingham
2026-07-06 18:22 ` [PATCH 2/2] minix: modernize function declarations in minix.h Jeremy Bingham

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=7d62598a8be99c6218d05bfca56bc37f1e634a49.1783360491.git.jbingham@gmail.com \
    --to=jbingham@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jkoolstra@xs4all.nl \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®