|
| 1 | +From b20a9a213e1f4901072f559e3aef4797b5955c59 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Sparks Song < [email protected]> |
| 3 | +Date: Wed, 4 Dec 2024 23:47:28 +0000 |
| 4 | +Subject: [PATCH] mkfs: source defaults from config file to make nrext64 |
| 5 | + default off on multiple kernel versions |
| 6 | + |
| 7 | +--- |
| 8 | + mkfs/xfs_mkfs.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- |
| 9 | + 1 file changed, 50 insertions(+), 1 deletion(-) |
| 10 | + |
| 11 | +diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c |
| 12 | +index 6d2469c..1f6f643 100644 |
| 13 | +--- a/mkfs/xfs_mkfs.c |
| 14 | ++++ b/mkfs/xfs_mkfs.c |
| 15 | +@@ -39,6 +39,9 @@ |
| 16 | + */ |
| 17 | + #define WHACK_SIZE (128 * 1024) |
| 18 | + |
| 19 | ++/* Default path for the mkfs.xfs configuration file */ |
| 20 | ++#define DEFAULT_CONFIG_PATH "/usr/share/xfs/mkfs.xfs.conf" |
| 21 | ++ |
| 22 | + /* |
| 23 | + * XXX: The configured block and sector sizes are defined as global variables so |
| 24 | + * that they don't need to be passed to getnum/cvtnum(). |
| 25 | +@@ -4271,6 +4274,44 @@ cfgfile_parse( |
| 26 | + cli->cfgfile); |
| 27 | + } |
| 28 | + |
| 29 | ++ |
| 30 | ++/* This function is similar to cfgfile_parse() and specifically parses |
| 31 | ++ * default config files. It doesn’t exit on failure. |
| 32 | ++ */ |
| 33 | ++static void |
| 34 | ++cfgfile_parse_default( |
| 35 | ++ struct cli_params *cli) |
| 36 | ++{ |
| 37 | ++ int error; |
| 38 | ++ |
| 39 | ++ if (!cli->cfgfile) |
| 40 | ++ return; |
| 41 | ++ |
| 42 | ++ error = ini_parse(cli->cfgfile, cfgfile_parse_ini, cli); |
| 43 | ++ if (error) { |
| 44 | ++ if (error > 0) { |
| 45 | ++ fprintf(stderr, |
| 46 | ++ _("%s: Unrecognised input on line %d. Aborting.\n"), |
| 47 | ++ cli->cfgfile, error); |
| 48 | ++ } else if (error == -1) { |
| 49 | ++ fprintf(stderr, |
| 50 | ++ _("Unable to open default config file %s. Aborting.\n"), |
| 51 | ++ cli->cfgfile); |
| 52 | ++ } else if (error == -2) { |
| 53 | ++ fprintf(stderr, |
| 54 | ++ _("Memory allocation failure parsing %s. Aborting.\n"), |
| 55 | ++ cli->cfgfile); |
| 56 | ++ } else { |
| 57 | ++ fprintf(stderr, |
| 58 | ++ _("Unknown error %d opening default config file %s. Aborting.\n"), |
| 59 | ++ error, cli->cfgfile); |
| 60 | ++ } |
| 61 | ++ } else { |
| 62 | ++ printf(_("Parameters parsed from default config file %s successfully\n"), |
| 63 | ++ cli->cfgfile); |
| 64 | ++ } |
| 65 | ++} |
| 66 | ++ |
| 67 | + int |
| 68 | + main( |
| 69 | + int argc, |
| 70 | +@@ -4428,7 +4469,15 @@ main( |
| 71 | + * the options from this file parsed, we can then proceed with parameter |
| 72 | + * and bounds checking and making the filesystem. |
| 73 | + */ |
| 74 | +- cfgfile_parse(&cli); |
| 75 | ++ |
| 76 | ++ if (cli.cfgfile == NULL) { |
| 77 | ++ /* No user config file specified, try default config */ |
| 78 | ++ cli.cfgfile = DEFAULT_CONFIG_PATH; |
| 79 | ++ cfgfile_parse_default(&cli); |
| 80 | ++ } else { |
| 81 | ++ /* User specified their own config file, use that */ |
| 82 | ++ cfgfile_parse(&cli); |
| 83 | ++ } |
| 84 | + |
| 85 | + protostring = setup_proto(cli.protofile); |
| 86 | + |
| 87 | +-- |
| 88 | +2.47.0 |
| 89 | + |
0 commit comments