aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend_reverse/virtualfile.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/fusefrontend_reverse/virtualfile.go')
-rw-r--r--internal/fusefrontend_reverse/virtualfile.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/internal/fusefrontend_reverse/virtualfile.go b/internal/fusefrontend_reverse/virtualfile.go
index 2bd9e88..00fa726 100644
--- a/internal/fusefrontend_reverse/virtualfile.go
+++ b/internal/fusefrontend_reverse/virtualfile.go
@@ -9,6 +9,18 @@ import (
"github.com/rfjakob/gocryptfs/internal/tlog"
)
+const (
+ // virtualFileMode is the mode to use for virtual files (gocryptfs.diriv and
+ // *.name). They are always readable, as stated in func Access
+ virtualFileMode = syscall.S_IFREG | 0444
+ // virtualInoBase is the start of the inode number range that is used
+ // for virtual files.
+ // The value 10^19 is just below 2^60. A power of 10 has been chosen so the
+ // "ls -li" output (which is base-10) is easy to read.
+ // 10^19 is the largest power of 10 that is smaller than UINT64_MAX/2.
+ virtualInoBase = uint64(1000000000000000000)
+)
+
func (rfs *ReverseFS) newDirIVFile(cRelPath string) (nodefs.File, fuse.Status) {
cDir := saneDir(cRelPath)
absDir, err := rfs.abs(rfs.decryptPath(cDir))
@@ -25,8 +37,6 @@ type virtualFile struct {
content []byte
// absolute path to a parent file
parentFile string
- // inode number
- ino uint64
}
// newVirtualFile creates a new in-memory file that does not have a representation
@@ -38,7 +48,6 @@ func (rfs *ReverseFS) newVirtualFile(content []byte, parentFile string) (nodefs.
File: nodefs.NewDefaultFile(),
content: content,
parentFile: parentFile,
- ino: rfs.inoGen.next(),
}, fuse.OK
}
@@ -62,7 +71,12 @@ func (f *virtualFile) GetAttr(a *fuse.Attr) fuse.Status {
tlog.Debug.Printf("GetAttr: Lstat %q: %v\n", f.parentFile, err)
return fuse.ToStatus(err)
}
- st.Ino = f.ino
+ if st.Ino > virtualInoBase {
+ tlog.Warn.Printf("virtualFile.GetAttr: parent file inode number %d crosses reserved space, max=%d. Returning EOVERFLOW.",
+ st.Ino, virtualInoBase)
+ return fuse.ToStatus(syscall.EOVERFLOW)
+ }
+ st.Ino = st.Ino + virtualInoBase
st.Size = int64(len(f.content))
st.Mode = virtualFileMode
st.Nlink = 1