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