teknoraver / rpms / rpm

Forked from rpms/rpm 2 months ago
Clone

Blame 0037-plugin_path.patch

bd9c00
--- a/plugins/reflink.c
bd9c00
+++ b/plugins/reflink.c
bd9c00
@@ -277,13 +277,17 @@ static rpmRC reflink_fsm_file_install(rpmPlugin plugin, rpmfi fi, const char* pa
bd9c00
     fcr.dest_offset = 0;
bd9c00
     if (S_ISREG(file_mode) && !(rpmfiFFlags(fi) & RPMFILE_GHOST)) {
bd9c00
 	rpm_ino_t inode = rpmfiFInode(fi);
bd9c00
+        char fullpath[PATH_MAX];
bd9c00
+
bd9c00
+        snprintf(fullpath, sizeof(fullpath), "%s/%s", rpmfiDN(fi), path);
bd9c00
+
bd9c00
 	/* check for hard link entry in table. GetEntry overwrites hlix with
bd9c00
 	 * the address of the first match.
bd9c00
 	 */
bd9c00
 	if (inodeIndexHashGetEntry(state->inodeIndexes, inode, &hl_target,
bd9c00
 				   NULL, NULL)) {
bd9c00
 	    /* entry is in table, use hard link */
bd9c00
-	    if (link(hl_target[0], path) != 0) {
bd9c00
+	    if (link(hl_target[0], fullpath) != 0) {
bd9c00
 		rpmlog(RPMLOG_ERR,
bd9c00
 		       _("reflink: Unable to hard link %s -> %s due to %s\n"),
bd9c00
 		       hl_target[0], path, strerror(errno));
bd9c00
@@ -296,11 +300,11 @@ static rpmRC reflink_fsm_file_install(rpmPlugin plugin, rpmfi fi, const char* pa
bd9c00
 	 */
bd9c00
 	if (rpmfiFNlink(fi) > 1) {
bd9c00
 	    /* minor optimization: only store files with more than one link */
bd9c00
-	    inodeIndexHashAddEntry(state->inodeIndexes, inode, rstrdup(path));
bd9c00
+	    inodeIndexHashAddEntry(state->inodeIndexes, inode, rstrdup(fullpath));
bd9c00
 	}
bd9c00
 	/* derived from wfd_open in fsm.c */
bd9c00
 	mode_t old_umask = umask(0577);
bd9c00
-	dst = open(path, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR);
bd9c00
+	dst = open(fullpath, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR);
bd9c00
 	umask(old_umask);
bd9c00
 	if (dst == -1) {
bd9c00
 	    rpmlog(RPMLOG_ERR,