All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Meyer <katexochen0@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: Paul Meyer <katexochen0@gmail.com>,
	Leonard Cohnen <leonard.cohnen@gmail.com>
Subject: [PATCH] erofs-utils: add --hardlink-dereference option
Date: Wed, 11 Dec 2024 16:07:34 +0100	[thread overview]
Message-ID: <20241211150734.97830-1-katexochen0@gmail.com> (raw)

Add option --hardlink-dereference to dereference hardlinks when
creating an image. Instead of reusing the inode, hardlinks are added
as separate inodes. This is useful for reproducible builds, when the
rootfs is space-optimized using hardlinks on some machines, but not on
others.

Co-authored-by: Leonard Cohnen <leonard.cohnen@gmail.com>
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
---
 include/erofs/config.h | 1 +
 lib/inode.c            | 2 +-
 mkfs/main.c            | 4 ++++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/erofs/config.h b/include/erofs/config.h
index cff4cea..8399afb 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -58,6 +58,7 @@ struct erofs_configure {
 	bool c_extra_ea_name_prefixes;
 	bool c_xattr_name_filter;
 	bool c_ovlfs_strip;
+	bool c_hardlink_dereference;
 
 #ifdef HAVE_LIBSELINUX
 	struct selabel_handle *sehnd;
diff --git a/lib/inode.c b/lib/inode.c
index 7e5c581..5d181b3 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1141,7 +1141,7 @@ static struct erofs_inode *erofs_iget_from_srcpath(struct erofs_sb_info *sbi,
 	 * hard-link, just return it. Also don't lookup for directories
 	 * since hard-link directory isn't allowed.
 	 */
-	if (!S_ISDIR(st.st_mode)) {
+	if (!S_ISDIR(st.st_mode) && (!cfg.c_hardlink_dereference)) {
 		inode = erofs_iget(st.st_dev, st.st_ino);
 		if (inode)
 			return inode;
diff --git a/mkfs/main.c b/mkfs/main.c
index d422787..09e39f5 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -85,6 +85,7 @@ static struct option long_options[] = {
 	{"mkfs-time", no_argument, NULL, 525},
 	{"all-time", no_argument, NULL, 526},
 	{"sort", required_argument, NULL, 527},
+	{"hardlink-dereference", no_argument, NULL, 528},
 	{0, 0, 0, 0},
 };
 
@@ -846,6 +847,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (!strcmp(optarg, "none"))
 				erofstar.try_no_reorder = true;
 			break;
+		case 528:
+			cfg.c_hardlink_dereference = true;
+			break;
 		case 'V':
 			version();
 			exit(0);
-- 
2.47.0


             reply	other threads:[~2024-12-11 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-11 15:07 Paul Meyer [this message]
2024-12-11 16:10 ` [PATCH] erofs-utils: add --hardlink-dereference option Gao Xiang
2024-12-12  9:40   ` Paul M
2024-12-12  9:54     ` Gao Xiang

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=20241211150734.97830-1-katexochen0@gmail.com \
    --to=katexochen0@gmail.com \
    --cc=leonard.cohnen@gmail.com \
    --cc=linux-erofs@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.