[PATCH 1/2] minix: define constants for dirsize and namelen
From: Jeremy Bingham
Date: Mon Jul 06 2026 - 14:25:13 EST
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@xxxxxxxxx>
---
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