minix: modernize function declarations and eliminating some magic numbers
cover minix: modernize function declarations and eliminating some magic numbers
Another set of minix patches fixing issues that I noticed while working on other things. The various dirsize and namelen values being set in minix_fill_super() in inode.c, which vary depending on the versions of the minix filesystem and how it was created, were being set as magic numbers. The function declarations in minix.h were also a mix of current and historic kernel coding standards, where some function declarations had arguments with types and names while others had only types. This became an annoyance when updating minix.h because checkpatch.pl would gripe about improper function declarations.
Create and use #defines for the various dirsize and namelen values in minix_fill_super, and modernize the function declarations in minix.h.
Both patches have been tested by mounting and performing file operations against v1, v2, and v3 minix filesystem volumes. Neither of them have any functional changes.
Jeremy Bingham (2):
minix: define constants for dirsize and namelen
minix: modernize function declarations in minix.h
fs/minix/inode.c | 20 ++++++------ fs/minix/itree_v1.c | 2 +- fs/minix/itree_v2.c | 2 +- fs/minix/minix.h | 78 ++++++++++++++++++++++++++++++--------------- 4 files changed, 65 insertions(+), 37 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/2 minix: define constants for dirsize and namelen
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.
--- fs/minix/inode.c | 20 ++++++++++---------- fs/minix/minix.h | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 11 deletions(-)
fs/minix/inode.c +10 -10
@@ -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))
fs/minix/minix.h +21 -0
@@ -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 */
Signature · 1 line
2.47.3
PATCH 2/2 minix: modernize function declarations in minix.h
In reply to Jeremy BinghamThe function prototypes in minix.h were a mix of current and historic standards. Some functions had arguments with types and names while others had just the types. Some functions were also still prefixed with extern, and there were a few uses of bare 'unsigned' still as well.
This brings fs/minix/minix.h up to speed with the current formatting standards. Function declarations are consistent with types and names both declared, and the bare 'unsigned' variables are now declared as 'unsigned int'.
There are no functional changes with this patch.
--- fs/minix/itree_v1.c | 2 +- fs/minix/itree_v2.c | 2 +- fs/minix/minix.h | 55 +++++++++++++++++++++++++-------------------- 3 files changed, 33 insertions(+), 26 deletions(-)
fs/minix/itree_v1.c +1 -1
@@ -61,7 +61,7 @@ void V1_minix_truncate(struct inode * inode)truncate (inode); } -unsigned V1_minix_blocks (loff_t size,struct super_block *sb) +unsigned int V1_minix_blocks (loff_t size,struct super_block *sb) {return nblocks (size, sb); }
fs/minix/itree_v2.c +1 -1
@@ -69,7 +69,7 @@ void V2_minix_truncate(struct inode * inode)truncate (inode); } -unsigned V2_minix_blocks (loff_t size,struct super_block *sb) +unsigned int V2_minix_blocks (loff_t size,struct super_block *sb) {return nblocks (size, sb); }
fs/minix/minix.h +31 -24
84 lines not on this page · raw message
Signature · 1 line
2.47.3
Re: [PATCH 1/2] minix: define constants for dirsize and namelen
In reply to Jeremy BinghamQuoted 106 lines
Op 06-07-2026 20:22 CEST schreef Jeremy Bingham <[email protected]>:
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.hso we don't need to set those values as magic numbers inminix_fill_super()ininode.cBefore:
sbi->s_dirsize = 16; After: sbi->s_dirsize = MINIX_V1_DIRSIZE;There are no functional changes with this patch.
Signed-off-by Jeremy Bingham <[email protected]>--- fs/minix/inode.c | 20 ++++++++++---------- fs/minix/minix.h | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 11 deletions(-)fs/minix/inode.c +10
-10@@ -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))fs/minix/minix.h +21
-0@@ -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 */ Signature · 1 line
2.47.3
Hi Jeremy,
Thanks for taking the time to look at minix. I have a particular fondness of the filesystem, so I am happy someone takes an interest.
However, I don't like this series. There is no reason for all this churn or the exorbitant amount of comments. If you can get iomap to work that would be great, but please don't do this.
Thanks,
Jori.
Re: [PATCH 1/2] minix: define constants for dirsize and namelen
Quoted 6 lines · Jori Koolstra
Quoted 2 lines
Op 06-07-2026 20:22 CEST schreef Jeremy Bingham <[email protected]>:
Hi Jeremy,
Thanks for taking the time to look at minix. I have a particular fondness of the filesystem, so I am happy someone takes an interest.
Thanks. I think it's kind of neat to have it around too.
Quoted 6 lines
However, I don't like this series. There is no reason for all this churn or the exorbitant amount of comments. If you can get iomap to work that would be great, but please don't do this.
Thanks,
Jori.
These two patch series were the only other things I had besides the iomap patch series. This one in particular I'm not super attached to, but I had noticed the bare numbers there while working on iomap. I wrote the minix.h patch in this same series because checkpatch.pl kept griping about the function declarations on the lines I had changed, and since it was a bit of a hodgepodge of different styles I thought it might be worth doing something about it. Changing all the function declarations was out of scope for the iomap series, though, which is why I did it separately here.
The other RFC patch, which unifies the itree_v1.c, itree_v2.c, and itree_common.c files, was inspired by Darrick's comment in the iomap patch series about how the way the v1 and v2 files have specific definitions and include the common file was "/one/ way to avoid having a geometry struct capturing those details". That got me thinking about how not having to worry about the different v1 and v2 definitions and just unifying those three files into one, but since that would also be (very) out of scope with iomap I made that RFC patch separately.
In re: the exorbitant comments, I had those in the RFC to explain what I was doing and why. If the RFC patch was well received, I would of course resubmit it with the comments significantly pared down. That patch would make the iomap conversion easier, but it isn't required. Since that RFC patch would be nice, but isn't necessary, I wanted to put it out there and get comments on it separately rather than trying to fold it in to the iomap patches. In the future, though, should I find myself submitting another RFC patch I'll keep the explanations in the cover letters and commit messages unless absolutely necessary.
Iomap and minix do work now. I just need to address Darrick's critiques of it before submitting it again. Since these two most recent patch series of mine were indirectly related but not required for iomap support, I broke them out into their own patches.
Thank you for the comments, and if there's anything else you think I should address I would love to hear it.
-j