public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Nithurshen <nithurshen.dev@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, hsiangkao@linux.alibaba.com,
	Nithurshen <nithurshen.dev@gmail.com>
Subject: [PATCH v2] erofs-utils: mkfs: add --exclude-path-from and --exclude-regex-from
Date: Mon, 16 Mar 2026 16:22:40 +0530	[thread overview]
Message-ID: <20260316105242.6894-3-nithurshen.dev@gmail.com> (raw)
In-Reply-To: <20260316105242.6894-1-nithurshen.dev@gmail.com>

Currently, users who want to exclude multiple specific files or paths
must pass them one-by-one using --exclude-path or --exclude-regex via
the command line. This becomes cumbersome for complex build systems
with dozens of exclusions.

This patch introduces --exclude-path-from=FILE and
--exclude-regex-from=FILE flags to mkfs.erofs. Similar to standard
archiving tools, they allow users to supply a text file containing a
list of literal paths or regular expressions to exclude, which are
read line-by-line and applied to the EROFS build process.

Signed-off-by: Nithurshen <nithurshen.dev@gmail.com>
---
 mkfs/main.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/mkfs/main.c b/mkfs/main.c
index 07ef086..1240771 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -39,6 +39,8 @@ static struct option long_options[] = {
 	{"help", no_argument, 0, 'h'},
 	{"exclude-path", required_argument, NULL, 2},
 	{"exclude-regex", required_argument, NULL, 3},
+	{"exclude-path-from", required_argument, NULL, 540},
+	{"exclude-regex-from", required_argument, NULL, 541},
 #ifdef HAVE_LIBSELINUX
 	{"file-contexts", required_argument, NULL, 4},
 #endif
@@ -199,6 +201,8 @@ static void usage(int argc, char **argv)
 		" --dsunit=#             align all data block addresses to multiples of #\n"
 		" --exclude-path=X       avoid including file X (X = exact literal path)\n"
 		" --exclude-regex=X      avoid including files that match X (X = regular expression)\n"
+		" --exclude-path-from=X  avoid including files listed in file X\n"
+		" --exclude-regex-from=X avoid including regexes listed in file X\n"
 #ifdef HAVE_LIBSELINUX
 		" --file-contexts=X      specify a file contexts file to setup selinux labels\n"
 #endif
@@ -1246,6 +1250,41 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 		case 7:
 			params->fixed_uid = params->fixed_gid = 0;
 			break;
+			case 540:
+			case 541: {
+				FILE *f = fopen(optarg, "r");
+				if (!f) {
+					erofs_err("failed to open exclude file: %s", optarg);
+					return -errno;
+				}
+
+				char *line = NULL;
+				size_t len = 0;
+				ssize_t read;
+				bool is_regex = (opt == 541);
+
+				while ((read = getline(&line, &len, f)) != -1) {
+					if (read > 0 && line[read - 1] == '\n') {
+						line[read - 1] = '\0';
+						read--;
+					}
+
+					if (read == 0) continue;
+
+					err = erofs_parse_exclude_path(line, is_regex);
+					if (err) {
+						erofs_err("failed to parse exclude rule from file: %s",
+							  erofs_strerror(err));
+						free(line);
+						fclose(f);
+						return err;
+					}
+				}
+				free(line);
+				fclose(f);
+				break;
+			}
+
 #ifndef NDEBUG
 		case 8:
 			cfg.c_random_pclusterblks = true;
-- 
2.51.0



  parent reply	other threads:[~2026-03-16 10:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06  8:57 [PATCH 0/2] erofs-utils: minor cleanups and enhancements Nithurshen
2026-03-06  8:57 ` [PATCH 1/2] erofs-utils: dump: remove redundant conditional branch in filesize distribution Nithurshen
2026-03-06  8:57 ` [PATCH 2/2] erofs-utils: fsck: add warning for unsupported file types during extraction Nithurshen
2026-03-16 10:05 ` [PATCH 0/2] erofs-utils: minor cleanups and enhancements Gao Xiang
2026-03-16 10:52 ` [PATCH v2 " Nithurshen
2026-03-16 10:52   ` [PATCH v2 1/2] erofs-utils: dump: remove redundant conditional branch in filesize distribution Nithurshen
2026-03-16 10:52   ` Nithurshen [this message]
2026-03-16 10:52   ` [PATCH v2] mkfs: support block map for blob devices Nithurshen
2026-03-16 10:52   ` [PATCH v2 2/2] erofs-utils: fsck: add warning for unsupported file types during extraction Nithurshen
2026-03-16 10:59 ` [PATCH v3 0/2] erofs-utils: minor cleanups and enhancements Nithurshen
2026-03-16 10:59   ` [PATCH v3 1/2] erofs-utils: dump: remove redundant conditional branch in filesize distribution Nithurshen
2026-03-16 10:59   ` [PATCH v3 2/2] erofs-utils: fsck: add warning for unsupported file types during extraction Nithurshen
  -- strict thread matches above, loose matches on Subject: below --
2026-03-08  3:47 [PATCH] erofs-utils: mkfs: add --exclude-from option Nithurshen
2026-03-09 12:47 ` [PATCH v2] erofs-utils: mkfs: add --exclude-path-from and --exclude-regex-from Nithurshen
2026-03-09 12:50 ` Nithurshen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260316105242.6894-3-nithurshen.dev@gmail.com \
    --to=nithurshen.dev@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox