From eba49402e44971fdf007c8b33aa71c29bc2a7cad Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Tue, 28 Nov 2017 01:11:19 +0100 Subject: fusefrontend: Introduce a openBackingPath helper and use it to simplify Mknod and Symlink --- internal/fusefrontend/fs.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'internal/fusefrontend/fs.go') diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index bb8e1cf..a77eae0 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -278,17 +278,12 @@ func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context) if fs.isFiltered(path) { return fuse.EPERM } - cPath, err := fs.getBackingPath(path) - if err != nil { - return fuse.ToStatus(err) - } - dirfd, err := os.Open(filepath.Dir(cPath)) + dirfd, cName, err := fs.openBackingPath(path) if err != nil { return fuse.ToStatus(err) } defer dirfd.Close() // Create ".name" file to store long file name (except in PlaintextNames mode) - cName := filepath.Base(cPath) if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) { err = fs.nameTransform.WriteLongName(dirfd, cName, path) if err != nil { @@ -423,11 +418,7 @@ func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (co if fs.isFiltered(linkName) { return fuse.EPERM } - cPath, err := fs.getBackingPath(linkName) - if err != nil { - return fuse.ToStatus(err) - } - dirfd, err := os.Open(filepath.Dir(cPath)) + dirfd, cName, err := fs.openBackingPath(linkName) if err != nil { return fuse.ToStatus(err) } @@ -439,7 +430,6 @@ func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (co cTarget = fs.nameTransform.B64.EncodeToString(cBinTarget) } // Create ".name" file to store long file name (except in PlaintextNames mode) - cName := filepath.Base(cPath) if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) { err = fs.nameTransform.WriteLongName(dirfd, cName, linkName) if err != nil { -- cgit v1.2.3