Skip to content

Commit

Permalink
patch: patching xfsprogs to source default config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparksssj committed Dec 6, 2024
1 parent e00a34e commit abbc6cf
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
89 changes: 89 additions & 0 deletions packages/xfsprogs/0001-mkfs-source-defaults-from-config-file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
From b20a9a213e1f4901072f559e3aef4797b5955c59 Mon Sep 17 00:00:00 2001
From: Sparks Song <[email protected]>
Date: Wed, 4 Dec 2024 23:47:28 +0000
Subject: [PATCH] mkfs: source defaults from config file to make nrext64
default off on multiple kernel versions

---
mkfs/xfs_mkfs.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 6d2469c..1f6f643 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -39,6 +39,9 @@
*/
#define WHACK_SIZE (128 * 1024)

+/* Default path for the mkfs.xfs configuration file */
+#define DEFAULT_CONFIG_PATH "/usr/share/xfs/mkfs.xfs.conf"
+
/*
* XXX: The configured block and sector sizes are defined as global variables so
* that they don't need to be passed to getnum/cvtnum().
@@ -4271,6 +4274,44 @@ cfgfile_parse(
cli->cfgfile);
}

+
+/* This function is similar to cfgfile_parse() and specifically parses
+ * default config files. It doesn’t exit on failure.
+ */
+static void
+cfgfile_parse_default(
+ struct cli_params *cli)
+{
+ int error;
+
+ if (!cli->cfgfile)
+ return;
+
+ error = ini_parse(cli->cfgfile, cfgfile_parse_ini, cli);
+ if (error) {
+ if (error > 0) {
+ fprintf(stderr,
+ _("%s: Unrecognised input on line %d. Aborting.\n"),
+ cli->cfgfile, error);
+ } else if (error == -1) {
+ fprintf(stderr,
+ _("Unable to open default config file %s. Aborting.\n"),
+ cli->cfgfile);
+ } else if (error == -2) {
+ fprintf(stderr,
+ _("Memory allocation failure parsing %s. Aborting.\n"),
+ cli->cfgfile);
+ } else {
+ fprintf(stderr,
+ _("Unknown error %d opening default config file %s. Aborting.\n"),
+ error, cli->cfgfile);
+ }
+ } else {
+ printf(_("Parameters parsed from default config file %s successfully\n"),
+ cli->cfgfile);
+ }
+}
+
int
main(
int argc,
@@ -4428,7 +4469,15 @@ main(
* the options from this file parsed, we can then proceed with parameter
* and bounds checking and making the filesystem.
*/
- cfgfile_parse(&cli);
+
+ if (cli.cfgfile == NULL) {
+ /* No user config file specified, try default config */
+ cli.cfgfile = DEFAULT_CONFIG_PATH;
+ cfgfile_parse_default(&cli);
+ } else {
+ /* User specified their own config file, use that */
+ cfgfile_parse(&cli);
+ }

protostring = setup_proto(cli.protofile);

--
2.47.0

7 changes: 6 additions & 1 deletion packages/xfsprogs/xfsprogs.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ License: GPL-2.0-only AND LGPL-2.1-only
URL: https://xfs.wiki.kernel.org
Source0: http://kernel.org/pub/linux/utils/fs/xfs/xfsprogs/xfsprogs-%{version}.tar.xz

Patch1000: 0001-mkfs-source-defaults-from-config-file.patch

BuildRequires: %{_cross_os}glibc-devel
BuildRequires: %{_cross_os}libuuid-devel
BuildRequires: %{_cross_os}libinih-devel
Expand All @@ -14,6 +16,9 @@ BuildRequires: %{_cross_os}libblkid-devel

Requires: %{_cross_os}liburcu
Requires: %{_cross_os}libinih
Requires: (%{_cross_os}kernel-5.10-mkfs-confs if %{_cross_os}kernel-5.10)
Requires: (%{_cross_os}kernel-5.15-mkfs-confs if %{_cross_os}kernel-5.15)
Requires: (%{_cross_os}kernel-6.1-mkfs-confs if %{_cross_os}kernel-6.1)

%description
%{summary}.
Expand All @@ -26,7 +31,7 @@ Requires: %{name}
%{summary}.

%prep
%autosetup -n xfsprogs-%{version}
%autosetup -n xfsprogs-%{version} -p1

%build
%cross_configure \
Expand Down

0 comments on commit abbc6cf

Please sign in to comment.