teknoraver / rpms / rpm

Forked from rpms/rpm 2 months ago
Clone
Blob Blame History Raw
From 3310d203e0aa162428c7b9dc1e9d8e09da768608 Mon Sep 17 00:00:00 2001
From: Matteo Croce <teknoraver@meta.com>
Date: Sat, 14 Sep 2024 09:32:48 -0700
Subject: [PATCH] reflink: set metadata for hardlinked files

RPM deduplicates identical files by creating them as hardlinks.
Since metadata is shared between copies, permissions are set when
extracting the last copy.
This breaks reflinks, where each copy has its own metadata.
Fix it by always set metadata when the file content is handled by a plugin.
---
 lib/fsm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/fsm.c b/lib/fsm.c
index 05c5bcf..e562220 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1010,6 +1010,8 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
 		rc = plugin_rc;
 	    } else if(plugin_rc == RPMRC_PLUGIN_CONTENTS){
 		rc = RPMRC_OK;
+		/* The reflink plugins handles hardlink differently, metadata has to be set. */
+		fp->setmeta = 1;
 	    } else if (S_ISREG(fp->sb.st_mode)) {
 		if (rc == RPMERR_ENOENT) {
 		    rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest,
-- 
2.43.5