aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file2_setattr.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-08-16 12:48:16 +0200
committerJakob Unterwurzacher2020-08-16 12:50:33 +0200
commitee5ab1cc29c6f5ff6061a88b742d5ff88de40802 (patch)
tree023406f3b09208a145d8cec8ebe81d9ebd62e09d /internal/fusefrontend/file2_setattr.go
parent94e8fc12ea5756a130e7ac9ed67ddd519b5f3a22 (diff)
v2api: rename "File2" to just "File"
Rename the symbols and the files.
Diffstat (limited to 'internal/fusefrontend/file2_setattr.go')
-rw-r--r--internal/fusefrontend/file2_setattr.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/internal/fusefrontend/file2_setattr.go b/internal/fusefrontend/file2_setattr.go
deleted file mode 100644
index 1385f3f..0000000
--- a/internal/fusefrontend/file2_setattr.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package fusefrontend
-
-import (
- "context"
- "syscall"
-
- "github.com/hanwen/go-fuse/v2/fs"
- "github.com/hanwen/go-fuse/v2/fuse"
-
- "github.com/rfjakob/gocryptfs/internal/syscallcompat"
- "github.com/rfjakob/gocryptfs/internal/tlog"
-)
-
-func (f *File2) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) (errno syscall.Errno) {
- errno = f.setAttr(ctx, in)
- if errno != 0 {
- return errno
- }
- return f.Getattr(ctx, out)
-}
-
-func (f *File2) setAttr(ctx context.Context, in *fuse.SetAttrIn) (errno syscall.Errno) {
- f.fdLock.RLock()
- defer f.fdLock.RUnlock()
- if f.released {
- tlog.Warn.Printf("ino%d fh%d: Truncate on released file", f.qIno.Ino, f.intFd())
- return syscall.EBADF
- }
- f.fileTableEntry.ContentLock.Lock()
- defer f.fileTableEntry.ContentLock.Unlock()
-
- // fchmod(2)
- if mode, ok := in.GetMode(); ok {
- errno = fs.ToErrno(syscall.Fchmod(f.intFd(), mode))
- if errno != 0 {
- return errno
- }
- }
-
- // fchown(2)
- uid32, uOk := in.GetUID()
- gid32, gOk := in.GetGID()
- if uOk || gOk {
- uid := -1
- gid := -1
-
- if uOk {
- uid = int(uid32)
- }
- if gOk {
- gid = int(gid32)
- }
- errno = fs.ToErrno(syscall.Fchown(f.intFd(), uid, gid))
- if errno != 0 {
- return errno
- }
- }
-
- // utimens(2)
- mtime, mok := in.GetMTime()
- atime, aok := in.GetATime()
- if mok || aok {
- ap := &atime
- mp := &mtime
- if !aok {
- ap = nil
- }
- if !mok {
- mp = nil
- }
- errno = fs.ToErrno(syscallcompat.FutimesNano(f.intFd(), ap, mp))
- if errno != 0 {
- return errno
- }
- }
-
- // truncate(2)
- if sz, ok := in.GetSize(); ok {
- errno = syscall.Errno(f.truncate(sz))
- if errno != 0 {
- return errno
- }
- }
- return 0
-}