2016-02-06 19:27:59 +01:00
|
|
|
package fusefrontend
|
2015-09-08 00:54:24 +02:00
|
|
|
|
2015-12-19 13:21:15 +01:00
|
|
|
// FUSE operations on paths
|
|
|
|
|
2015-09-08 00:54:24 +02:00
|
|
|
import (
|
2015-11-27 00:03:10 +01:00
|
|
|
"encoding/base64"
|
2015-09-08 00:54:24 +02:00
|
|
|
"os"
|
2015-11-27 22:20:01 +01:00
|
|
|
"sync"
|
|
|
|
"syscall"
|
2015-09-08 00:54:24 +02:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hanwen/go-fuse/fuse"
|
|
|
|
"github.com/hanwen/go-fuse/fuse/nodefs"
|
|
|
|
"github.com/hanwen/go-fuse/fuse/pathfs"
|
2016-02-06 19:20:54 +01:00
|
|
|
|
2016-02-06 20:23:36 +01:00
|
|
|
"github.com/rfjakob/gocryptfs/internal/contentenc"
|
2016-02-06 19:20:54 +01:00
|
|
|
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
|
|
|
"github.com/rfjakob/gocryptfs/internal/nametransform"
|
2016-02-06 20:23:36 +01:00
|
|
|
"github.com/rfjakob/gocryptfs/internal/toggledlog"
|
2015-09-08 00:54:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type FS struct {
|
2015-11-29 21:55:20 +01:00
|
|
|
pathfs.FileSystem // loopbackFileSystem, see go-fuse/fuse/pathfs/loopback.go
|
|
|
|
args Args // Stores configuration arguments
|
2015-11-27 21:48:58 +01:00
|
|
|
// dirIVLock: Lock()ed if any "gocryptfs.diriv" file is modified
|
|
|
|
// Readers must RLock() it to prevent them from seeing intermediate
|
|
|
|
// states
|
|
|
|
dirIVLock sync.RWMutex
|
2016-02-06 19:20:54 +01:00
|
|
|
// Filename encryption helper
|
|
|
|
nameTransform *nametransform.NameTransform
|
|
|
|
// Content encryption helper
|
|
|
|
contentEnc *contentenc.ContentEnc
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Encrypted FUSE overlay filesystem
|
2015-11-28 16:52:57 +01:00
|
|
|
func NewFS(args Args) *FS {
|
2016-02-06 19:20:54 +01:00
|
|
|
|
|
|
|
cryptoCore := cryptocore.New(args.Masterkey, args.OpenSSL, args.GCMIV128)
|
2016-02-06 20:22:45 +01:00
|
|
|
contentEnc := contentenc.New(cryptoCore, contentenc.DefaultBS)
|
2016-02-06 22:54:14 +01:00
|
|
|
nameTransform := nametransform.New(cryptoCore, args.EMENames, args.LongNames)
|
2016-02-06 19:20:54 +01:00
|
|
|
|
2015-09-08 00:54:24 +02:00
|
|
|
return &FS{
|
2016-02-06 20:23:36 +01:00
|
|
|
FileSystem: pathfs.NewLoopbackFileSystem(args.Cipherdir),
|
|
|
|
args: args,
|
2016-02-06 19:20:54 +01:00
|
|
|
nameTransform: nameTransform,
|
2016-02-06 20:23:36 +01:00
|
|
|
contentEnc: contentEnc,
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("FS.GetAttr('%s')", name)
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(name) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return nil, fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cName, err := fs.encryptPath(name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fuse.ToStatus(err)
|
|
|
|
}
|
2015-09-16 19:32:37 +02:00
|
|
|
a, status := fs.FileSystem.GetAttr(cName, context)
|
2015-09-08 00:54:24 +02:00
|
|
|
if a == nil {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("FS.GetAttr failed: %s", status.String())
|
2015-09-08 00:54:24 +02:00
|
|
|
return a, status
|
|
|
|
}
|
2015-09-16 19:32:37 +02:00
|
|
|
if a.IsRegular() {
|
2016-02-06 19:20:54 +01:00
|
|
|
a.Size = fs.contentEnc.CipherSizeToPlainSize(a.Size)
|
2015-09-16 19:32:37 +02:00
|
|
|
} else if a.IsSymlink() {
|
|
|
|
target, _ := fs.Readlink(name, context)
|
|
|
|
a.Size = uint64(len(target))
|
|
|
|
}
|
2015-09-08 00:54:24 +02:00
|
|
|
return a, status
|
|
|
|
}
|
|
|
|
|
|
|
|
// We always need read access to do read-modify-write cycles
|
|
|
|
func (fs *FS) mangleOpenFlags(flags uint32) (newFlags int, writeOnly bool) {
|
|
|
|
newFlags = int(flags)
|
2015-10-04 14:36:20 +02:00
|
|
|
if newFlags&os.O_WRONLY > 0 {
|
2015-09-08 00:54:24 +02:00
|
|
|
writeOnly = true
|
|
|
|
newFlags = newFlags ^ os.O_WRONLY | os.O_RDWR
|
|
|
|
}
|
|
|
|
// We also cannot open the file in append mode, we need to seek back for RMW
|
|
|
|
newFlags = newFlags &^ os.O_APPEND
|
|
|
|
|
|
|
|
return newFlags, writeOnly
|
|
|
|
}
|
|
|
|
|
2015-11-03 00:00:13 +01:00
|
|
|
func (fs *FS) Open(path string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 00:00:13 +01:00
|
|
|
return nil, fuse.EPERM
|
|
|
|
}
|
2015-09-08 00:54:24 +02:00
|
|
|
iflags, writeOnly := fs.mangleOpenFlags(flags)
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.getBackingPath(path)
|
|
|
|
if err != nil {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("Open: getBackingPath: %v", err)
|
2015-11-27 00:03:10 +01:00
|
|
|
return nil, fuse.ToStatus(err)
|
|
|
|
}
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("Open: %s", cPath)
|
2015-11-27 00:03:10 +01:00
|
|
|
f, err := os.OpenFile(cPath, iflags, 0666)
|
2015-09-08 00:54:24 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
|
2016-02-06 19:20:54 +01:00
|
|
|
return NewFile(f, writeOnly, fs.contentEnc), fuse.OK
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) Create(path string, flags uint32, mode uint32, context *fuse.Context) (fuseFile nodefs.File, code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return nil, fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-09-08 00:54:24 +02:00
|
|
|
iflags, writeOnly := fs.mangleOpenFlags(flags)
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.getBackingPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fuse.ToStatus(err)
|
|
|
|
}
|
2016-02-07 14:02:09 +01:00
|
|
|
// Create .name file to store the long file name if needed
|
|
|
|
if !fs.args.PlaintextNames {
|
|
|
|
err = fs.nameTransform.WriteLongName(cPath, path)
|
2016-02-06 22:54:14 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
f, err := os.OpenFile(cPath, iflags|os.O_CREATE, os.FileMode(mode))
|
2015-09-08 00:54:24 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, fuse.ToStatus(err)
|
|
|
|
}
|
2016-02-06 19:20:54 +01:00
|
|
|
return NewFile(f, writeOnly, fs.contentEnc), fuse.OK
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) Chmod(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.encryptPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
return fs.FileSystem.Chmod(cPath, mode, context)
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) Chown(path string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.encryptPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
return fs.FileSystem.Chown(cPath, uid, gid, context)
|
2015-09-18 22:22:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 00:03:10 +01:00
|
|
|
func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.encryptPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
2016-02-07 14:02:09 +01:00
|
|
|
if !fs.args.PlaintextNames {
|
|
|
|
// Create .name file to store the long file name if needed
|
|
|
|
err = fs.nameTransform.WriteLongName(cPath, path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
return fs.FileSystem.Mknod(cPath, mode, dev, context)
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2016-01-24 19:43:21 +01:00
|
|
|
var truncateWarned bool
|
|
|
|
|
2015-09-08 00:54:24 +02:00
|
|
|
func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) {
|
2016-01-24 19:43:21 +01:00
|
|
|
// Only warn once
|
|
|
|
if !truncateWarned {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Warn.Printf("truncate(2) is not supported, returning ENOSYS - use ftruncate(2)")
|
2016-01-24 19:43:21 +01:00
|
|
|
truncateWarned = true
|
|
|
|
}
|
2015-11-01 01:32:33 +01:00
|
|
|
return fuse.ENOSYS
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) Utimens(path string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.encryptPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
return fs.FileSystem.Utimens(cPath, Atime, Mtime, context)
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 00:03:10 +01:00
|
|
|
func (fs *FS) Readlink(path string, context *fuse.Context) (out string, status fuse.Status) {
|
|
|
|
cPath, err := fs.encryptPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return "", fuse.ToStatus(err)
|
|
|
|
}
|
2015-11-28 16:47:30 +01:00
|
|
|
cTarget, status := fs.FileSystem.Readlink(cPath, context)
|
2015-09-09 19:32:59 +02:00
|
|
|
if status != fuse.OK {
|
|
|
|
return "", status
|
|
|
|
}
|
2015-11-28 16:52:57 +01:00
|
|
|
// Old filesystem: symlinks are encrypted like paths (CBC)
|
|
|
|
if !fs.args.DirIV {
|
|
|
|
target, err := fs.decryptPath(cTarget)
|
|
|
|
if err != nil {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Warn.Printf("Readlink: CBC decryption failed: %v", err)
|
2015-11-28 16:52:57 +01:00
|
|
|
return "", fuse.EIO
|
|
|
|
}
|
|
|
|
return target, fuse.OK
|
|
|
|
}
|
|
|
|
// Since gocryptfs v0.5 symlinks are encrypted like file contents (GCM)
|
2015-11-28 16:47:30 +01:00
|
|
|
cBinTarget, err := base64.URLEncoding.DecodeString(cTarget)
|
2015-09-09 19:32:59 +02:00
|
|
|
if err != nil {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Warn.Printf("Readlink: %v", err)
|
2015-09-09 19:32:59 +02:00
|
|
|
return "", fuse.EIO
|
|
|
|
}
|
2016-02-06 19:20:54 +01:00
|
|
|
target, err := fs.contentEnc.DecryptBlock([]byte(cBinTarget), 0, nil)
|
2015-11-28 16:47:30 +01:00
|
|
|
if err != nil {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Warn.Printf("Readlink: %v", err)
|
2015-11-28 16:47:30 +01:00
|
|
|
return "", fuse.EIO
|
|
|
|
}
|
|
|
|
return string(target), fuse.OK
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 00:03:10 +01:00
|
|
|
func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.getBackingPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
2015-09-16 19:32:37 +02:00
|
|
|
}
|
2016-02-07 14:02:09 +01:00
|
|
|
err = syscall.Unlink(cPath)
|
|
|
|
// Delete .name file
|
|
|
|
if err == nil && !fs.args.PlaintextNames {
|
|
|
|
nametransform.DeleteLongName(cPath)
|
|
|
|
}
|
|
|
|
return fuse.ToStatus(err)
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 00:03:10 +01:00
|
|
|
func (fs *FS) Symlink(target string, linkName string, context *fuse.Context) (code fuse.Status) {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("Symlink(\"%s\", \"%s\")", target, linkName)
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(linkName) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-28 16:47:30 +01:00
|
|
|
cPath, err := fs.getBackingPath(linkName)
|
2015-11-27 00:03:10 +01:00
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
2015-11-28 16:52:57 +01:00
|
|
|
// Old filesystem: symlinks are encrypted like paths (CBC)
|
2016-02-07 14:02:09 +01:00
|
|
|
// TODO drop compatibility and simplify code
|
2015-11-28 16:52:57 +01:00
|
|
|
if !fs.args.DirIV {
|
|
|
|
cTarget, err := fs.encryptPath(target)
|
|
|
|
if err != nil {
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Warn.Printf("Symlink: BUG: we should not get an error here: %v", err)
|
2015-11-28 16:52:57 +01:00
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
err = os.Symlink(cTarget, cPath)
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
// Since gocryptfs v0.5 symlinks are encrypted like file contents (GCM)
|
2016-02-06 19:20:54 +01:00
|
|
|
cBinTarget := fs.contentEnc.EncryptBlock([]byte(target), 0, nil)
|
2015-11-27 00:03:10 +01:00
|
|
|
cTarget := base64.URLEncoding.EncodeToString(cBinTarget)
|
2016-02-07 14:02:09 +01:00
|
|
|
if !fs.args.PlaintextNames {
|
|
|
|
// Create .name file to store the long file name if needed
|
|
|
|
err = fs.nameTransform.WriteLongName(cPath, linkName)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-28 16:47:30 +01:00
|
|
|
err = os.Symlink(cTarget, cPath)
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("Symlink: os.Symlink(%s, %s) = %v", cTarget, cPath, err)
|
2015-11-28 16:47:30 +01:00
|
|
|
return fuse.ToStatus(err)
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2015-11-03 22:25:29 +01:00
|
|
|
func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(newPath) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cOldPath, err := fs.getBackingPath(oldPath)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
cNewPath, err := fs.getBackingPath(newPath)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
2015-11-29 21:41:38 +01:00
|
|
|
// The Rename may cause a directory to take the place of another directory.
|
|
|
|
// That directory may still be in the DirIV cache, clear it.
|
2016-02-06 19:20:54 +01:00
|
|
|
fs.nameTransform.DirIVCache.Clear()
|
2015-11-29 21:41:38 +01:00
|
|
|
|
2016-02-07 14:02:09 +01:00
|
|
|
if !fs.args.PlaintextNames {
|
|
|
|
// Create .name file to store the new long file name if needed
|
|
|
|
err = fs.nameTransform.WriteLongName(cNewPath, newPath)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Actual rename
|
2015-12-06 15:00:54 +01:00
|
|
|
err = os.Rename(cOldPath, cNewPath)
|
2015-12-19 13:21:15 +01:00
|
|
|
|
|
|
|
if lerr, ok := err.(*os.LinkError); ok && lerr.Err == syscall.ENOTEMPTY {
|
|
|
|
// If an empty directory is overwritten we will always get
|
|
|
|
// ENOTEMPTY as the "empty" directory will still contain gocryptfs.diriv.
|
|
|
|
// Handle that case by removing the target directory and trying again.
|
2016-02-06 19:20:54 +01:00
|
|
|
toggledlog.Debug.Printf("Rename: Handling ENOTEMPTY")
|
2015-12-19 13:21:15 +01:00
|
|
|
if fs.Rmdir(newPath, context) == fuse.OK {
|
|
|
|
err = os.Rename(cOldPath, cNewPath)
|
|
|
|
}
|
|
|
|
}
|
2016-02-07 14:02:09 +01:00
|
|
|
if err == nil {
|
|
|
|
// Rename succeeded - delete old long name file
|
|
|
|
nametransform.DeleteLongName(cOldPath)
|
|
|
|
} else {
|
|
|
|
// Rename has failed - undo long name file creation
|
|
|
|
nametransform.DeleteLongName(cNewPath)
|
|
|
|
}
|
2015-12-19 13:21:15 +01:00
|
|
|
|
2015-12-06 15:00:54 +01:00
|
|
|
return fuse.ToStatus(err)
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 00:03:10 +01:00
|
|
|
func (fs *FS) Link(oldPath string, newPath string, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(newPath) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
2015-11-03 00:00:13 +01:00
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cOldPath, err := fs.getBackingPath(oldPath)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
cNewPath, err := fs.getBackingPath(newPath)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
2016-02-07 14:02:09 +01:00
|
|
|
if !fs.args.PlaintextNames {
|
|
|
|
// Create .name file to store the long file name if needed
|
|
|
|
err = fs.nameTransform.WriteLongName(cNewPath, newPath)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
return fuse.ToStatus(os.Link(cOldPath, cNewPath))
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 00:03:10 +01:00
|
|
|
func (fs *FS) Access(path string, mode uint32, context *fuse.Context) (code fuse.Status) {
|
2015-12-08 16:13:29 +01:00
|
|
|
if fs.isFiltered(path) {
|
2015-11-03 22:25:29 +01:00
|
|
|
return fuse.EPERM
|
|
|
|
}
|
2015-11-27 00:03:10 +01:00
|
|
|
cPath, err := fs.getBackingPath(path)
|
|
|
|
if err != nil {
|
|
|
|
return fuse.ToStatus(err)
|
|
|
|
}
|
|
|
|
return fuse.ToStatus(syscall.Access(cPath, mode))
|
2015-09-08 00:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
|
|
|
|
return nil, fuse.ENOSYS
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status {
|
|
|
|
return fuse.ENOSYS
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) {
|
|
|
|
return nil, fuse.ENOSYS
|
|
|
|
}
|
|
|
|
|
|
|
|
func (fs *FS) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status {
|
|
|
|
return fuse.ENOSYS
|
|
|
|
}
|