mkfs: allow specification of default options via configuration file
RFC PATCH 1/1 mkfs: allow specification of default options via configuration file
From: Darrick J. Wong <[email protected]>
Ted asked for the ability to set default mkfs options, but to retain the ability respecify options via a separate configuration file or cli options. This would be useful for running fstests with the default featureset of (say) Linux 5.15 LTS, while still allowing individual testcases to provide their own overrides. It's certainly less messy than what Ted does today, which is a bash script that copies the desired config file and changes things.
--- man/man8/mkfs.xfs.8.in | 16 ++++- mkfs/xfs_mkfs.c | 159 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 152 insertions(+), 23 deletions(-)
man/man8/mkfs.xfs.8.in +14 -2
@@ -152,10 +152,22 @@ .SH OPTIONS .BI \-c " configuration_file_option" This option specifies the files that mkfs configuration will be obtained from. The valid -.I configuration_file_option -is: +.I configuration_file_options +are: .RS 1.2i .TP +.BI defaults= name +Default configuration options will be sourced from the file specified by the +.I name +option string. +This option can be use either an absolute or relative path to the configuration +file to be read. +Sample configuration files can be found in @mkfs_cfg_dir@. +Options specified through the default configuration file can be overridden by +a configuration file specified via +.B options= +or command line arguments, in that order. +.TP .BI options= name The configuration options will be sourced from the file specified by the .I name
mkfs/xfs_mkfs.c +138 -21
256 lines not on this page · raw message
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Ted asked for the ability to set default mkfs options, but to retain the ability respecify options via a separate configuration file or cli options. This would be useful for running fstests with the default featureset of (say) Linux 5.15 LTS, while still allowing individual testcases to provide their own overrides. It's certainly less messy than what Ted does today, which is a bash script that copies the desired config file and changes things.
Looks reasonable, do you have a test for it as well?
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 6028
Quoted 2 lines
mkfs/xfs_mkfs.c +2
-0+static inline int +getopt_mkfs(
I don't think there's much of a point in the inline here.
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 6036
Quoted 8 lines
mkfs/xfs_mkfs.c +8
-0+ int argc, + char *const argv[], + const struct option *longopts, + int *longindex) +{ + return getopt_long(argc, argv, "b:c:d:i:l:L:m:n:KNp:qr:s:CfV", + longopts, longindex); +}
Why does this hardcode the short options, but requires the caller to pass in the long options (which are the same for both callers)?
Review
Quoted 1 line
(quoted diff) +1
-0+ while ((c = getopt_mkfs(argc, argv, long_options, &option_index)) != EOF) {
Killing the long_opts would also avoid the overly long line here and in the other call site.
mkfs/xfs_mkfs.c main( · line 6148
Quoted 3 lines
mkfs/xfs_mkfs.c +3
-0+if (c =='c' ) { +parse_subopts (c, optarg, defcfg_subopt_tab, &cli); + }
Spurious braces.
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Ted asked for the ability to set default mkfs options, but to retain the ability respecify options via a separate configuration file or cli options. This would be useful for running fstests with the default featureset of (say) Linux 5.15 LTS, while still allowing individual testcases to provide their own overrides. It's certainly less messy than what Ted does today, which is a bash script that copies the desired config file and changes things.
Quoted 1 line
Looks reasonable, do you have a test for it as well?
Somewhere, yeah :)
Quoted 5 lines
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 6028
Quoted 2 lines
mkfs/xfs_mkfs.c +2
-0+static inline int +getopt_mkfs(I don't think there's much of a point in the inline here.
Quoted 11 lines
mkfs/xfs_mkfs.c check_rt_meta_prealloc( · line 6036
Quoted 8 lines
mkfs/xfs_mkfs.c +8
-0+ int argc, + char *const argv[], + const struct option *longopts, + int *longindex) +{ + return getopt_long(argc, argv, "b:c:d:i:l:L:m:n:KNp:qr:s:CfV", + longopts, longindex); +}Why does this hardcode the short options, but requires the caller to pass in the long options (which are the same for both callers)?
long_options is a local variable which contains a pointer into cli, which is another local variable in main().
I could have made a fugly macro with implicit variable access, but that was yuck.
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ while ((c = getopt_mkfs(argc, argv, long_options, &option_index)) != EOF) {Killing the
long_optswould also avoid the overly long line here and in the other call site.
I could just shorten it to "lopts" or something.
Quoted 5 lines
mkfs/xfs_mkfs.c main( · line 6148
Quoted 3 lines
mkfs/xfs_mkfs.c +3
-0+if (c =='c' ) { +parse_subopts (c, optarg, defcfg_subopt_tab, &cli); + }Spurious braces.
Will fix.
--D