From a38507978442f28ace42ec0003c4a2bf61cb4a91 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 5 May 2024 22:46:17 +0200 Subject: reverse: use incrementing inode number for gocryptfs.longname.*.name files ed0a12b7337c2d88c027329f64e73070da17d5b3 already fixed the kernel side, now we also want the .name files to NOT appear hardlinked when just looking at the inode number. Relates-to: https://github.com/rfjakob/gocryptfs/issues/802 --- internal/fusefrontend_reverse/virtualnode.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'internal/fusefrontend_reverse/virtualnode.go') diff --git a/internal/fusefrontend_reverse/virtualnode.go b/internal/fusefrontend_reverse/virtualnode.go index 688f536..922cfa7 100644 --- a/internal/fusefrontend_reverse/virtualnode.go +++ b/internal/fusefrontend_reverse/virtualnode.go @@ -86,8 +86,15 @@ func (n *Node) newVirtualMemNode(content []byte, parentStat *syscall.Stat_t, ino // Adjust inode number and size rn := n.rootNode() st := parentStat - q := inomap.NewQIno(uint64(st.Dev), inoTag, uint64(st.Ino)) - st.Ino = rn.inoMap.Translate(q) + if inoTag == inoTagNameFile { + // No stable mapping for gocryptfs.longname.*.name files, instead use an + // incrementing counter. We don't want two of those files to ever have the + // same inode number, even for hard-linked files. + st.Ino = rn.inoMap.NextSpillIno() + } else { + q := inomap.NewQIno(uint64(st.Dev), inoTag, uint64(st.Ino)) + st.Ino = rn.inoMap.Translate(q) + } st.Size = int64(len(content)) st.Mode = virtualFileMode st.Nlink = 1 -- cgit v1.2.3