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 {
......
...@@ -134,12 +134,12 @@ func (b *rawBridge) inode(id uint64, fh uint64) (*Inode, *fileEntry) { ...@@ -134,12 +134,12 @@ func (b *rawBridge) inode(id uint64, fh uint64) (*Inode, *fileEntry) {
func (b *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOut) (status fuse.Status) { func (b *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOut) (status fuse.Status) {
parent, _ := b.inode(header.NodeId, 0) parent, _ := b.inode(header.NodeId, 0)
child, code := parent.node.Lookup(context.TODO(), name, out) child, status := parent.node.Lookup(context.TODO(), name, out)
if !code.Ok() { if !status.Ok() {
if b.options.NegativeTimeout != nil { if b.options.NegativeTimeout != nil {
out.SetEntryTimeout(*b.options.NegativeTimeout) out.SetEntryTimeout(*b.options.NegativeTimeout)
} }
return code return status
} }
b.addNewChild(parent, name, child, nil, out) b.addNewChild(parent, name, child, nil, out)
...@@ -151,29 +151,29 @@ func (b *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOu ...@@ -151,29 +151,29 @@ func (b *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOu
func (b *rawBridge) Rmdir(header *fuse.InHeader, name string) fuse.Status { func (b *rawBridge) Rmdir(header *fuse.InHeader, name string) fuse.Status {
parent, _ := b.inode(header.NodeId, 0) parent, _ := b.inode(header.NodeId, 0)
code := parent.node.Rmdir(context.TODO(), name) status := parent.node.Rmdir(context.TODO(), name)
if code.Ok() { if status.Ok() {
parent.RmChild(name) parent.RmChild(name)
} }
return code return status
} }
func (b *rawBridge) Unlink(header *fuse.InHeader, name string) fuse.Status { func (b *rawBridge) Unlink(header *fuse.InHeader, name string) fuse.Status {
parent, _ := b.inode(header.NodeId, 0) parent, _ := b.inode(header.NodeId, 0)
code := parent.node.Unlink(context.TODO(), name) status := parent.node.Unlink(context.TODO(), name)
if code.Ok() { if status.Ok() {
parent.RmChild(name) parent.RmChild(name)
} }
return code return status
} }
func (b *rawBridge) Mkdir(input *fuse.MkdirIn, name string, out *fuse.EntryOut) (code fuse.Status) { func (b *rawBridge) Mkdir(input *fuse.MkdirIn, name string, out *fuse.EntryOut) (status fuse.Status) {
parent, _ := b.inode(input.NodeId, 0) parent, _ := b.inode(input.NodeId, 0)
child, code := parent.node.Mkdir(context.TODO(), name, input.Mode, out) child, status := parent.node.Mkdir(context.TODO(), name, input.Mode, out)
if !code.Ok() { if !status.Ok() {
return code return status
} }
if out.Attr.Mode&^07777 != fuse.S_IFDIR { if out.Attr.Mode&^07777 != fuse.S_IFDIR {
...@@ -185,12 +185,12 @@ func (b *rawBridge) Mkdir(input *fuse.MkdirIn, name string, out *fuse.EntryOut) ...@@ -185,12 +185,12 @@ func (b *rawBridge) Mkdir(input *fuse.MkdirIn, name string, out *fuse.EntryOut)
return fuse.OK return fuse.OK
} }
func (b *rawBridge) Mknod(input *fuse.MknodIn, name string, out *fuse.EntryOut) (code fuse.Status) { func (b *rawBridge) Mknod(input *fuse.MknodIn, name string, out *fuse.EntryOut) (status fuse.Status) {
parent, _ := b.inode(input.NodeId, 0) parent, _ := b.inode(input.NodeId, 0)
child, code := parent.node.Mknod(context.TODO(), name, input.Mode, input.Rdev, out) child, status := parent.node.Mknod(context.TODO(), name, input.Mode, input.Rdev, out)
if !code.Ok() { if !status.Ok() {
return code return status
} }
b.addNewChild(parent, name, child, nil, out) b.addNewChild(parent, name, child, nil, out)
...@@ -229,15 +229,15 @@ func (b *rawBridge) setEntryOutTimeout(out *fuse.EntryOut) { ...@@ -229,15 +229,15 @@ func (b *rawBridge) setEntryOutTimeout(out *fuse.EntryOut) {
} }
} }
func (b *rawBridge) Create(input *fuse.CreateIn, name string, out *fuse.CreateOut) (code fuse.Status) { func (b *rawBridge) Create(input *fuse.CreateIn, name string, out *fuse.CreateOut) (status fuse.Status) {
ctx := context.TODO() ctx := context.TODO()
parent, _ := b.inode(input.NodeId, 0) parent, _ := b.inode(input.NodeId, 0)
child, f, flags, code := parent.node.Create(ctx, name, input.Flags, input.Mode) child, f, flags, status := parent.node.Create(ctx, name, input.Flags, input.Mode)
if !code.Ok() { if !status.Ok() {
if b.options.NegativeTimeout != nil { if b.options.NegativeTimeout != nil {
out.SetEntryTimeout(*b.options.NegativeTimeout) out.SetEntryTimeout(*b.options.NegativeTimeout)
} }
return code return status
} }
out.Fh = b.addNewChild(parent, name, child, f, &out.EntryOut) out.Fh = b.addNewChild(parent, name, child, f, &out.EntryOut)
...@@ -274,11 +274,11 @@ func (b *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Statu ...@@ -274,11 +274,11 @@ func (b *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Statu
f = nil f = nil
} }
code := n.node.GetAttr(context.TODO(), f, out) status := n.node.GetAttr(context.TODO(), f, out)
b.setAttrTimeout(out) b.setAttrTimeout(out)
out.Ino = input.NodeId out.Ino = input.NodeId
out.Mode = (out.Attr.Mode & 07777) | n.mode out.Mode = (out.Attr.Mode & 07777) | n.mode
return code return status
} }
func (b *rawBridge) setAttrTimeout(out *fuse.AttrOut) { func (b *rawBridge) setAttrTimeout(out *fuse.AttrOut) {
...@@ -287,7 +287,7 @@ func (b *rawBridge) setAttrTimeout(out *fuse.AttrOut) { ...@@ -287,7 +287,7 @@ func (b *rawBridge) setAttrTimeout(out *fuse.AttrOut) {
} }
} }
func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse.Status) { func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (status fuse.Status) {
ctx := context.TODO() ctx := context.TODO()
n, fEntry := b.inode(input.NodeId, input.Fh) n, fEntry := b.inode(input.NodeId, input.Fh)
...@@ -298,10 +298,10 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse ...@@ -298,10 +298,10 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse
if input.Valid&fuse.FATTR_MODE != 0 { if input.Valid&fuse.FATTR_MODE != 0 {
permissions := uint32(07777) & input.Mode permissions := uint32(07777) & input.Mode
code = n.node.Chmod(ctx, f, permissions) status = n.node.Chmod(ctx, f, permissions)
} }
if code.Ok() && (input.Valid&(fuse.FATTR_UID|fuse.FATTR_GID) != 0) { if status.Ok() && (input.Valid&(fuse.FATTR_UID|fuse.FATTR_GID) != 0) {
var uid uint32 = ^uint32(0) // means "do not change" in chown(2) var uid uint32 = ^uint32(0) // means "do not change" in chown(2)
var gid uint32 = ^uint32(0) var gid uint32 = ^uint32(0)
if input.Valid&fuse.FATTR_UID != 0 { if input.Valid&fuse.FATTR_UID != 0 {
...@@ -310,14 +310,14 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse ...@@ -310,14 +310,14 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse
if input.Valid&fuse.FATTR_GID != 0 { if input.Valid&fuse.FATTR_GID != 0 {
gid = input.Gid gid = input.Gid
} }
code = n.node.Chown(ctx, f, uid, gid) status = n.node.Chown(ctx, f, uid, gid)
} }
if code.Ok() && input.Valid&fuse.FATTR_SIZE != 0 { if status.Ok() && input.Valid&fuse.FATTR_SIZE != 0 {
code = n.node.Truncate(ctx, f, input.Size) status = n.node.Truncate(ctx, f, input.Size)
} }
if code.Ok() && (input.Valid&(fuse.FATTR_ATIME|fuse.FATTR_MTIME|fuse.FATTR_ATIME_NOW|fuse.FATTR_MTIME_NOW) != 0) { if status.Ok() && (input.Valid&(fuse.FATTR_ATIME|fuse.FATTR_MTIME|fuse.FATTR_ATIME_NOW|fuse.FATTR_MTIME_NOW) != 0) {
now := time.Now() now := time.Now()
var atime *time.Time var atime *time.Time
var mtime *time.Time var mtime *time.Time
...@@ -340,28 +340,28 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse ...@@ -340,28 +340,28 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse
} }
} }
code = n.node.Utimens(ctx, f, atime, mtime) status = n.node.Utimens(ctx, f, atime, mtime)
} }
if !code.Ok() { if !status.Ok() {
return code return status
} }
// Must call GetAttr(); the filesystem may override some of // Must call GetAttr(); the filesystem may override some of
// the changes we effect here. // the changes we effect here.
code = n.node.GetAttr(ctx, f, out) status = n.node.GetAttr(ctx, f, out)
b.setAttrTimeout(out) b.setAttrTimeout(out)
out.Ino = n.nodeID.Ino out.Ino = n.nodeID.Ino
out.Mode = n.mode | (out.Mode &^ 07777) out.Mode = n.mode | (out.Mode &^ 07777)
return code return status
} }
func (b *rawBridge) Rename(input *fuse.RenameIn, oldName string, newName string) fuse.Status { func (b *rawBridge) Rename(input *fuse.RenameIn, oldName string, newName string) fuse.Status {
p1, _ := b.inode(input.NodeId, 0) p1, _ := b.inode(input.NodeId, 0)
p2, _ := b.inode(input.Newdir, 0) p2, _ := b.inode(input.Newdir, 0)
code := p1.node.Rename(context.TODO(), oldName, p2.node, newName, input.Flags) status := p1.node.Rename(context.TODO(), oldName, p2.node, newName, input.Flags)
if code.Ok() { if status.Ok() {
if input.Flags&unix.RENAME_EXCHANGE != 0 { if input.Flags&unix.RENAME_EXCHANGE != 0 {
// XXX - test coverage. // XXX - test coverage.
p1.ExchangeChild(oldName, p2, newName) p1.ExchangeChild(oldName, p2, newName)
...@@ -369,16 +369,16 @@ func (b *rawBridge) Rename(input *fuse.RenameIn, oldName string, newName string) ...@@ -369,16 +369,16 @@ func (b *rawBridge) Rename(input *fuse.RenameIn, oldName string, newName string)
p1.MvChild(oldName, p2, newName, true) p1.MvChild(oldName, p2, newName, true)
} }
} }
return code return status
} }
func (b *rawBridge) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (code fuse.Status) { func (b *rawBridge) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (status fuse.Status) {
parent, _ := b.inode(input.NodeId, 0) parent, _ := b.inode(input.NodeId, 0)
target, _ := b.inode(input.Oldnodeid, 0) target, _ := b.inode(input.Oldnodeid, 0)
child, code := parent.node.Link(context.TODO(), target.node, name, out) child, status := parent.node.Link(context.TODO(), target.node, name, out)
if !code.Ok() { if !status.Ok() {
return code return status
} }
b.addNewChild(parent, name, child, nil, out) b.addNewChild(parent, name, child, nil, out)
...@@ -386,11 +386,11 @@ func (b *rawBridge) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (c ...@@ -386,11 +386,11 @@ func (b *rawBridge) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (c
return fuse.OK return fuse.OK
} }
func (b *rawBridge) Symlink(header *fuse.InHeader, target string, name string, out *fuse.EntryOut) (code fuse.Status) { func (b *rawBridge) Symlink(header *fuse.InHeader, target string, name string, out *fuse.EntryOut) (status fuse.Status) {
parent, _ := b.inode(header.NodeId, 0) parent, _ := b.inode(header.NodeId, 0)
child, code := parent.node.Symlink(context.TODO(), target, name, out) child, status := parent.node.Symlink(context.TODO(), target, name, out)
if !code.Ok() { if !status.Ok() {
return code return status
} }
b.addNewChild(parent, name, child, nil, out) b.addNewChild(parent, name, child, nil, out)
...@@ -398,30 +398,30 @@ func (b *rawBridge) Symlink(header *fuse.InHeader, target string, name string, o ...@@ -398,30 +398,30 @@ func (b *rawBridge) Symlink(header *fuse.InHeader, target string, name string, o
return fuse.OK return fuse.OK
} }
func (b *rawBridge) Readlink(header *fuse.InHeader) (out []byte, code fuse.Status) { func (b *rawBridge) Readlink(header *fuse.InHeader) (out []byte, status fuse.Status) {
n, _ := b.inode(header.NodeId, 0) n, _ := b.inode(header.NodeId, 0)
result, code := n.node.Readlink(context.TODO()) result, status := n.node.Readlink(context.TODO())
if !code.Ok() { if !status.Ok() {
return nil, code return nil, status
} }
return []byte(result), fuse.OK return []byte(result), fuse.OK
} }
func (b *rawBridge) Access(input *fuse.AccessIn) (code fuse.Status) { func (b *rawBridge) Access(input *fuse.AccessIn) (status fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
// Extended attributes. // Extended attributes.
func (b *rawBridge) GetXAttrSize(header *fuse.InHeader, attr string) (sz int, code fuse.Status) { func (b *rawBridge) GetXAttrSize(header *fuse.InHeader, attr string) (sz int, status fuse.Status) {
return 0, fuse.ENOSYS return 0, fuse.ENOSYS
} }
func (b *rawBridge) GetXAttrData(header *fuse.InHeader, attr string) (data []byte, code fuse.Status) { func (b *rawBridge) GetXAttrData(header *fuse.InHeader, attr string) (data []byte, status fuse.Status) {
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (b *rawBridge) ListXAttr(header *fuse.InHeader) (attributes []byte, code fuse.Status) { func (b *rawBridge) ListXAttr(header *fuse.InHeader) (attributes []byte, status fuse.Status) {
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
...@@ -429,16 +429,16 @@ func (b *rawBridge) SetXAttr(input *fuse.SetXAttrIn, attr string, data []byte) f ...@@ -429,16 +429,16 @@ func (b *rawBridge) SetXAttr(input *fuse.SetXAttrIn, attr string, data []byte) f
return fuse.ENOSYS return fuse.ENOSYS
} }
func (b *rawBridge) RemoveXAttr(header *fuse.InHeader, attr string) (code fuse.Status) { func (b *rawBridge) RemoveXAttr(header *fuse.InHeader, attr string) (status fuse.Status) {
return return
} }
func (b *rawBridge) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) { func (b *rawBridge) Open(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {
n, _ := b.inode(input.NodeId, 0) n, _ := b.inode(input.NodeId, 0)
// NOSUBMIT: what about the mode argument? // NOSUBMIT: what about the mode argument?
f, flags, code := n.node.Open(context.TODO(), input.Flags) f, flags, status := n.node.Open(context.TODO(), input.Flags)
if !code.Ok() { if !status.Ok() {
return code return status
} }
b.mu.Lock() b.mu.Lock()
...@@ -469,17 +469,17 @@ func (b *rawBridge) Read(input *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse. ...@@ -469,17 +469,17 @@ func (b *rawBridge) Read(input *fuse.ReadIn, buf []byte) (fuse.ReadResult, fuse.
return n.node.Read(context.TODO(), f.file, buf, int64(input.Offset)) return n.node.Read(context.TODO(), f.file, buf, int64(input.Offset))
} }
func (b *rawBridge) GetLk(input *fuse.LkIn, out *fuse.LkOut) (code fuse.Status) { func (b *rawBridge) GetLk(input *fuse.LkIn, out *fuse.LkOut) (status fuse.Status) {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
return n.node.GetLk(context.TODO(), f.file, input.Owner, &input.Lk, input.LkFlags, &out.Lk) return n.node.GetLk(context.TODO(), f.file, input.Owner, &input.Lk, input.LkFlags, &out.Lk)
} }
func (b *rawBridge) SetLk(input *fuse.LkIn) (code fuse.Status) { func (b *rawBridge) SetLk(input *fuse.LkIn) (status fuse.Status) {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
return n.node.SetLk(context.TODO(), f.file, input.Owner, &input.Lk, input.LkFlags) return n.node.SetLk(context.TODO(), f.file, input.Owner, &input.Lk, input.LkFlags)
} }
func (b *rawBridge) SetLkw(input *fuse.LkIn) (code fuse.Status) { func (b *rawBridge) SetLkw(input *fuse.LkIn) (status fuse.Status) {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
return n.node.SetLkw(context.TODO(), f.file, input.Owner, &input.Lk, input.LkFlags) return n.node.SetLkw(context.TODO(), f.file, input.Owner, &input.Lk, input.LkFlags)
} }
...@@ -509,7 +509,7 @@ func (b *rawBridge) releaseFileEntry(fh uint64) { ...@@ -509,7 +509,7 @@ func (b *rawBridge) releaseFileEntry(fh uint64) {
} }
} }
func (b *rawBridge) Write(input *fuse.WriteIn, data []byte) (written uint32, code fuse.Status) { func (b *rawBridge) Write(input *fuse.WriteIn, data []byte) (written uint32, status fuse.Status) {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
return n.node.Write(context.TODO(), f.file, data, int64(input.Offset)) return n.node.Write(context.TODO(), f.file, data, int64(input.Offset))
} }
...@@ -519,21 +519,21 @@ func (b *rawBridge) Flush(input *fuse.FlushIn) fuse.Status { ...@@ -519,21 +519,21 @@ func (b *rawBridge) Flush(input *fuse.FlushIn) fuse.Status {
return n.node.Flush(context.TODO(), f.file) return n.node.Flush(context.TODO(), f.file)
} }
func (b *rawBridge) Fsync(input *fuse.FsyncIn) (code fuse.Status) { func (b *rawBridge) Fsync(input *fuse.FsyncIn) (status fuse.Status) {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
return n.node.Fsync(context.TODO(), f.file, input.FsyncFlags) return n.node.Fsync(context.TODO(), f.file, input.FsyncFlags)
} }
func (b *rawBridge) Fallocate(input *fuse.FallocateIn) (code fuse.Status) { func (b *rawBridge) Fallocate(input *fuse.FallocateIn) (status fuse.Status) {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
return n.node.Allocate(context.TODO(), f.file, input.Offset, input.Length, input.Mode) return n.node.Allocate(context.TODO(), f.file, input.Offset, input.Length, input.Mode)
} }
func (b *rawBridge) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) { func (b *rawBridge) OpenDir(input *fuse.OpenIn, out *fuse.OpenOut) fuse.Status {
n, _ := b.inode(input.NodeId, 0) n, _ := b.inode(input.NodeId, 0)
code := n.node.OpenDir(context.TODO()) status := n.node.OpenDir(context.TODO())
if !code.Ok() { if !status.Ok() {
return code return status
} }
b.mu.Lock() b.mu.Lock()
defer b.mu.Unlock() defer b.mu.Unlock()
...@@ -547,9 +547,9 @@ func (b *rawBridge) getStream(input *fuse.ReadIn, inode *Inode, f *fileEntry) fu ...@@ -547,9 +547,9 @@ func (b *rawBridge) getStream(input *fuse.ReadIn, inode *Inode, f *fileEntry) fu
f.dirStream.Close() f.dirStream.Close()
f.dirStream = nil f.dirStream = nil
} }
str, code := inode.node.ReadDir(context.TODO()) str, status := inode.node.ReadDir(context.TODO())
if !code.Ok() { if !status.Ok() {
return code return status
} }
f.hasOverflow = false f.hasOverflow = false
...@@ -562,8 +562,8 @@ func (b *rawBridge) getStream(input *fuse.ReadIn, inode *Inode, f *fileEntry) fu ...@@ -562,8 +562,8 @@ func (b *rawBridge) getStream(input *fuse.ReadIn, inode *Inode, f *fileEntry) fu
func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status { func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
if code := b.getStream(input, n, f); !code.Ok() { if status := b.getStream(input, n, f); !status.Ok() {
return code return status
} }
if f.hasOverflow { if f.hasOverflow {
...@@ -574,15 +574,15 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta ...@@ -574,15 +574,15 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta
// TODO - should post '..' and '.' ? // TODO - should post '..' and '.' ?
for f.dirStream.HasNext() { for f.dirStream.HasNext() {
e, code := f.dirStream.Next() e, status := f.dirStream.Next()
if !code.Ok() { if !status.Ok() {
return code return status
} }
if !out.AddDirEntry(e) { if !out.AddDirEntry(e) {
f.overflow = e f.overflow = e
f.hasOverflow = true f.hasOverflow = true
return code return status
} }
} }
...@@ -592,22 +592,22 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta ...@@ -592,22 +592,22 @@ func (b *rawBridge) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Sta
func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status { func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse.Status {
n, f := b.inode(input.NodeId, input.Fh) n, f := b.inode(input.NodeId, input.Fh)
if code := b.getStream(input, n, f); !code.Ok() { if status := b.getStream(input, n, f); !status.Ok() {
return code return status
} }
for f.dirStream.HasNext() { for f.dirStream.HasNext() {
var e fuse.DirEntry var e fuse.DirEntry
var code fuse.Status var status fuse.Status
if f.hasOverflow { if f.hasOverflow {
e = f.overflow e = f.overflow
f.hasOverflow = false f.hasOverflow = false
} else { } else {
e, code = f.dirStream.Next() e, status = f.dirStream.Next()
} }
if !code.Ok() { if !status.Ok() {
return code return status
} }
entryOut := out.AddDirLookupEntry(e) entryOut := out.AddDirLookupEntry(e)
...@@ -617,8 +617,8 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse ...@@ -617,8 +617,8 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse
return fuse.OK return fuse.OK
} }
child, code := n.node.Lookup(context.TODO(), e.Name, entryOut) child, status := n.node.Lookup(context.TODO(), e.Name, entryOut)
if !code.Ok() { if !status.Ok() {
if b.options.NegativeTimeout != nil { if b.options.NegativeTimeout != nil {
entryOut.SetEntryTimeout(*b.options.NegativeTimeout) entryOut.SetEntryTimeout(*b.options.NegativeTimeout)
} }
...@@ -637,11 +637,11 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse ...@@ -637,11 +637,11 @@ func (b *rawBridge) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) fuse
return fuse.OK return fuse.OK
} }
func (b *rawBridge) FsyncDir(input *fuse.FsyncIn) (code fuse.Status) { func (b *rawBridge) FsyncDir(input *fuse.FsyncIn) (status fuse.Status) {
return return
} }
func (b *rawBridge) StatFs(input *fuse.InHeader, out *fuse.StatfsOut) (code fuse.Status) { func (b *rawBridge) StatFs(input *fuse.InHeader, out *fuse.StatfsOut) (status fuse.Status) {
return return
} }
......
...@@ -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