Commit 09e0ba87 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: code -> status.

parent bea6a031
...@@ -101,9 +101,9 @@ type Operations interface { ...@@ -101,9 +101,9 @@ type Operations interface {
setInode(*Inode) bool setInode(*Inode) bool
// File locking // File locking
GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (status fuse.Status)
SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status)
SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status)
// The methods below may be called on closed files, due to // The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF. // concurrency. In that case, you should return EBADF.
...@@ -120,11 +120,11 @@ type Operations interface { ...@@ -120,11 +120,11 @@ type Operations interface {
Rmdir(ctx context.Context, name string) fuse.Status Rmdir(ctx context.Context, name string) fuse.Status
Unlink(ctx context.Context, name string) fuse.Status Unlink(ctx context.Context, name string) fuse.Status
Rename(ctx context.Context, name string, newParent Operations, newName string, flags uint32) fuse.Status Rename(ctx context.Context, name string, newParent Operations, newName string, flags uint32) fuse.Status
Create(ctx context.Context, name string, flags uint32, mode uint32) (node *Inode, fh FileHandle, fuseFlags uint32, code fuse.Status) Create(ctx context.Context, name string, flags uint32, mode uint32) (node *Inode, fh FileHandle, fuseFlags uint32, status fuse.Status)
Link(ctx context.Context, target Operations, name string, out *fuse.EntryOut) (node *Inode, code fuse.Status) Link(ctx context.Context, target Operations, name string, out *fuse.EntryOut) (node *Inode, status fuse.Status)
Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (node *Inode, code fuse.Status) Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (node *Inode, status fuse.Status)
Readlink(ctx context.Context) (string, fuse.Status) Readlink(ctx context.Context) (string, fuse.Status)
Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, code fuse.Status) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, status fuse.Status)
// OpenDir is called for sanity/permission checks on opening a // OpenDir is called for sanity/permission checks on opening a
// directory. // directory.
...@@ -135,9 +135,9 @@ type Operations interface { ...@@ -135,9 +135,9 @@ type Operations interface {
Read(ctx context.Context, f FileHandle, dest []byte, off int64) (fuse.ReadResult, fuse.Status) Read(ctx context.Context, f FileHandle, dest []byte, off int64) (fuse.ReadResult, fuse.Status)
Write(ctx context.Context, f FileHandle, data []byte, off int64) (written uint32, code fuse.Status) Write(ctx context.Context, f FileHandle, data []byte, off int64) (written uint32, status fuse.Status)
Fsync(ctx context.Context, f FileHandle, flags uint32) (code fuse.Status) Fsync(ctx context.Context, f FileHandle, flags uint32) (status fuse.Status)
// Flush is called for close() call on a file descriptor. In // Flush is called for close() call on a file descriptor. In
// case of duplicated descriptor, it may be called more than // case of duplicated descriptor, it may be called more than
...@@ -161,17 +161,17 @@ type Operations interface { ...@@ -161,17 +161,17 @@ type Operations interface {
Chown(ctx context.Context, f FileHandle, uid uint32, gid uint32) fuse.Status Chown(ctx context.Context, f FileHandle, uid uint32, gid uint32) fuse.Status
Chmod(ctx context.Context, f FileHandle, perms uint32) fuse.Status Chmod(ctx context.Context, f FileHandle, perms uint32) fuse.Status
Utimens(ctx context.Context, f FileHandle, atime *time.Time, mtime *time.Time) fuse.Status Utimens(ctx context.Context, f FileHandle, atime *time.Time, mtime *time.Time) fuse.Status
Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) (code fuse.Status) Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) (status fuse.Status)
} }
type FileHandle interface { type FileHandle interface {
Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, fuse.Status) Read(ctx context.Context, dest []byte, off int64) (fuse.ReadResult, fuse.Status)
Write(ctx context.Context, data []byte, off int64) (written uint32, code fuse.Status) Write(ctx context.Context, data []byte, off int64) (written uint32, status fuse.Status)
// File locking // File locking
GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (status fuse.Status)
SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status)
SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status)
// Flush is called for close() call on a file descriptor. In // Flush is called for close() call on a file descriptor. In
// case of duplicated descriptor, it may be called more than // case of duplicated descriptor, it may be called more than
...@@ -194,7 +194,7 @@ type FileHandle interface { ...@@ -194,7 +194,7 @@ type FileHandle interface {
Chown(ctx context.Context, uid uint32, gid uint32) fuse.Status Chown(ctx context.Context, uid uint32, gid uint32) fuse.Status
Chmod(ctx context.Context, perms uint32) fuse.Status Chmod(ctx context.Context, perms uint32) fuse.Status
Utimens(ctx context.Context, atime *time.Time, mtime *time.Time) fuse.Status Utimens(ctx context.Context, atime *time.Time, mtime *time.Time) fuse.Status
Allocate(ctx context.Context, off uint64, size uint64, mode uint32) (code fuse.Status) Allocate(ctx context.Context, off uint64, size uint64, mode uint32) (status fuse.Status)
} }
type Options struct { type Options struct {
......
This diff is collapsed.
...@@ -88,7 +88,7 @@ func (n *DefaultOperations) Read(ctx context.Context, f FileHandle, dest []byte, ...@@ -88,7 +88,7 @@ func (n *DefaultOperations) Read(ctx context.Context, f FileHandle, dest []byte,
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (n *DefaultOperations) Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (node *Inode, code fuse.Status) { func (n *DefaultOperations) Symlink(ctx context.Context, target, name string, out *fuse.EntryOut) (node *Inode, status fuse.Status) {
log.Println("defsyml") log.Println("defsyml")
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
...@@ -104,7 +104,7 @@ func (n *DefaultOperations) Fsync(ctx context.Context, f FileHandle, flags uint3 ...@@ -104,7 +104,7 @@ func (n *DefaultOperations) Fsync(ctx context.Context, f FileHandle, flags uint3
return fuse.ENOSYS return fuse.ENOSYS
} }
func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte, off int64) (written uint32, code fuse.Status) { func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte, off int64) (written uint32, status fuse.Status) {
if f != nil { if f != nil {
return f.Write(ctx, data, off) return f.Write(ctx, data, off)
} }
...@@ -112,7 +112,7 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte ...@@ -112,7 +112,7 @@ func (n *DefaultOperations) Write(ctx context.Context, f FileHandle, data []byte
return 0, fuse.ENOSYS return 0, fuse.ENOSYS
} }
func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) { func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (status fuse.Status) {
if f != nil { if f != nil {
return f.GetLk(ctx, owner, lk, flags, out) return f.GetLk(ctx, owner, lk, flags, out)
} }
...@@ -120,7 +120,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6 ...@@ -120,7 +120,7 @@ func (n *DefaultOperations) GetLk(ctx context.Context, f FileHandle, owner uint6
return fuse.ENOSYS return fuse.ENOSYS
} }
func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status) {
if f != nil { if f != nil {
return f.SetLk(ctx, owner, lk, flags) return f.SetLk(ctx, owner, lk, flags)
} }
...@@ -128,7 +128,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6 ...@@ -128,7 +128,7 @@ func (n *DefaultOperations) SetLk(ctx context.Context, f FileHandle, owner uint6
return fuse.ENOSYS return fuse.ENOSYS
} }
func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (n *DefaultOperations) SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status) {
if f != nil { if f != nil {
return f.SetLkw(ctx, owner, lk, flags) return f.SetLkw(ctx, owner, lk, flags)
} }
...@@ -149,7 +149,7 @@ func (n *DefaultOperations) Release(ctx context.Context, f FileHandle) { ...@@ -149,7 +149,7 @@ func (n *DefaultOperations) Release(ctx context.Context, f FileHandle) {
} }
} }
func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) (code fuse.Status) { func (n *DefaultOperations) Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) (status fuse.Status) {
if f != nil { if f != nil {
return f.Allocate(ctx, off, size, mode) return f.Allocate(ctx, off, size, mode)
} }
...@@ -197,14 +197,14 @@ func (n *DefaultOperations) Utimens(ctx context.Context, f FileHandle, atime *ti ...@@ -197,14 +197,14 @@ func (n *DefaultOperations) Utimens(ctx context.Context, f FileHandle, atime *ti
return fuse.ENOSYS return fuse.ENOSYS
} }
func (n *DefaultOperations) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, code fuse.Status) { func (n *DefaultOperations) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, status fuse.Status) {
return nil, 0, fuse.ENOSYS return nil, 0, fuse.ENOSYS
} }
func (n *DefaultOperations) Create(ctx context.Context, name string, flags uint32, mode uint32) (node *Inode, fh FileHandle, fuseFlags uint32, code fuse.Status) { func (n *DefaultOperations) Create(ctx context.Context, name string, flags uint32, mode uint32) (node *Inode, fh FileHandle, fuseFlags uint32, status fuse.Status) {
return nil, nil, 0, fuse.ENOSYS return nil, nil, 0, fuse.ENOSYS
} }
func (n *DefaultOperations) Link(ctx context.Context, target Operations, name string, out *fuse.EntryOut) (node *Inode, code fuse.Status) { func (n *DefaultOperations) Link(ctx context.Context, target Operations, name string, out *fuse.EntryOut) (node *Inode, status fuse.Status) {
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
...@@ -217,19 +217,19 @@ func (f *DefaultFile) Read(ctx context.Context, dest []byte, off int64) (fuse.Re ...@@ -217,19 +217,19 @@ func (f *DefaultFile) Read(ctx context.Context, dest []byte, off int64) (fuse.Re
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (f *DefaultFile) Write(ctx context.Context, data []byte, off int64) (written uint32, code fuse.Status) { func (f *DefaultFile) Write(ctx context.Context, data []byte, off int64) (written uint32, status fuse.Status) {
return 0, fuse.ENOSYS return 0, fuse.ENOSYS
} }
func (f *DefaultFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) { func (f *DefaultFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (status fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *DefaultFile) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *DefaultFile) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *DefaultFile) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *DefaultFile) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
...@@ -262,10 +262,10 @@ func (f *DefaultFile) Utimens(ctx context.Context, atime *time.Time, mtime *time ...@@ -262,10 +262,10 @@ func (f *DefaultFile) Utimens(ctx context.Context, atime *time.Time, mtime *time
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *DefaultFile) Allocate(ctx context.Context, off uint64, size uint64, mode uint32) (code fuse.Status) { func (f *DefaultFile) Allocate(ctx context.Context, off uint64, size uint64, mode uint32) (status fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *DefaultFile) Fsync(ctx context.Context, flags uint32) (code fuse.Status) { func (f *DefaultFile) Fsync(ctx context.Context, flags uint32) (status fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
...@@ -30,7 +30,7 @@ type loopbackFile struct { ...@@ -30,7 +30,7 @@ type loopbackFile struct {
mu sync.Mutex mu sync.Mutex
} }
func (f *loopbackFile) Read(ctx context.Context, buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { func (f *loopbackFile) Read(ctx context.Context, buf []byte, off int64) (res fuse.ReadResult, status fuse.Status) {
f.mu.Lock() f.mu.Lock()
// This is not racy by virtue of the kernel properly // This is not racy by virtue of the kernel properly
// synchronizing the open/write/close. // synchronizing the open/write/close.
...@@ -68,7 +68,7 @@ func (f *loopbackFile) Flush(ctx context.Context) fuse.Status { ...@@ -68,7 +68,7 @@ func (f *loopbackFile) Flush(ctx context.Context) fuse.Status {
return fuse.ToStatus(err) return fuse.ToStatus(err)
} }
func (f *loopbackFile) Fsync(ctx context.Context, flags uint32) (code fuse.Status) { func (f *loopbackFile) Fsync(ctx context.Context, flags uint32) (status fuse.Status) {
f.mu.Lock() f.mu.Lock()
r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd()))) r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd())))
f.mu.Unlock() f.mu.Unlock()
...@@ -82,23 +82,23 @@ const ( ...@@ -82,23 +82,23 @@ const (
_OFD_SETLKW = 38 _OFD_SETLKW = 38
) )
func (f *loopbackFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) { func (f *loopbackFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (status fuse.Status) {
flk := syscall.Flock_t{} flk := syscall.Flock_t{}
lk.ToFlockT(&flk) lk.ToFlockT(&flk)
code = fuse.ToStatus(syscall.FcntlFlock(f.File.Fd(), _OFD_GETLK, &flk)) status = fuse.ToStatus(syscall.FcntlFlock(f.File.Fd(), _OFD_GETLK, &flk))
out.FromFlockT(&flk) out.FromFlockT(&flk)
return return
} }
func (f *loopbackFile) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *loopbackFile) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status) {
return f.setLock(ctx, owner, lk, flags, false) return f.setLock(ctx, owner, lk, flags, false)
} }
func (f *loopbackFile) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *loopbackFile) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (status fuse.Status) {
return f.setLock(ctx, owner, lk, flags, true) return f.setLock(ctx, owner, lk, flags, true)
} }
func (f *loopbackFile) setLock(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, blocking bool) (code fuse.Status) { func (f *loopbackFile) setLock(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, blocking bool) (status fuse.Status) {
if (flags & fuse.FUSE_LK_FLOCK) != 0 { if (flags & fuse.FUSE_LK_FLOCK) != 0 {
var op int var op int
switch lk.Typ { switch lk.Typ {
......
...@@ -542,6 +542,6 @@ func (n *Inode) WriteCache(offset int64, data []byte) fuse.Status { ...@@ -542,6 +542,6 @@ func (n *Inode) WriteCache(offset int64, data []byte) fuse.Status {
} }
func (n *Inode) ReadCache(offset int64, dest []byte) (count int, code fuse.Status) { func (n *Inode) ReadCache(offset int64, dest []byte) (count int, status fuse.Status) {
return n.bridge.server.InodeRetrieveCache(n.nodeID.Ino, offset, dest) return n.bridge.server.InodeRetrieveCache(n.nodeID.Ino, offset, dest)
} }
...@@ -165,7 +165,7 @@ func idFromStat(st *syscall.Stat_t) FileID { ...@@ -165,7 +165,7 @@ func idFromStat(st *syscall.Stat_t) FileID {
} }
} }
func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mode uint32) (inode *Inode, fh FileHandle, fuseFlags uint32, code fuse.Status) { func (n *loopbackNode) Create(ctx context.Context, name string, flags uint32, mode uint32) (inode *Inode, fh FileHandle, fuseFlags uint32, status fuse.Status) {
p := filepath.Join(n.path(), name) p := filepath.Join(n.path(), name)
f, err := os.OpenFile(p, int(flags)|os.O_CREATE, os.FileMode(mode)) f, err := os.OpenFile(p, int(flags)|os.O_CREATE, os.FileMode(mode))
...@@ -242,7 +242,7 @@ func (n *loopbackNode) Readlink(ctx context.Context) (string, fuse.Status) { ...@@ -242,7 +242,7 @@ func (n *loopbackNode) Readlink(ctx context.Context) (string, fuse.Status) {
} }
} }
func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, code fuse.Status) { func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, fuseFlags uint32, status fuse.Status) {
p := n.path() p := n.path()
f, err := os.OpenFile(p, int(flags), 0) f, err := os.OpenFile(p, int(flags), 0)
if err != nil { if err != nil {
...@@ -285,8 +285,8 @@ func (n *loopbackNode) GetAttr(ctx context.Context, f FileHandle, out *fuse.Attr ...@@ -285,8 +285,8 @@ func (n *loopbackNode) GetAttr(ctx context.Context, f FileHandle, out *fuse.Attr
return f.GetAttr(ctx, out) return f.GetAttr(ctx, out)
} }
if code, ok := n.fGetAttr(ctx, out); ok { if status, ok := n.fGetAttr(ctx, out); ok {
return code return status
} }
p := n.path() p := n.path()
......
...@@ -500,6 +500,14 @@ func TestReadDir(t *testing.T) { ...@@ -500,6 +500,14 @@ func TestReadDir(t *testing.T) {
tc := newTestCase(t) tc := newTestCase(t)
defer tc.Clean() defer tc.Clean()
f, err := os.Open(tc.mntDir)
if err != nil {
t.Fatalf("Open: %v", err)
}
defer f.Close()
// add entries after opening the directory
// XXX what about ".." and "." ? // XXX what about ".." and "." ?
want := map[string]bool{} want := map[string]bool{}
for i := 0; i < 110; i++ { for i := 0; i < 110; i++ {
...@@ -512,13 +520,13 @@ func TestReadDir(t *testing.T) { ...@@ -512,13 +520,13 @@ func TestReadDir(t *testing.T) {
} }
} }
entries, err := ioutil.ReadDir(tc.mntDir) names, err := f.Readdirnames(-1)
if err != nil { if err != nil {
t.Fatalf("ReadDir: %v", err) t.Fatalf("ReadDir: %v", err)
} }
got := map[string]bool{} got := map[string]bool{}
for _, e := range entries { for _, e := range names {
got[e.Name()] = true got[e] = true
} }
if len(got) != len(want) { if len(got) != len(want) {
t.Errorf("got %d entries, want %d", len(got), len(want)) t.Errorf("got %d entries, want %d", len(got), len(want))
......
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