Commit 5cd3775f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add *Context to all FileSystem api methods.

This is needed for creating allow_other filesystems with proper
permission checking
parent e51db3a8
......@@ -106,9 +106,6 @@ Grep source code for TODO. Major topics:
* Missing support for FUSE_INTERRUPT, CUSE, BMAP, POLL, IOCTL
* Partial support for mounting as root (The high level FS api does not
pass caller Uid/Gid/Pid)
* In the high-level API, renames are racy; See also:
http://sourceforge.net/mailarchive/message.php?msg_id=27550667
......
......@@ -40,7 +40,7 @@ func (me *StatFs) add(name string, fi os.FileInfo) {
me.add(dir, os.FileInfo{Mode: fuse.S_IFDIR | 0755})
}
func (me *StatFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
func (me *StatFs) GetAttr(name string, context *fuse.Context) (*os.FileInfo, fuse.Status) {
e := me.entries[name]
if e == nil {
return nil, fuse.ENOENT
......@@ -48,7 +48,7 @@ func (me *StatFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
return e, fuse.OK
}
func (me *StatFs) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.Status) {
func (me *StatFs) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, status fuse.Status) {
log.Printf("OPENDIR '%v', %v %v", name, me.entries, me.dirs)
entries := me.dirs[name]
if entries == nil {
......
......@@ -13,7 +13,7 @@ type HelloFs struct {
fuse.DefaultFileSystem
}
func (me *HelloFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
func (me *HelloFs) GetAttr(name string, context *fuse.Context) (*os.FileInfo, fuse.Status) {
switch name {
case "file.txt":
return &os.FileInfo{
......@@ -27,7 +27,7 @@ func (me *HelloFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
return nil, fuse.ENOENT
}
func (me *HelloFs) OpenDir(name string) (c chan fuse.DirEntry, code fuse.Status) {
func (me *HelloFs) OpenDir(name string, context *fuse.Context) (c chan fuse.DirEntry, code fuse.Status) {
if name == "" {
c = make(chan fuse.DirEntry, 1)
c <- fuse.DirEntry{Name: "file.txt", Mode: fuse.S_IFREG}
......@@ -37,7 +37,7 @@ func (me *HelloFs) OpenDir(name string) (c chan fuse.DirEntry, code fuse.Status)
return nil, fuse.ENOENT
}
func (me *HelloFs) Open(name string, flags uint32) (file fuse.File, code fuse.Status) {
func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
if name != "file.txt" {
return nil, fuse.ENOENT
}
......
......@@ -20,30 +20,30 @@ type FileSystem interface {
Name() string
// Attributes
GetAttr(name string) (*os.FileInfo, Status)
GetAttr(name string, context *Context) (*os.FileInfo, Status)
// These should update the file's ctime too.
Chmod(name string, mode uint32) (code Status)
Chown(name string, uid uint32, gid uint32) (code Status)
Utimens(name string, AtimeNs uint64, MtimeNs uint64) (code Status)
Chmod(name string, mode uint32, context *Context) (code Status)
Chown(name string, uid uint32, gid uint32, context *Context) (code Status)
Utimens(name string, AtimeNs uint64, MtimeNs uint64, context *Context) (code Status)
Truncate(name string, offset uint64) (code Status)
Truncate(name string, offset uint64, context *Context) (code Status)
Access(name string, mode uint32) (code Status)
Access(name string, mode uint32, context *Context) (code Status)
// Tree structure
Link(oldName string, newName string) (code Status)
Mkdir(name string, mode uint32) Status
Mknod(name string, mode uint32, dev uint32) Status
Rename(oldName string, newName string) (code Status)
Rmdir(name string) (code Status)
Unlink(name string) (code Status)
Link(oldName string, newName string, context *Context) (code Status)
Mkdir(name string, mode uint32, context *Context) Status
Mknod(name string, mode uint32, dev uint32, context *Context) Status
Rename(oldName string, newName string, context *Context) (code Status)
Rmdir(name string, context *Context) (code Status)
Unlink(name string, context *Context) (code Status)
// Extended attributes.
GetXAttr(name string, attribute string) (data []byte, code Status)
ListXAttr(name string) (attributes []string, code Status)
RemoveXAttr(name string, attr string) Status
SetXAttr(name string, attr string, data []byte, flags int) Status
GetXAttr(name string, attribute string, context *Context) (data []byte, code Status)
ListXAttr(name string, context *Context) (attributes []string, code Status)
RemoveXAttr(name string, attr string, context *Context) Status
SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status
// Called after mount.
Mount(connector *FileSystemConnector)
......@@ -51,18 +51,18 @@ type FileSystem interface {
// File handling. If opening for writing, the file's mtime
// should be updated too.
Open(name string, flags uint32) (file File, code Status)
Create(name string, flags uint32, mode uint32) (file File, code Status)
Open(name string, flags uint32, context *Context) (file File, code Status)
Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status)
// Flush() gets called as a file opened for read/write.
Flush(name string) Status
// Directory handling
OpenDir(name string) (stream chan DirEntry, code Status)
OpenDir(name string, context *Context) (stream chan DirEntry, code Status)
// Symlinks.
Symlink(value string, linkName string) (code Status)
Readlink(name string) (string, Status)
Symlink(value string, linkName string, context *Context) (code Status)
Readlink(name string, context *Context) (string, Status)
StatFs() *StatfsOut
}
......@@ -72,6 +72,7 @@ type FileSystem interface {
// a default null implementation.
//
// TODO - should File be thread safe?
// TODO - should we pass a *Context argument?
type File interface {
Read(*ReadIn, BufferPool) ([]byte, Status)
Write(*WriteIn, []byte) (written uint32, code Status)
......
......@@ -11,8 +11,8 @@ type cacheFs struct {
*LoopbackFileSystem
}
func (me *cacheFs) Open(name string, flags uint32) (fuseFile File, status Status) {
f, c := me.LoopbackFileSystem.Open(name, flags)
func (me *cacheFs) Open(name string, flags uint32, context *Context) (fuseFile File, status Status) {
f, c := me.LoopbackFileSystem.Open(name, flags, context)
if !c.Ok() {
return f, c
}
......@@ -88,14 +88,14 @@ type nonseekFs struct {
Length int
}
func (me *nonseekFs) GetAttr(name string) (fi *os.FileInfo, status Status) {
func (me *nonseekFs) GetAttr(name string, context *Context) (fi *os.FileInfo, status Status) {
if name == "file" {
return &os.FileInfo{ Mode: S_IFREG | 0644 }, OK
}
return nil, ENOENT
}
func (me *nonseekFs) Open(name string, flags uint32) (fuseFile File, status Status) {
func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile File, status Status) {
if name != "file" {
return nil, ENOENT
}
......
......@@ -4,15 +4,15 @@ import (
"os"
)
func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string) Status {
src, code := srcFs.Open(srcFile, uint32(os.O_RDONLY))
func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Context) Status {
src, code := srcFs.Open(srcFile, uint32(os.O_RDONLY), context)
if !code.Ok() {
return code
}
defer src.Release()
defer src.Flush()
attr, code := srcFs.GetAttr(srcFile)
attr, code := srcFs.GetAttr(srcFile, context)
if !code.Ok() {
return code
}
......@@ -20,7 +20,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string) Status {
w := WriteIn{
Flags: uint32(os.O_WRONLY | os.O_CREATE | os.O_TRUNC),
}
dst, code := destFs.Create(destFile, w.Flags, attr.Mode)
dst, code := destFs.Create(destFile, w.Flags, attr.Mode, context)
if !code.Ok() {
return code
}
......
......@@ -17,7 +17,7 @@ func TestCopyFile(t *testing.T) {
err := ioutil.WriteFile(d1+"/file", []byte(content1), 0644)
CheckSuccess(err)
code := CopyFile(fs1, fs2, "file", "file")
code := CopyFile(fs1, fs2, "file", "file", nil)
if !code.Ok() {
t.Fatal("Unexpected ret code", code)
}
......@@ -33,7 +33,7 @@ func TestCopyFile(t *testing.T) {
CheckSuccess(err)
// Copy back: should overwrite.
code = CopyFile(fs2, fs1, "file", "file")
code = CopyFile(fs2, fs1, "file", "file", nil)
if !code.Ok() {
t.Fatal("Unexpected ret code", code)
}
......
......@@ -187,71 +187,71 @@ func (me *DefaultFile) Ioctl(input *IoctlIn) (output *IoctlOut, data []byte, cod
////////////////////////////////////////////////////////////////
// DefaultFileSystem
func (me *DefaultFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
func (me *DefaultFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
return nil, ENOSYS
}
func (me *DefaultFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *DefaultFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
return nil, ENOSYS
}
func (me *DefaultFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
func (me *DefaultFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
return ENOSYS
}
func (me *DefaultFileSystem) ListXAttr(name string) ([]string, Status) {
func (me *DefaultFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
return nil, ENOSYS
}
func (me *DefaultFileSystem) RemoveXAttr(name string, attr string) Status {
func (me *DefaultFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
return ENOSYS
}
func (me *DefaultFileSystem) Readlink(name string) (string, Status) {
func (me *DefaultFileSystem) Readlink(name string, context *Context) (string, Status) {
return "", ENOSYS
}
func (me *DefaultFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
func (me *DefaultFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) Status {
return ENOSYS
}
func (me *DefaultFileSystem) Mkdir(name string, mode uint32) Status {
func (me *DefaultFileSystem) Mkdir(name string, mode uint32, context *Context) Status {
return ENOSYS
}
func (me *DefaultFileSystem) Unlink(name string) (code Status) {
func (me *DefaultFileSystem) Unlink(name string, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Rmdir(name string) (code Status) {
func (me *DefaultFileSystem) Rmdir(name string, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Symlink(value string, linkName string) (code Status) {
func (me *DefaultFileSystem) Symlink(value string, linkName string, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Rename(oldName string, newName string) (code Status) {
func (me *DefaultFileSystem) Rename(oldName string, newName string, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Link(oldName string, newName string) (code Status) {
func (me *DefaultFileSystem) Link(oldName string, newName string, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Chmod(name string, mode uint32) (code Status) {
func (me *DefaultFileSystem) Chmod(name string, mode uint32, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
func (me *DefaultFileSystem) Chown(name string, uid uint32, gid uint32, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Truncate(name string, offset uint64) (code Status) {
func (me *DefaultFileSystem) Truncate(name string, offset uint64, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Open(name string, flags uint32) (file File, code Status) {
func (me *DefaultFileSystem) Open(name string, flags uint32, context *Context) (file File, code Status) {
return nil, ENOSYS
}
......@@ -259,7 +259,7 @@ func (me *DefaultFileSystem) Flush(name string) Status {
return OK
}
func (me *DefaultFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *DefaultFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
return nil, ENOSYS
}
......@@ -269,15 +269,15 @@ func (me *DefaultFileSystem) Mount(conn *FileSystemConnector) {
func (me *DefaultFileSystem) Unmount() {
}
func (me *DefaultFileSystem) Access(name string, mode uint32) (code Status) {
func (me *DefaultFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
return ENOSYS
}
func (me *DefaultFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
func (me *DefaultFileSystem) Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status) {
return nil, ENOSYS
}
func (me *DefaultFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
func (me *DefaultFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64, context *Context) (code Status) {
return ENOSYS
}
......
......@@ -83,11 +83,11 @@ type FSetAttrFs struct {
file *MutableDataFile
}
func (me *FSetAttrFs) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *FSetAttrFs) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
return nil, ENODATA
}
func (me *FSetAttrFs) GetAttr(name string) (*os.FileInfo, Status) {
func (me *FSetAttrFs) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
if name == "" {
return &os.FileInfo{Mode: S_IFDIR | 0700}, OK
}
......@@ -99,14 +99,14 @@ func (me *FSetAttrFs) GetAttr(name string) (*os.FileInfo, Status) {
return nil, ENOENT
}
func (me *FSetAttrFs) Open(name string, flags uint32) (File, Status) {
func (me *FSetAttrFs) Open(name string, flags uint32, context *Context) (File, Status) {
if name == "file" {
return me.file, OK
}
return nil, ENOENT
}
func (me *FSetAttrFs) Create(name string, flags uint32, mode uint32) (File, Status) {
func (me *FSetAttrFs) Create(name string, flags uint32, mode uint32, context *Context) (File, Status) {
if name == "file" {
f := NewFile()
me.file = f
......
......@@ -26,73 +26,73 @@ func (me *LockingFileSystem) locked() func() {
return func() { me.lock.Unlock() }
}
func (me *LockingFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
func (me *LockingFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
defer me.locked()()
return me.FileSystem.GetAttr(name)
return me.FileSystem.GetAttr(name, context)
}
func (me *LockingFileSystem) Readlink(name string) (string, Status) {
func (me *LockingFileSystem) Readlink(name string, context *Context) (string, Status) {
defer me.locked()()
return me.FileSystem.Readlink(name)
return me.FileSystem.Readlink(name, context)
}
func (me *LockingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
func (me *LockingFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) Status {
defer me.locked()()
return me.FileSystem.Mknod(name, mode, dev)
return me.FileSystem.Mknod(name, mode, dev, context)
}
func (me *LockingFileSystem) Mkdir(name string, mode uint32) Status {
func (me *LockingFileSystem) Mkdir(name string, mode uint32, context *Context) Status {
defer me.locked()()
return me.FileSystem.Mkdir(name, mode)
return me.FileSystem.Mkdir(name, mode, context)
}
func (me *LockingFileSystem) Unlink(name string) (code Status) {
func (me *LockingFileSystem) Unlink(name string, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Unlink(name)
return me.FileSystem.Unlink(name, context)
}
func (me *LockingFileSystem) Rmdir(name string) (code Status) {
func (me *LockingFileSystem) Rmdir(name string, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Rmdir(name)
return me.FileSystem.Rmdir(name, context)
}
func (me *LockingFileSystem) Symlink(value string, linkName string) (code Status) {
func (me *LockingFileSystem) Symlink(value string, linkName string, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Symlink(value, linkName)
return me.FileSystem.Symlink(value, linkName, context)
}
func (me *LockingFileSystem) Rename(oldName string, newName string) (code Status) {
func (me *LockingFileSystem) Rename(oldName string, newName string, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Rename(oldName, newName)
return me.FileSystem.Rename(oldName, newName, context)
}
func (me *LockingFileSystem) Link(oldName string, newName string) (code Status) {
func (me *LockingFileSystem) Link(oldName string, newName string, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Link(oldName, newName)
return me.FileSystem.Link(oldName, newName, context)
}
func (me *LockingFileSystem) Chmod(name string, mode uint32) (code Status) {
func (me *LockingFileSystem) Chmod(name string, mode uint32, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Chmod(name, mode)
return me.FileSystem.Chmod(name, mode, context)
}
func (me *LockingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
func (me *LockingFileSystem) Chown(name string, uid uint32, gid uint32, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Chown(name, uid, gid)
return me.FileSystem.Chown(name, uid, gid, context)
}
func (me *LockingFileSystem) Truncate(name string, offset uint64) (code Status) {
func (me *LockingFileSystem) Truncate(name string, offset uint64, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Truncate(name, offset)
return me.FileSystem.Truncate(name, offset, context)
}
func (me *LockingFileSystem) Open(name string, flags uint32) (file File, code Status) {
return me.FileSystem.Open(name, flags)
func (me *LockingFileSystem) Open(name string, flags uint32, context *Context) (file File, code Status) {
return me.FileSystem.Open(name, flags, context)
}
func (me *LockingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *LockingFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
defer me.locked()()
return me.FileSystem.OpenDir(name)
return me.FileSystem.OpenDir(name, context)
}
func (me *LockingFileSystem) Mount(conn *FileSystemConnector) {
......@@ -105,39 +105,39 @@ func (me *LockingFileSystem) Unmount() {
me.FileSystem.Unmount()
}
func (me *LockingFileSystem) Access(name string, mode uint32) (code Status) {
func (me *LockingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Access(name, mode)
return me.FileSystem.Access(name, mode, context)
}
func (me *LockingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
func (me *LockingFileSystem) Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status) {
defer me.locked()()
return me.FileSystem.Create(name, flags, mode)
return me.FileSystem.Create(name, flags, mode, context)
}
func (me *LockingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
func (me *LockingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64, context *Context) (code Status) {
defer me.locked()()
return me.FileSystem.Utimens(name, AtimeNs, CtimeNs)
return me.FileSystem.Utimens(name, AtimeNs, CtimeNs, context)
}
func (me *LockingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *LockingFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
defer me.locked()()
return me.FileSystem.GetXAttr(name, attr)
return me.FileSystem.GetXAttr(name, attr, context)
}
func (me *LockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
func (me *LockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
defer me.locked()()
return me.FileSystem.SetXAttr(name, attr, data, flags)
return me.FileSystem.SetXAttr(name, attr, data, flags, context)
}
func (me *LockingFileSystem) ListXAttr(name string) ([]string, Status) {
func (me *LockingFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
defer me.locked()()
return me.FileSystem.ListXAttr(name)
return me.FileSystem.ListXAttr(name, context)
}
func (me *LockingFileSystem) RemoveXAttr(name string, attr string) Status {
func (me *LockingFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
defer me.locked()()
return me.FileSystem.RemoveXAttr(name, attr)
return me.FileSystem.RemoveXAttr(name, attr, context)
}
////////////////////////////////////////////////////////////////
......
......@@ -24,94 +24,94 @@ func (me *LoggingFileSystem) Print(name string, arg string) {
log.Printf("Op %s arg %s", name, arg)
}
func (me *LoggingFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
func (me *LoggingFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
me.Print("GetAttr", name)
return me.FileSystem.GetAttr(name)
return me.FileSystem.GetAttr(name, context)
}
func (me *LoggingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *LoggingFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
me.Print("GetXAttr", name)
return me.FileSystem.GetXAttr(name, attr)
return me.FileSystem.GetXAttr(name, attr, context)
}
func (me *LoggingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
func (me *LoggingFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
me.Print("SetXAttr", name)
return me.FileSystem.SetXAttr(name, attr, data, flags)
return me.FileSystem.SetXAttr(name, attr, data, flags, context)
}
func (me *LoggingFileSystem) ListXAttr(name string) ([]string, Status) {
func (me *LoggingFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
me.Print("ListXAttr", name)
return me.FileSystem.ListXAttr(name)
return me.FileSystem.ListXAttr(name, context)
}
func (me *LoggingFileSystem) RemoveXAttr(name string, attr string) Status {
func (me *LoggingFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
me.Print("RemoveXAttr", name)
return me.FileSystem.RemoveXAttr(name, attr)
return me.FileSystem.RemoveXAttr(name, attr, context)
}
func (me *LoggingFileSystem) Readlink(name string) (string, Status) {
func (me *LoggingFileSystem) Readlink(name string, context *Context) (string, Status) {
me.Print("Readlink", name)
return me.FileSystem.Readlink(name)
return me.FileSystem.Readlink(name, context)
}
func (me *LoggingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
func (me *LoggingFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) Status {
me.Print("Mknod", name)
return me.FileSystem.Mknod(name, mode, dev)
return me.FileSystem.Mknod(name, mode, dev, context)
}
func (me *LoggingFileSystem) Mkdir(name string, mode uint32) Status {
func (me *LoggingFileSystem) Mkdir(name string, mode uint32, context *Context) Status {
me.Print("Mkdir", name)
return me.FileSystem.Mkdir(name, mode)
return me.FileSystem.Mkdir(name, mode, context)
}
func (me *LoggingFileSystem) Unlink(name string) (code Status) {
func (me *LoggingFileSystem) Unlink(name string, context *Context) (code Status) {
me.Print("Unlink", name)
return me.FileSystem.Unlink(name)
return me.FileSystem.Unlink(name, context)
}
func (me *LoggingFileSystem) Rmdir(name string) (code Status) {
func (me *LoggingFileSystem) Rmdir(name string, context *Context) (code Status) {
me.Print("Rmdir", name)
return me.FileSystem.Rmdir(name)
return me.FileSystem.Rmdir(name, context)
}
func (me *LoggingFileSystem) Symlink(value string, linkName string) (code Status) {
func (me *LoggingFileSystem) Symlink(value string, linkName string, context *Context) (code Status) {
me.Print("Symlink", linkName)
return me.FileSystem.Symlink(value, linkName)
return me.FileSystem.Symlink(value, linkName, context)
}
func (me *LoggingFileSystem) Rename(oldName string, newName string) (code Status) {
func (me *LoggingFileSystem) Rename(oldName string, newName string, context *Context) (code Status) {
me.Print("Rename", oldName)
return me.FileSystem.Rename(oldName, newName)
return me.FileSystem.Rename(oldName, newName, context)
}
func (me *LoggingFileSystem) Link(oldName string, newName string) (code Status) {
func (me *LoggingFileSystem) Link(oldName string, newName string, context *Context) (code Status) {
me.Print("Link", newName)
return me.FileSystem.Link(oldName, newName)
return me.FileSystem.Link(oldName, newName, context)
}
func (me *LoggingFileSystem) Chmod(name string, mode uint32) (code Status) {
func (me *LoggingFileSystem) Chmod(name string, mode uint32, context *Context) (code Status) {
me.Print("Chmod", name)
return me.FileSystem.Chmod(name, mode)
return me.FileSystem.Chmod(name, mode, context)
}
func (me *LoggingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
func (me *LoggingFileSystem) Chown(name string, uid uint32, gid uint32, context *Context) (code Status) {
me.Print("Chown", name)
return me.FileSystem.Chown(name, uid, gid)
return me.FileSystem.Chown(name, uid, gid, context)
}
func (me *LoggingFileSystem) Truncate(name string, offset uint64) (code Status) {
func (me *LoggingFileSystem) Truncate(name string, offset uint64, context *Context) (code Status) {
me.Print("Truncate", name)
return me.FileSystem.Truncate(name, offset)
return me.FileSystem.Truncate(name, offset, context)
}
func (me *LoggingFileSystem) Open(name string, flags uint32) (file File, code Status) {
func (me *LoggingFileSystem) Open(name string, flags uint32, context *Context) (file File, code Status) {
me.Print("Open", name)
return me.FileSystem.Open(name, flags)
return me.FileSystem.Open(name, flags, context)
}
func (me *LoggingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *LoggingFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
me.Print("OpenDir", name)
return me.FileSystem.OpenDir(name)
return me.FileSystem.OpenDir(name, context)
}
func (me *LoggingFileSystem) Mount(conn *FileSystemConnector) {
......@@ -124,17 +124,17 @@ func (me *LoggingFileSystem) Unmount() {
me.FileSystem.Unmount()
}
func (me *LoggingFileSystem) Access(name string, mode uint32) (code Status) {
func (me *LoggingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
me.Print("Access", name)
return me.FileSystem.Access(name, mode)
return me.FileSystem.Access(name, mode, context)
}
func (me *LoggingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
func (me *LoggingFileSystem) Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status) {
me.Print("Create", name)
return me.FileSystem.Create(name, flags, mode)
return me.FileSystem.Create(name, flags, mode, context)
}
func (me *LoggingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
func (me *LoggingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64, context *Context) (code Status) {
me.Print("Utimens", name)
return me.FileSystem.Utimens(name, AtimeNs, CtimeNs)
return me.FileSystem.Utimens(name, AtimeNs, CtimeNs, context)
}
......@@ -32,7 +32,7 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string {
return filepath.Join(me.Root, relPath)
}
func (me *LoopbackFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
func (me *LoopbackFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
fullPath := me.GetPath(name)
fi, err := os.Lstat(fullPath)
if err != nil {
......@@ -41,7 +41,7 @@ func (me *LoopbackFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
return fi, OK
}
func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *LoopbackFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
// What other ways beyond O_RDONLY are there to open
// directories?
f, err := os.Open(me.GetPath(name))
......@@ -74,7 +74,7 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status
return output, OK
}
func (me *LoopbackFileSystem) Open(name string, flags uint32) (fuseFile File, status Status) {
func (me *LoopbackFileSystem) Open(name string, flags uint32, context *Context) (fuseFile File, status Status) {
f, err := os.OpenFile(me.GetPath(name), int(flags), 0)
if err != nil {
return nil, OsErrorToErrno(err)
......@@ -82,80 +82,80 @@ func (me *LoopbackFileSystem) Open(name string, flags uint32) (fuseFile File, st
return &LoopbackFile{File: f}, OK
}
func (me *LoopbackFileSystem) Chmod(path string, mode uint32) (code Status) {
func (me *LoopbackFileSystem) Chmod(path string, mode uint32, context *Context) (code Status) {
err := os.Chmod(me.GetPath(path), mode)
return OsErrorToErrno(err)
}
func (me *LoopbackFileSystem) Chown(path string, uid uint32, gid uint32) (code Status) {
func (me *LoopbackFileSystem) Chown(path string, uid uint32, gid uint32, context *Context) (code Status) {
return OsErrorToErrno(os.Chown(me.GetPath(path), int(uid), int(gid)))
}
func (me *LoopbackFileSystem) Truncate(path string, offset uint64) (code Status) {
func (me *LoopbackFileSystem) Truncate(path string, offset uint64, context *Context) (code Status) {
return OsErrorToErrno(os.Truncate(me.GetPath(path), int64(offset)))
}
func (me *LoopbackFileSystem) Utimens(path string, AtimeNs uint64, MtimeNs uint64) (code Status) {
func (me *LoopbackFileSystem) Utimens(path string, AtimeNs uint64, MtimeNs uint64, context *Context) (code Status) {
return OsErrorToErrno(os.Chtimes(me.GetPath(path), int64(AtimeNs), int64(MtimeNs)))
}
func (me *LoopbackFileSystem) Readlink(name string) (out string, code Status) {
func (me *LoopbackFileSystem) Readlink(name string, context *Context) (out string, code Status) {
f, err := os.Readlink(me.GetPath(name))
return f, OsErrorToErrno(err)
}
func (me *LoopbackFileSystem) Mknod(name string, mode uint32, dev uint32) (code Status) {
func (me *LoopbackFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) (code Status) {
return Status(syscall.Mknod(me.GetPath(name), mode, int(dev)))
}
func (me *LoopbackFileSystem) Mkdir(path string, mode uint32) (code Status) {
func (me *LoopbackFileSystem) Mkdir(path string, mode uint32, context *Context) (code Status) {
return OsErrorToErrno(os.Mkdir(me.GetPath(path), mode))
}
// Don't use os.Remove, it removes twice (unlink followed by rmdir).
func (me *LoopbackFileSystem) Unlink(name string) (code Status) {
func (me *LoopbackFileSystem) Unlink(name string, context *Context) (code Status) {
return Status(syscall.Unlink(me.GetPath(name)))
}
func (me *LoopbackFileSystem) Rmdir(name string) (code Status) {
func (me *LoopbackFileSystem) Rmdir(name string, context *Context) (code Status) {
return Status(syscall.Rmdir(me.GetPath(name)))
}
func (me *LoopbackFileSystem) Symlink(pointedTo string, linkName string) (code Status) {
func (me *LoopbackFileSystem) Symlink(pointedTo string, linkName string, context *Context) (code Status) {
return OsErrorToErrno(os.Symlink(pointedTo, me.GetPath(linkName)))
}
func (me *LoopbackFileSystem) Rename(oldPath string, newPath string) (code Status) {
func (me *LoopbackFileSystem) Rename(oldPath string, newPath string, context *Context) (code Status) {
err := os.Rename(me.GetPath(oldPath), me.GetPath(newPath))
return OsErrorToErrno(err)
}
func (me *LoopbackFileSystem) Link(orig string, newName string) (code Status) {
func (me *LoopbackFileSystem) Link(orig string, newName string, context *Context) (code Status) {
return OsErrorToErrno(os.Link(me.GetPath(orig), me.GetPath(newName)))
}
func (me *LoopbackFileSystem) Access(name string, mode uint32) (code Status) {
func (me *LoopbackFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
return Status(syscall.Access(me.GetPath(name), mode))
}
func (me *LoopbackFileSystem) Create(path string, flags uint32, mode uint32) (fuseFile File, code Status) {
func (me *LoopbackFileSystem) Create(path string, flags uint32, mode uint32, context *Context) (fuseFile File, code Status) {
f, err := os.OpenFile(me.GetPath(path), int(flags)|os.O_CREATE, mode)
return &LoopbackFile{File: f}, OsErrorToErrno(err)
}
func (me *LoopbackFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *LoopbackFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
data, errNo := GetXAttr(me.GetPath(name), attr)
return data, Status(errNo)
}
func (me *LoopbackFileSystem) ListXAttr(name string) ([]string, Status) {
func (me *LoopbackFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
data, errNo := ListXAttr(me.GetPath(name))
return data, Status(errNo)
}
func (me *LoopbackFileSystem) RemoveXAttr(name string, attr string) Status {
func (me *LoopbackFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
return Status(Removexattr(me.GetPath(name), attr))
}
......
......@@ -14,7 +14,7 @@ type NotifyFs struct {
exist bool
}
func (me *NotifyFs) GetAttr(name string) (*os.FileInfo, Status) {
func (me *NotifyFs) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
if name == "" {
return &os.FileInfo{Mode: S_IFDIR | 0755}, OK
}
......@@ -27,7 +27,7 @@ func (me *NotifyFs) GetAttr(name string) (*os.FileInfo, Status) {
return nil, ENOENT
}
func (me *NotifyFs) Open(name string, f uint32) (File, Status) {
func (me *NotifyFs) Open(name string, f uint32, context *Context) (File, Status) {
return NewReadOnlyFile([]byte{42}), OK
}
......
......@@ -11,7 +11,7 @@ type ownerFs struct {
const _RANDOM_OWNER = 31415265
func (me *ownerFs) GetAttr(name string) (*os.FileInfo, Status) {
func (me *ownerFs) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
if name == "" {
return &os.FileInfo{
Mode: S_IFDIR | 0755,
......
......@@ -42,12 +42,12 @@ func (me *FileSystemDebug) Add(name string, callback getter) {
me.callbacks[name] = callback
}
func (me *FileSystemDebug) Open(path string, flags uint32) (fuseFile File, status Status) {
func (me *FileSystemDebug) Open(path string, flags uint32, context *Context) (fuseFile File, status Status) {
content := me.getContent(path)
if content != nil {
return NewReadOnlyFile(content), OK
}
return me.FileSystem.Open(path, flags)
return me.FileSystem.Open(path, flags, context)
}
var SeparatorString = string([]byte{filepath.Separator})
......@@ -65,16 +65,16 @@ func (me *FileSystemDebug) getContent(path string) []byte {
return nil
}
func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *FileSystemDebug) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
if strings.HasPrefix(name, DebugDir) {
return nil, ENODATA
}
return me.FileSystem.GetXAttr(name, attr)
return me.FileSystem.GetXAttr(name, attr, context)
}
func (me *FileSystemDebug) GetAttr(path string) (*os.FileInfo, Status) {
func (me *FileSystemDebug) GetAttr(path string, context *Context) (*os.FileInfo, Status) {
if !strings.HasPrefix(path, DebugDir) {
return me.FileSystem.GetAttr(path)
return me.FileSystem.GetAttr(path, context)
}
if path == DebugDir {
return &os.FileInfo{
......@@ -122,7 +122,7 @@ func IntMapToBytes(m map[string]int) []byte {
return []byte(strings.Join(r, "\n"))
}
func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *FileSystemDebug) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
if name == DebugDir {
me.RWMutex.RLock()
defer me.RWMutex.RUnlock()
......@@ -137,7 +137,7 @@ func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status St
close(stream)
return stream, OK
}
return me.FileSystem.OpenDir(name)
return me.FileSystem.OpenDir(name, context)
}
func (me *FileSystemDebug) AddMountState(state *MountState) {
......
......@@ -40,15 +40,15 @@ func (me *FileSystemConnector) Lookup(header *InHeader, name string) (out *Entry
if me.Debug {
log.Printf("Node %v = '%s'", parent.NodeId, parent.GetFullPath())
}
return me.internalLookup(parent, name, 1)
return me.internalLookup(parent, name, 1, &header.Context)
}
func (me *FileSystemConnector) internalLookup(parent *inode, name string, lookupCount int) (out *EntryOut, status Status) {
out, status, _ = me.internalLookupWithNode(parent, name, lookupCount)
func (me *FileSystemConnector) internalLookup(parent *inode, name string, lookupCount int, context *Context) (out *EntryOut, status Status) {
out, status, _ = me.internalLookupWithNode(parent, name, lookupCount, context)
return out, status
}
func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string, lookupCount int) (out *EntryOut, status Status, node *inode) {
func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string, lookupCount int, context *Context) (out *EntryOut, status Status, node *inode) {
fullPath, mount, isMountPoint := me.lookupMount(parent, name, lookupCount)
if isMountPoint {
node = mount.mountInode
......@@ -67,7 +67,7 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
return nil, ENOENT, nil
}
}
fi, err := mount.fs.GetAttr(fullPath)
fi, err := mount.fs.GetAttr(fullPath, context)
if err == ENOENT && mount.options.NegativeTimeout > 0.0 {
return NegativeEntry(mount.options.NegativeTimeout), OK, nil
}
......@@ -131,7 +131,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
return nil, ENOENT
}
fi, err := mount.fs.GetAttr(fullPath)
fi, err := mount.fs.GetAttr(fullPath, &header.Context)
if err != OK {
return nil, err
}
......@@ -154,7 +154,7 @@ func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags u
return 0, 0, ENOENT
}
// TODO - how to handle return flags, the FUSE open flags?
stream, err := mount.fs.OpenDir(fullPath)
stream, err := mount.fs.OpenDir(fullPath, &header.Context)
if err != OK {
return 0, 0, err
}
......@@ -183,7 +183,7 @@ func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint
return 0, 0, ENOENT
}
f, err := mount.fs.Open(fullPath, input.Flags)
f, err := mount.fs.Open(fullPath, input.Flags, &header.Context)
if err != OK {
return 0, 0, err
}
......@@ -215,7 +215,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult = f.Chmod(permissions)
}
if fileResult == ENOSYS {
err = mount.fs.Chmod(fullPath, permissions)
err = mount.fs.Chmod(fullPath, permissions, &header.Context)
} else {
err = fileResult
fileResult = ENOSYS
......@@ -228,7 +228,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
if fileResult == ENOSYS {
// TODO - can we get just FATTR_GID but not FATTR_UID ?
err = mount.fs.Chown(fullPath, uint32(input.Uid), uint32(input.Gid))
err = mount.fs.Chown(fullPath, uint32(input.Uid), uint32(input.Gid), &header.Context)
} else {
err = fileResult
fileResult = ENOSYS
......@@ -239,7 +239,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult = f.Truncate(input.Size)
}
if fileResult == ENOSYS {
err = mount.fs.Truncate(fullPath, input.Size)
err = mount.fs.Truncate(fullPath, input.Size, &header.Context)
} else {
err = fileResult
fileResult = ENOSYS
......@@ -260,7 +260,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
fileResult = f.Utimens(atime, mtime)
}
if fileResult == ENOSYS {
err = mount.fs.Utimens(fullPath, atime, mtime)
err = mount.fs.Utimens(fullPath, atime, mtime, &header.Context)
} else {
err = fileResult
fileResult = ENOSYS
......@@ -278,7 +278,7 @@ func (me *FileSystemConnector) Readlink(header *InHeader) (out []byte, code Stat
if mount == nil {
return nil, ENOENT
}
val, err := mount.fs.Readlink(fullPath)
val, err := mount.fs.Readlink(fullPath, &header.Context)
return bytes.NewBufferString(val).Bytes(), err
}
......@@ -288,11 +288,11 @@ func (me *FileSystemConnector) Mknod(header *InHeader, input *MknodIn, name stri
return nil, ENOENT
}
fullPath = filepath.Join(fullPath, name)
err := mount.fs.Mknod(fullPath, input.Mode, uint32(input.Rdev))
err := mount.fs.Mknod(fullPath, input.Mode, uint32(input.Rdev), &header.Context)
if err != OK {
return nil, err
}
return me.internalLookup(node, name, 1)
return me.internalLookup(node, name, 1, &header.Context)
}
func (me *FileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
......@@ -300,9 +300,9 @@ func (me *FileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name stri
if mount == nil {
return nil, ENOENT
}
code = mount.fs.Mkdir(filepath.Join(fullPath, name), input.Mode)
code = mount.fs.Mkdir(filepath.Join(fullPath, name), input.Mode, &header.Context)
if code.Ok() {
out, code = me.internalLookup(parent, name, 1)
out, code = me.internalLookup(parent, name, 1, &header.Context)
}
return out, code
}
......@@ -312,7 +312,7 @@ func (me *FileSystemConnector) Unlink(header *InHeader, name string) (code Statu
if mount == nil {
return ENOENT
}
code = mount.fs.Unlink(filepath.Join(fullPath, name))
code = mount.fs.Unlink(filepath.Join(fullPath, name), &header.Context)
if code.Ok() {
// Like fuse.c, we update our internal tables.
me.unlinkUpdate(parent, name)
......@@ -325,7 +325,7 @@ func (me *FileSystemConnector) Rmdir(header *InHeader, name string) (code Status
if mount == nil {
return ENOENT
}
code = mount.fs.Rmdir(filepath.Join(fullPath, name))
code = mount.fs.Rmdir(filepath.Join(fullPath, name), &header.Context)
if code.Ok() {
me.unlinkUpdate(parent, name)
}
......@@ -337,12 +337,12 @@ func (me *FileSystemConnector) Symlink(header *InHeader, pointedTo string, linkN
if mount == nil {
return nil, ENOENT
}
err := mount.fs.Symlink(pointedTo, filepath.Join(fullPath, linkName))
err := mount.fs.Symlink(pointedTo, filepath.Join(fullPath, linkName), &header.Context)
if err != OK {
return nil, err
}
out, code = me.internalLookup(parent, linkName, 1)
out, code = me.internalLookup(parent, linkName, 1, &header.Context)
return out, code
}
......@@ -362,7 +362,7 @@ func (me *FileSystemConnector) Rename(header *InHeader, input *RenameIn, oldName
oldPath = filepath.Join(oldPath, oldName)
newPath = filepath.Join(newPath, newName)
code = mount.fs.Rename(oldPath, newPath)
code = mount.fs.Rename(oldPath, newPath, &header.Context)
if code.Ok() {
me.renameUpdate(oldParent, oldName, newParent, newName)
}
......@@ -380,13 +380,13 @@ func (me *FileSystemConnector) Link(header *InHeader, input *LinkIn, filename st
return nil, EXDEV
}
newName = filepath.Join(newName, filename)
err := mount.fs.Link(orig, newName)
err := mount.fs.Link(orig, newName, &header.Context)
if err != OK {
return nil, err
}
return me.internalLookup(newParent, filename, 1)
return me.internalLookup(newParent, filename, 1, &header.Context)
}
func (me *FileSystemConnector) Access(header *InHeader, input *AccessIn) (code Status) {
......@@ -394,7 +394,7 @@ func (me *FileSystemConnector) Access(header *InHeader, input *AccessIn) (code S
if mount == nil {
return ENOENT
}
return mount.fs.Access(p, input.Mask)
return mount.fs.Access(p, input.Mask, &header.Context)
}
func (me *FileSystemConnector) Create(header *InHeader, input *CreateIn, name string) (flags uint32, h uint64, out *EntryOut, code Status) {
......@@ -404,12 +404,12 @@ func (me *FileSystemConnector) Create(header *InHeader, input *CreateIn, name st
}
fullPath := filepath.Join(directory, name)
f, err := mount.fs.Create(fullPath, uint32(input.Flags), input.Mode)
f, err := mount.fs.Create(fullPath, uint32(input.Flags), input.Mode, &header.Context)
if err != OK {
return 0, 0, nil, err
}
out, code, inode := me.internalLookupWithNode(parent, name, 1)
out, code, inode := me.internalLookupWithNode(parent, name, 1, &header.Context)
if inode == nil {
msg := fmt.Sprintf("Create succeded, but GetAttr returned no entry %v", fullPath)
panic(msg)
......@@ -460,7 +460,7 @@ func (me *FileSystemConnector) GetXAttr(header *InHeader, attribute string) (dat
return nil, ENOENT
}
data, code = mount.fs.GetXAttr(path, attribute)
data, code = mount.fs.GetXAttr(path, attribute, &header.Context)
return data, code
}
......@@ -470,7 +470,7 @@ func (me *FileSystemConnector) RemoveXAttr(header *InHeader, attr string) Status
return ENOENT
}
return mount.fs.RemoveXAttr(path, attr)
return mount.fs.RemoveXAttr(path, attr, &header.Context)
}
func (me *FileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status {
......@@ -479,7 +479,7 @@ func (me *FileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn, att
return ENOENT
}
return mount.fs.SetXAttr(path, attr, data, int(input.Flags))
return mount.fs.SetXAttr(path, attr, data, int(input.Flags), &header.Context)
}
func (me *FileSystemConnector) ListXAttr(header *InHeader) (data []byte, code Status) {
......@@ -488,7 +488,7 @@ func (me *FileSystemConnector) ListXAttr(header *InHeader) (data []byte, code St
return nil, ENOENT
}
attrs, code := mount.fs.ListXAttr(path)
attrs, code := mount.fs.ListXAttr(path, &header.Context)
if code != OK {
return nil, code
}
......
......@@ -76,63 +76,63 @@ func (me *SwitchFileSystem) findFileSystem(path string) (string, *SwitchedFileSy
return "", nil
}
func (me *SwitchFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
func (me *SwitchFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return nil, ENOENT
}
return fs.FileSystem.GetAttr(name)
return fs.FileSystem.GetAttr(name, context)
}
func (me *SwitchFileSystem) Readlink(name string) (string, Status) {
func (me *SwitchFileSystem) Readlink(name string, context *Context) (string, Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return "", ENOENT
}
return fs.FileSystem.Readlink(name)
return fs.FileSystem.Readlink(name, context)
}
func (me *SwitchFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
func (me *SwitchFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) Status {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Mknod(name, mode, dev)
return fs.FileSystem.Mknod(name, mode, dev, context)
}
func (me *SwitchFileSystem) Mkdir(name string, mode uint32) Status {
func (me *SwitchFileSystem) Mkdir(name string, mode uint32, context *Context) Status {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Mkdir(name, mode)
return fs.FileSystem.Mkdir(name, mode, context)
}
func (me *SwitchFileSystem) Unlink(name string) (code Status) {
func (me *SwitchFileSystem) Unlink(name string, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Unlink(name)
return fs.FileSystem.Unlink(name, context)
}
func (me *SwitchFileSystem) Rmdir(name string) (code Status) {
func (me *SwitchFileSystem) Rmdir(name string, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Rmdir(name)
return fs.FileSystem.Rmdir(name, context)
}
func (me *SwitchFileSystem) Symlink(value string, linkName string) (code Status) {
func (me *SwitchFileSystem) Symlink(value string, linkName string, context *Context) (code Status) {
linkName, fs := me.findFileSystem(linkName)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Symlink(value, linkName)
return fs.FileSystem.Symlink(value, linkName, context)
}
func (me *SwitchFileSystem) Rename(oldName string, newName string) (code Status) {
func (me *SwitchFileSystem) Rename(oldName string, newName string, context *Context) (code Status) {
oldName, fs1 := me.findFileSystem(oldName)
newName, fs2 := me.findFileSystem(newName)
if fs1 != fs2 {
......@@ -141,10 +141,10 @@ func (me *SwitchFileSystem) Rename(oldName string, newName string) (code Status)
if fs1 == nil {
return ENOENT
}
return fs1.Rename(oldName, newName)
return fs1.Rename(oldName, newName, context)
}
func (me *SwitchFileSystem) Link(oldName string, newName string) (code Status) {
func (me *SwitchFileSystem) Link(oldName string, newName string, context *Context) (code Status) {
oldName, fs1 := me.findFileSystem(oldName)
newName, fs2 := me.findFileSystem(newName)
if fs1 != fs2 {
......@@ -153,47 +153,47 @@ func (me *SwitchFileSystem) Link(oldName string, newName string) (code Status) {
if fs1 == nil {
return ENOENT
}
return fs1.Link(oldName, newName)
return fs1.Link(oldName, newName, context)
}
func (me *SwitchFileSystem) Chmod(name string, mode uint32) (code Status) {
func (me *SwitchFileSystem) Chmod(name string, mode uint32, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Chmod(name, mode)
return fs.FileSystem.Chmod(name, mode, context)
}
func (me *SwitchFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
func (me *SwitchFileSystem) Chown(name string, uid uint32, gid uint32, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Chown(name, uid, gid)
return fs.FileSystem.Chown(name, uid, gid, context)
}
func (me *SwitchFileSystem) Truncate(name string, offset uint64) (code Status) {
func (me *SwitchFileSystem) Truncate(name string, offset uint64, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Truncate(name, offset)
return fs.FileSystem.Truncate(name, offset, context)
}
func (me *SwitchFileSystem) Open(name string, flags uint32) (file File, code Status) {
func (me *SwitchFileSystem) Open(name string, flags uint32, context *Context) (file File, code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return nil, ENOENT
}
return fs.FileSystem.Open(name, flags)
return fs.FileSystem.Open(name, flags, context)
}
func (me *SwitchFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *SwitchFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return nil, ENOENT
}
return fs.FileSystem.OpenDir(name)
return fs.FileSystem.OpenDir(name, context)
}
func (me *SwitchFileSystem) Mount(conn *FileSystemConnector) {
......@@ -208,60 +208,60 @@ func (me *SwitchFileSystem) Unmount() {
}
}
func (me *SwitchFileSystem) Access(name string, mode uint32) (code Status) {
func (me *SwitchFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Access(name, mode)
return fs.FileSystem.Access(name, mode, context)
}
func (me *SwitchFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
func (me *SwitchFileSystem) Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return nil, ENOENT
}
return fs.FileSystem.Create(name, flags, mode)
return fs.FileSystem.Create(name, flags, mode, context)
}
func (me *SwitchFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
func (me *SwitchFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64, context *Context) (code Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.Utimens(name, AtimeNs, CtimeNs)
return fs.FileSystem.Utimens(name, AtimeNs, CtimeNs, context)
}
func (me *SwitchFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *SwitchFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return nil, ENOENT
}
return fs.FileSystem.GetXAttr(name, attr)
return fs.FileSystem.GetXAttr(name, attr, context)
}
func (me *SwitchFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
func (me *SwitchFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.SetXAttr(name, attr, data, flags)
return fs.FileSystem.SetXAttr(name, attr, data, flags, context)
}
func (me *SwitchFileSystem) ListXAttr(name string) ([]string, Status) {
func (me *SwitchFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
name, fs := me.findFileSystem(name)
if fs == nil {
return nil, ENOENT
}
return fs.FileSystem.ListXAttr(name)
return fs.FileSystem.ListXAttr(name, context)
}
func (me *SwitchFileSystem) RemoveXAttr(name string, attr string) Status {
func (me *SwitchFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
name, fs := me.findFileSystem(name)
if fs == nil {
return ENOENT
}
return fs.FileSystem.RemoveXAttr(name, attr)
return fs.FileSystem.RemoveXAttr(name, attr, context)
}
func (me *SwitchFileSystem) Flush(name string) Status {
......
......@@ -45,94 +45,94 @@ func (me *TimingFileSystem) HotPaths(operation string) (paths []string) {
return me.LatencyMap.TopArgs(operation)
}
func (me *TimingFileSystem) GetAttr(name string) (*os.FileInfo, Status) {
func (me *TimingFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
defer me.startTimer("GetAttr", name)()
return me.FileSystem.GetAttr(name)
return me.FileSystem.GetAttr(name, context)
}
func (me *TimingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *TimingFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
defer me.startTimer("GetXAttr", name)()
return me.FileSystem.GetXAttr(name, attr)
return me.FileSystem.GetXAttr(name, attr, context)
}
func (me *TimingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
func (me *TimingFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *Context) (code Status) {
defer me.startTimer("SetXAttr", name)()
return me.FileSystem.SetXAttr(name, attr, data, flags)
return me.FileSystem.SetXAttr(name, attr, data, flags, context)
}
func (me *TimingFileSystem) ListXAttr(name string) ([]string, Status) {
func (me *TimingFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
defer me.startTimer("ListXAttr", name)()
return me.FileSystem.ListXAttr(name)
return me.FileSystem.ListXAttr(name, context)
}
func (me *TimingFileSystem) RemoveXAttr(name string, attr string) Status {
func (me *TimingFileSystem) RemoveXAttr(name string, attr string, context *Context) (code Status) {
defer me.startTimer("RemoveXAttr", name)()
return me.FileSystem.RemoveXAttr(name, attr)
return me.FileSystem.RemoveXAttr(name, attr, context)
}
func (me *TimingFileSystem) Readlink(name string) (string, Status) {
func (me *TimingFileSystem) Readlink(name string, context *Context) (string, Status) {
defer me.startTimer("Readlink", name)()
return me.FileSystem.Readlink(name)
return me.FileSystem.Readlink(name, context)
}
func (me *TimingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
func (me *TimingFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) (code Status) {
defer me.startTimer("Mknod", name)()
return me.FileSystem.Mknod(name, mode, dev)
return me.FileSystem.Mknod(name, mode, dev, context)
}
func (me *TimingFileSystem) Mkdir(name string, mode uint32) Status {
func (me *TimingFileSystem) Mkdir(name string, mode uint32, context *Context) (code Status) {
defer me.startTimer("Mkdir", name)()
return me.FileSystem.Mkdir(name, mode)
return me.FileSystem.Mkdir(name, mode, context)
}
func (me *TimingFileSystem) Unlink(name string) (code Status) {
func (me *TimingFileSystem) Unlink(name string, context *Context) (code Status) {
defer me.startTimer("Unlink", name)()
return me.FileSystem.Unlink(name)
return me.FileSystem.Unlink(name, context)
}
func (me *TimingFileSystem) Rmdir(name string) (code Status) {
func (me *TimingFileSystem) Rmdir(name string, context *Context) (code Status) {
defer me.startTimer("Rmdir", name)()
return me.FileSystem.Rmdir(name)
return me.FileSystem.Rmdir(name, context)
}
func (me *TimingFileSystem) Symlink(value string, linkName string) (code Status) {
func (me *TimingFileSystem) Symlink(value string, linkName string, context *Context) (code Status) {
defer me.startTimer("Symlink", linkName)()
return me.FileSystem.Symlink(value, linkName)
return me.FileSystem.Symlink(value, linkName, context)
}
func (me *TimingFileSystem) Rename(oldName string, newName string) (code Status) {
func (me *TimingFileSystem) Rename(oldName string, newName string, context *Context) (code Status) {
defer me.startTimer("Rename", oldName)()
return me.FileSystem.Rename(oldName, newName)
return me.FileSystem.Rename(oldName, newName, context)
}
func (me *TimingFileSystem) Link(oldName string, newName string) (code Status) {
func (me *TimingFileSystem) Link(oldName string, newName string, context *Context) (code Status) {
defer me.startTimer("Link", newName)()
return me.FileSystem.Link(oldName, newName)
return me.FileSystem.Link(oldName, newName, context)
}
func (me *TimingFileSystem) Chmod(name string, mode uint32) (code Status) {
func (me *TimingFileSystem) Chmod(name string, mode uint32, context *Context) (code Status) {
defer me.startTimer("Chmod", name)()
return me.FileSystem.Chmod(name, mode)
return me.FileSystem.Chmod(name, mode, context)
}
func (me *TimingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
func (me *TimingFileSystem) Chown(name string, uid uint32, gid uint32, context *Context) (code Status) {
defer me.startTimer("Chown", name)()
return me.FileSystem.Chown(name, uid, gid)
return me.FileSystem.Chown(name, uid, gid, context)
}
func (me *TimingFileSystem) Truncate(name string, offset uint64) (code Status) {
func (me *TimingFileSystem) Truncate(name string, offset uint64, context *Context) (code Status) {
defer me.startTimer("Truncate", name)()
return me.FileSystem.Truncate(name, offset)
return me.FileSystem.Truncate(name, offset, context)
}
func (me *TimingFileSystem) Open(name string, flags uint32) (file File, code Status) {
func (me *TimingFileSystem) Open(name string, flags uint32, context *Context) (file File, code Status) {
defer me.startTimer("Open", name)()
return me.FileSystem.Open(name, flags)
return me.FileSystem.Open(name, flags, context)
}
func (me *TimingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
func (me *TimingFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
defer me.startTimer("OpenDir", name)()
return me.FileSystem.OpenDir(name)
return me.FileSystem.OpenDir(name, context)
}
func (me *TimingFileSystem) Mount(conn *FileSystemConnector) {
......@@ -145,17 +145,17 @@ func (me *TimingFileSystem) Unmount() {
me.FileSystem.Unmount()
}
func (me *TimingFileSystem) Access(name string, mode uint32) (code Status) {
func (me *TimingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
defer me.startTimer("Access", name)()
return me.FileSystem.Access(name, mode)
return me.FileSystem.Access(name, mode, context)
}
func (me *TimingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
func (me *TimingFileSystem) Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status) {
defer me.startTimer("Create", name)()
return me.FileSystem.Create(name, flags, mode)
return me.FileSystem.Create(name, flags, mode, context)
}
func (me *TimingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
func (me *TimingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64, context *Context) (code Status) {
defer me.startTimer("Utimens", name)()
return me.FileSystem.Utimens(name, AtimeNs, CtimeNs)
return me.FileSystem.Utimens(name, AtimeNs, CtimeNs, context)
}
......@@ -87,7 +87,7 @@ type Owner struct {
Gid uint32
}
type Identity struct {
type Context struct {
Owner
Pid uint32
}
......@@ -430,7 +430,7 @@ type InHeader struct {
opcode
Unique uint64
NodeId uint64
Identity
Context
Padding uint32
}
......
......@@ -24,7 +24,7 @@ func NewXAttrFs(nm string, m map[string][]byte) *XAttrTestFs {
return x
}
func (me *XAttrTestFs) GetAttr(name string) (*os.FileInfo, Status) {
func (me *XAttrTestFs) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
a := &os.FileInfo{}
if name == "" || name == "/" {
a.Mode = S_IFDIR | 0700
......@@ -37,7 +37,7 @@ func (me *XAttrTestFs) GetAttr(name string) (*os.FileInfo, Status) {
return nil, ENOENT
}
func (me *XAttrTestFs) SetXAttr(name string, attr string, data []byte, flags int) Status {
func (me *XAttrTestFs) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
log.Println("SetXAttr", name, attr, string(data), flags)
if name != me.filename {
return ENOENT
......@@ -48,7 +48,7 @@ func (me *XAttrTestFs) SetXAttr(name string, attr string, data []byte, flags int
return OK
}
func (me *XAttrTestFs) GetXAttr(name string, attr string) ([]byte, Status) {
func (me *XAttrTestFs) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
if name != me.filename {
return nil, ENOENT
}
......@@ -60,7 +60,7 @@ func (me *XAttrTestFs) GetXAttr(name string, attr string) ([]byte, Status) {
return v, OK
}
func (me *XAttrTestFs) ListXAttr(name string) (data []string, code Status) {
func (me *XAttrTestFs) ListXAttr(name string, context *Context) (data []string, code Status) {
if name != me.filename {
return nil, ENOENT
}
......@@ -71,7 +71,7 @@ func (me *XAttrTestFs) ListXAttr(name string) (data []string, code Status) {
return data, OK
}
func (me *XAttrTestFs) RemoveXAttr(name string, attr string) Status {
func (me *XAttrTestFs) RemoveXAttr(name string, attr string, context *Context) Status {
if name != me.filename {
return ENOENT
}
......
......@@ -172,7 +172,7 @@ func (me *AutoUnionFs) updateKnownFses() {
log.Println("Done looking")
}
func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
func (me *AutoUnionFs) Readlink(path string, context *fuse.Context) (out string, code fuse.Status) {
comps := strings.Split(path, fuse.SeparatorString)
if comps[0] == _STATUS && comps[1] == _ROOT {
return me.root, fuse.OK
......@@ -198,7 +198,7 @@ func (me *AutoUnionFs) getUnionFs(name string) *UnionFs {
return me.knownFileSystems[name]
}
func (me *AutoUnionFs) Symlink(pointedTo string, linkName string) (code fuse.Status) {
func (me *AutoUnionFs) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) {
comps := strings.Split(linkName, "/")
if len(comps) != 2 {
return fuse.EPERM
......@@ -216,7 +216,7 @@ func (me *AutoUnionFs) Symlink(pointedTo string, linkName string) (code fuse.Sta
return fuse.EPERM
}
func (me *AutoUnionFs) Unlink(path string) (code fuse.Status) {
func (me *AutoUnionFs) Unlink(path string, context *fuse.Context) (code fuse.Status) {
comps := strings.Split(path, "/")
if len(comps) != 2 {
return fuse.EPERM
......@@ -231,11 +231,11 @@ func (me *AutoUnionFs) Unlink(path string) (code fuse.Status) {
}
// Must define this, because ENOSYS will suspend all GetXAttr calls.
func (me *AutoUnionFs) GetXAttr(name string, attr string) ([]byte, fuse.Status) {
func (me *AutoUnionFs) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
return nil, fuse.ENODATA
}
func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
func (me *AutoUnionFs) GetAttr(path string, context *fuse.Context) (*os.FileInfo, fuse.Status) {
if path == "" || path == _CONFIG || path == _STATUS {
a := &os.FileInfo{
Mode: fuse.S_IFDIR | 0755,
......@@ -297,7 +297,7 @@ func (me *AutoUnionFs) StatusDir() (stream chan fuse.DirEntry, status fuse.Statu
return stream, fuse.OK
}
func (me *AutoUnionFs) Open(path string, flags uint32) (fuse.File, fuse.Status) {
func (me *AutoUnionFs) Open(path string, flags uint32, context *fuse.Context) (fuse.File, fuse.Status) {
if path == filepath.Join(_STATUS, _VERSION) {
if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
......@@ -313,7 +313,7 @@ func (me *AutoUnionFs) Open(path string, flags uint32) (fuse.File, fuse.Status)
return nil, fuse.ENOENT
}
func (me *AutoUnionFs) Truncate(name string, offset uint64) (code fuse.Status) {
func (me *AutoUnionFs) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) {
if name != filepath.Join(_CONFIG, _SCAN_CONFIG) {
log.Println("Huh? Truncating unsupported write file", name)
return fuse.EPERM
......@@ -321,7 +321,7 @@ func (me *AutoUnionFs) Truncate(name string, offset uint64) (code fuse.Status) {
return fuse.OK
}
func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.Status) {
func (me *AutoUnionFs) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, status fuse.Status) {
switch name {
case _STATUS:
return me.StatusDir()
......
......@@ -44,7 +44,7 @@ type CachingFileSystem struct {
}
func readDir(fs fuse.FileSystem, name string) *dirResponse {
origStream, code := fs.OpenDir(name)
origStream, code := fs.OpenDir(name, nil)
r := &dirResponse{nil, code}
if code != fuse.OK {
......@@ -62,7 +62,7 @@ func readDir(fs fuse.FileSystem, name string) *dirResponse {
}
func getAttr(fs fuse.FileSystem, name string) *attrResponse {
a, code := fs.GetAttr(name)
a, code := fs.GetAttr(name, nil)
return &attrResponse{
FileInfo: a,
Status: code,
......@@ -71,7 +71,7 @@ func getAttr(fs fuse.FileSystem, name string) *attrResponse {
func getXAttr(fs fuse.FileSystem, nameAttr string) *xattrResponse {
ns := strings.SplitN(nameAttr, _XATTRSEP, 2)
a, code := fs.GetXAttr(ns[0], ns[1])
a, code := fs.GetXAttr(ns[0], ns[1], nil)
return &xattrResponse{
data: a,
Status: code,
......@@ -79,7 +79,7 @@ func getXAttr(fs fuse.FileSystem, nameAttr string) *xattrResponse {
}
func readLink(fs fuse.FileSystem, name string) *linkResponse {
a, code := fs.Readlink(name)
a, code := fs.Readlink(name, nil)
return &linkResponse{
linkContent: a,
Status: code,
......@@ -104,7 +104,7 @@ func (me *CachingFileSystem) DropCache() {
}
}
func (me *CachingFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
func (me *CachingFileSystem) GetAttr(name string, context *fuse.Context) (*os.FileInfo, fuse.Status) {
if name == _DROP_CACHE {
return &os.FileInfo{
Mode: fuse.S_IFREG | 0777,
......@@ -115,18 +115,18 @@ func (me *CachingFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
return r.FileInfo, r.Status
}
func (me *CachingFileSystem) GetXAttr(name string, attr string) ([]byte, fuse.Status) {
func (me *CachingFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
key := name + _XATTRSEP + attr
r := me.xattr.Get(key).(*xattrResponse)
return r.data, r.Status
}
func (me *CachingFileSystem) Readlink(name string) (string, fuse.Status) {
func (me *CachingFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) {
r := me.links.Get(name).(*linkResponse)
return r.linkContent, r.Status
}
func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.Status) {
func (me *CachingFileSystem) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, status fuse.Status) {
r := me.dirs.Get(name).(*dirResponse)
if r.Status.Ok() {
stream = make(chan fuse.DirEntry, len(r.entries))
......@@ -144,10 +144,10 @@ func (me *CachingFileSystem) Name() string {
return fmt.Sprintf("CachingFileSystem(%s)", me.FileSystem.Name())
}
func (me *CachingFileSystem) Open(name string, flags uint32) (f fuse.File, status fuse.Status) {
func (me *CachingFileSystem) Open(name string, flags uint32, context *fuse.Context) (f fuse.File, status fuse.Status) {
if flags&fuse.O_ANYWRITE != 0 && name == _DROP_CACHE {
log.Println("Dropping cache for", me.Name())
me.DropCache()
}
return me.FileSystem.Open(name, flags)
return me.FileSystem.Open(name, flags, context)
}
......@@ -34,7 +34,7 @@ func TestCachingFs(t *testing.T) {
cfs := NewCachingFileSystem(fs, 0)
os.Mkdir(wd+"/orig", 0755)
fi, code := cfs.GetAttr("orig")
fi, code := cfs.GetAttr("orig", nil)
if !code.Ok() {
t.Fatal("GetAttr failure", code)
}
......@@ -44,7 +44,7 @@ func TestCachingFs(t *testing.T) {
os.Symlink("orig", wd+"/symlink")
val, code := cfs.Readlink("symlink")
val, code := cfs.Readlink("symlink", nil)
if val != "orig" {
t.Error("unexpected readlink", val)
}
......@@ -52,7 +52,7 @@ func TestCachingFs(t *testing.T) {
t.Error("code !ok ", code)
}
stream, code := cfs.OpenDir("")
stream, code := cfs.OpenDir("", nil)
if !code.Ok() {
t.Fatal("Readdir fail", code)
}
......
......@@ -11,7 +11,7 @@ import (
// returns a nil map. This forces reloads in the DirCache until we
// succeed.
func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool {
stream, code := fs.OpenDir(dir)
stream, code := fs.OpenDir(dir, nil)
if !code.Ok() {
log.Printf("newDirnameMap(%s): %v %v", fs.Name(), dir, code)
return nil
......
This diff is collapsed.
......@@ -91,7 +91,7 @@ func (me *MemTreeFileSystem) Name() string {
return "MemTreeFileSystem"
}
func (me *MemTreeFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
func (me *MemTreeFileSystem) GetAttr(name string, context *fuse.Context) (*os.FileInfo, fuse.Status) {
dir, file := me.tree.Lookup(name)
if dir == nil {
return nil, fuse.ENOENT
......@@ -107,7 +107,7 @@ func (me *MemTreeFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
return a, fuse.OK
}
func (me *MemTreeFileSystem) Open(name string, flags uint32) (fuseFile fuse.File, code fuse.Status) {
func (me *MemTreeFileSystem) Open(name string, flags uint32, context *fuse.Context) (fuseFile fuse.File, code fuse.Status) {
if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
}
......@@ -120,7 +120,7 @@ func (me *MemTreeFileSystem) Open(name string, flags uint32) (fuseFile fuse.File
return fuse.NewReadOnlyFile(file.Data()), fuse.OK
}
func (me *MemTreeFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, code fuse.Status) {
func (me *MemTreeFileSystem) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, code fuse.Status) {
dir, file := me.tree.Lookup(name)
if dir == nil {
return nil, fuse.ENOENT
......
......@@ -53,7 +53,7 @@ func (me *MultiZipFs) Mount(connector *fuse.FileSystemConnector) {
me.Connector = connector
}
func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse.Status) {
func (me *MultiZipFs) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, code fuse.Status) {
me.lock.RLock()
defer me.lock.RUnlock()
......@@ -78,7 +78,7 @@ func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse
return stream, fuse.OK
}
func (me *MultiZipFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
func (me *MultiZipFs) GetAttr(name string, context *fuse.Context) (*os.FileInfo, fuse.Status) {
a := &os.FileInfo{}
if name == "" {
// Should not write in top dir.
......@@ -113,7 +113,7 @@ func (me *MultiZipFs) GetAttr(name string) (*os.FileInfo, fuse.Status) {
return nil, fuse.ENOENT
}
func (me *MultiZipFs) Unlink(name string) (code fuse.Status) {
func (me *MultiZipFs) Unlink(name string, context *fuse.Context) (code fuse.Status) {
dir, basename := filepath.Split(name)
if dir == CONFIG_PREFIX {
me.lock.Lock()
......@@ -135,7 +135,7 @@ func (me *MultiZipFs) Unlink(name string) (code fuse.Status) {
return fuse.EPERM
}
func (me *MultiZipFs) Readlink(path string) (val string, code fuse.Status) {
func (me *MultiZipFs) Readlink(path string, context *fuse.Context) (val string, code fuse.Status) {
dir, base := filepath.Split(path)
if dir != CONFIG_PREFIX {
return "", fuse.ENOENT
......@@ -151,7 +151,7 @@ func (me *MultiZipFs) Readlink(path string) (val string, code fuse.Status) {
return zipfile, fuse.OK
}
func (me *MultiZipFs) Symlink(value string, linkName string) (code fuse.Status) {
func (me *MultiZipFs) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) {
dir, base := filepath.Split(linkName)
if dir != CONFIG_PREFIX {
return fuse.EPERM
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment