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