aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorSebastian Lackner2017-11-28 01:28:29 +0100
committerrfjakob2017-11-28 09:28:06 +0100
commit5d44a31b412e3db07313d3f7e839e2838cff67c0 (patch)
treec5f6cf1e8ccd32b025e41954eadf3bac10d0416e /internal
parent2591900b6920a71f754779807bafeb01bfef5ab3 (diff)
fusefrontend: Use openBackingPath in Unlink and simplify code
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/fs.go26
1 files changed, 8 insertions, 18 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index 46787e2..08edd2b 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -382,33 +382,23 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
if fs.isFiltered(path) {
return fuse.EPERM
}
- cPath, err := fs.getBackingPath(path)
+ dirfd, cName, err := fs.openBackingPath(path)
if err != nil {
return fuse.ToStatus(err)
}
-
- cName := filepath.Base(cPath)
+ defer dirfd.Close()
+ // Delete content
+ err = syscallcompat.Unlinkat(int(dirfd.Fd()), cName)
+ if err != nil {
+ return fuse.ToStatus(err)
+ }
+ // Delete ".name" file
if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) {
- var dirfd *os.File
- dirfd, err = os.Open(filepath.Dir(cPath))
- if err != nil {
- return fuse.ToStatus(err)
- }
- defer dirfd.Close()
- // Delete content
- err = syscallcompat.Unlinkat(int(dirfd.Fd()), cName)
- if err != nil {
- return fuse.ToStatus(err)
- }
- // Delete ".name"
err = nametransform.DeleteLongName(dirfd, cName)
if err != nil {
tlog.Warn.Printf("Unlink: could not delete .name file: %v", err)
}
- return fuse.ToStatus(err)
}
-
- err = syscall.Unlink(cPath)
return fuse.ToStatus(err)
}