Commit e6ec0065 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: regularize method naming

parent 1ab130b4
......@@ -50,6 +50,10 @@ Decisions
reading) are handled automatically. No support for directory
seeks.
* Method names are based on syscall names. Where there is no
syscall (eg. "open directory"), we bias towards writing
everything together (Opendir)
To do/To decide
=========
......
......@@ -67,7 +67,8 @@ import (
// Operations is the interface that implements the filesystem inode.
// Each Operations instance must embed OperationStubs. All error
// reporting must use the syscall.Errno type. The value 0 (`OK`)
// should be used to indicate success.
// should be used to indicate success. The method names are inspired
// on the system call names, so we have Listxattr rather than ListXAttr.
type Operations interface {
// populateInode and inode are used by nodefs internally to
// link Inode to a Node.
......@@ -82,9 +83,9 @@ type Operations interface {
// OperationStubs, and should not be reimplemented.
Inode() *Inode
// StatFs implements statistics for the filesystem that holds
// Statfs implements statistics for the filesystem that holds
// this Inode.
StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno
Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno
// Access should return if the caller can access the file with
// the given mode. In this case, the context has data about
......@@ -95,10 +96,10 @@ type Operations interface {
// GetAttr reads attributes for an Inode. The library will
// ensure that Mode and Ino are set correctly. For regular
// files, Size should be set so it can be read correctly.
GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno
Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno
// SetAttr sets attributes for an Inode.
SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
// OnAdd is called once this Operations object is attached to
// an Inode.
......@@ -112,19 +113,19 @@ type XAttrOperations interface {
// GetXAttr should read data for the given attribute into
// `dest` and return the number of bytes. If `dest` is too
// small, it should return ERANGE and the size of the attribute.
GetXAttr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno)
Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno)
// SetXAttr should store data for the given attribute. See
// setxattr(2) for information about flags.
SetXAttr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno
Setxattr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno
// RemoveXAttr should delete the given attribute.
RemoveXAttr(ctx context.Context, attr string) syscall.Errno
Removexattr(ctx context.Context, attr string) syscall.Errno
// ListXAttr should read all attributes (null terminated) into
// `dest`. If the `dest` buffer is too small, it should return
// ERANGE and the correct size.
ListXAttr(ctx context.Context, dest []byte) (uint32, syscall.Errno)
Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno)
}
// SymlinkOperations holds operations specific to symlinks.
......@@ -177,11 +178,11 @@ type FileOperations interface {
// never encounter ESPACE.
Allocate(ctx context.Context, f FileHandle, off uint64, size uint64, mode uint32) syscall.Errno
// FGetAttr is like GetAttr but provides a file handle if available.
FGetAttr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno
// FGetattr is like Getattr but provides a file handle if available.
Fgetattr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno
// FSetAttr is like SetAttr but provides a file handle if available.
FSetAttr(ctx context.Context, f FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
// FSetattr is like SetAttr but provides a file handle if available.
Fsetattr(ctx context.Context, f FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
// CopyFileRange copies data between sections of two files,
// without the data having to pass through the calling process.
......@@ -199,18 +200,18 @@ type FileOperations interface {
type LockOperations interface {
FileOperations
// GetLk returns locks that would conflict with the given
// Getlk returns locks that would conflict with the given
// input lock. If no locks conflict, the output has type
// L_UNLCK. See fcntl(2) for more information.
GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) syscall.Errno
Getlk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) syscall.Errno
// Obtain a lock on a file, or fail if the lock could not
// Setlk obtains a lock on a file, or fail if the lock could not
// obtained. See fcntl(2) for more information.
SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
Setlk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
// Obtain a lock on a file, waiting if necessary. See fcntl(2)
// Setlkw obtains a lock on a file, waiting if necessary. See fcntl(2)
// for more information.
SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
Setlkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
}
// DirStream lists directory entries.
......@@ -246,10 +247,10 @@ type DirOperations interface {
// contents. The actual reading is driven from ReadDir, so
// this method is just for performing sanity/permission
// checks.
OpenDir(ctx context.Context) syscall.Errno
Opendir(ctx context.Context) syscall.Errno
// ReadDir opens a stream of directory entries.
ReadDir(ctx context.Context) (DirStream, syscall.Errno)
Readdir(ctx context.Context) (DirStream, syscall.Errno)
}
// MutableDirOperations are operations for directories that can add or
......@@ -307,9 +308,9 @@ type FileHandle interface {
Write(ctx context.Context, data []byte, off int64) (written uint32, errno syscall.Errno)
GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) syscall.Errno
SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
Getlk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) syscall.Errno
Setlk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
Setlkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) syscall.Errno
Lseek(ctx context.Context, off uint64, whence uint32) (uint64, syscall.Errno)
......@@ -319,8 +320,8 @@ type FileHandle interface {
Release(ctx context.Context) syscall.Errno
GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno
SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno
Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno
Allocate(ctx context.Context, off uint64, size uint64, mode uint32) syscall.Errno
}
......
......@@ -320,7 +320,7 @@ func (b *rawBridge) Create(cancel <-chan struct{}, input *fuse.CreateIn, name st
out.OpenFlags = flags
var temp fuse.AttrOut
f.GetAttr(ctx, &temp)
f.Getattr(ctx, &temp)
out.Attr = temp.Attr
out.AttrValid = temp.AttrValid
out.AttrValidNsec = temp.AttrValidNsec
......@@ -360,13 +360,13 @@ func (b *rawBridge) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *
b.mu.Unlock()
}
errno := fops.FGetAttr(ctx, f, out)
errno := fops.Fgetattr(ctx, f, out)
b.setAttrTimeout(out)
out.Ino = input.NodeId
out.Mode = (out.Attr.Mode & 07777) | n.nodeAttr.Mode
return errnoToStatus(errno)
}
return errnoToStatus(n.ops.GetAttr(ctx, out))
return errnoToStatus(n.ops.Getattr(ctx, out))
}
func (b *rawBridge) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fuse.AttrOut) fuse.Status {
......@@ -379,10 +379,10 @@ func (b *rawBridge) SetAttr(cancel <-chan struct{}, in *fuse.SetAttrIn, out *fus
}
if fops, ok := n.ops.(FileOperations); ok {
return errnoToStatus(fops.FSetAttr(ctx, f, in, out))
return errnoToStatus(fops.Fsetattr(ctx, f, in, out))
}
return errnoToStatus(n.ops.SetAttr(ctx, in, out))
return errnoToStatus(n.ops.Setattr(ctx, in, out))
}
func (b *rawBridge) Rename(cancel <-chan struct{}, input *fuse.RenameIn, oldName string, newName string) fuse.Status {
......@@ -458,7 +458,7 @@ func (b *rawBridge) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr
n, _ := b.inode(header.NodeId, 0)
if xops, ok := n.ops.(XAttrOperations); ok {
nb, errno := xops.GetXAttr(&fuse.Context{Caller: header.Caller, Cancel: cancel}, attr, data)
nb, errno := xops.Getxattr(&fuse.Context{Caller: header.Caller, Cancel: cancel}, attr, data)
return nb, errnoToStatus(errno)
}
......@@ -468,7 +468,7 @@ func (b *rawBridge) GetXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr
func (b *rawBridge) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, dest []byte) (sz uint32, status fuse.Status) {
n, _ := b.inode(header.NodeId, 0)
if xops, ok := n.ops.(XAttrOperations); ok {
sz, errno := xops.ListXAttr(&fuse.Context{Caller: header.Caller, Cancel: cancel}, dest)
sz, errno := xops.Listxattr(&fuse.Context{Caller: header.Caller, Cancel: cancel}, dest)
return sz, errnoToStatus(errno)
}
return 0, fuse.ENOTSUP
......@@ -477,7 +477,7 @@ func (b *rawBridge) ListXAttr(cancel <-chan struct{}, header *fuse.InHeader, des
func (b *rawBridge) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, attr string, data []byte) fuse.Status {
n, _ := b.inode(input.NodeId, 0)
if xops, ok := n.ops.(XAttrOperations); ok {
return errnoToStatus(xops.SetXAttr(&fuse.Context{Caller: input.Caller, Cancel: cancel}, attr, data, input.Flags))
return errnoToStatus(xops.Setxattr(&fuse.Context{Caller: input.Caller, Cancel: cancel}, attr, data, input.Flags))
}
return fuse.ENOTSUP
}
......@@ -485,7 +485,7 @@ func (b *rawBridge) SetXAttr(cancel <-chan struct{}, input *fuse.SetXAttrIn, att
func (b *rawBridge) RemoveXAttr(cancel <-chan struct{}, header *fuse.InHeader, attr string) fuse.Status {
n, _ := b.inode(header.NodeId, 0)
if xops, ok := n.ops.(XAttrOperations); ok {
return errnoToStatus(xops.RemoveXAttr(&fuse.Context{Caller: header.Caller, Cancel: cancel}, attr))
return errnoToStatus(xops.Removexattr(&fuse.Context{Caller: header.Caller, Cancel: cancel}, attr))
}
return fuse.ENOTSUP
}
......@@ -536,7 +536,7 @@ func (b *rawBridge) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.Lk
n, f := b.inode(input.NodeId, input.Fh)
if lops, ok := n.ops.(LockOperations); ok {
return errnoToStatus(lops.GetLk(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Owner, &input.Lk, input.LkFlags, &out.Lk))
return errnoToStatus(lops.Getlk(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Owner, &input.Lk, input.LkFlags, &out.Lk))
}
return fuse.ENOTSUP
}
......@@ -544,14 +544,14 @@ func (b *rawBridge) GetLk(cancel <-chan struct{}, input *fuse.LkIn, out *fuse.Lk
func (b *rawBridge) SetLk(cancel <-chan struct{}, input *fuse.LkIn) fuse.Status {
n, f := b.inode(input.NodeId, input.Fh)
if lops, ok := n.ops.(LockOperations); ok {
return errnoToStatus(lops.SetLk(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Owner, &input.Lk, input.LkFlags))
return errnoToStatus(lops.Setlk(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Owner, &input.Lk, input.LkFlags))
}
return fuse.ENOTSUP
}
func (b *rawBridge) SetLkw(cancel <-chan struct{}, input *fuse.LkIn) fuse.Status {
n, f := b.inode(input.NodeId, input.Fh)
if lops, ok := n.ops.(LockOperations); ok {
return errnoToStatus(lops.SetLkw(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Owner, &input.Lk, input.LkFlags))
return errnoToStatus(lops.Setlkw(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Owner, &input.Lk, input.LkFlags))
}
return fuse.ENOTSUP
}
......@@ -625,7 +625,7 @@ func (b *rawBridge) Fallocate(cancel <-chan struct{}, input *fuse.FallocateIn) f
func (b *rawBridge) OpenDir(cancel <-chan struct{}, input *fuse.OpenIn, out *fuse.OpenOut) fuse.Status {
n, _ := b.inode(input.NodeId, 0)
errno := n.dirOps().OpenDir(&fuse.Context{Caller: input.Caller, Cancel: cancel})
errno := n.dirOps().Opendir(&fuse.Context{Caller: input.Caller, Cancel: cancel})
if errno != 0 {
return errnoToStatus(errno)
}
......@@ -641,7 +641,7 @@ func (b *rawBridge) getStream(cancel <-chan struct{}, input *fuse.ReadIn, inode
f.dirStream.Close()
f.dirStream = nil
}
str, errno := inode.dirOps().ReadDir(&fuse.Context{Caller: input.Caller, Cancel: cancel})
str, errno := inode.dirOps().Readdir(&fuse.Context{Caller: input.Caller, Cancel: cancel})
if errno != 0 {
return errno
}
......@@ -737,7 +737,7 @@ func (b *rawBridge) FsyncDir(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.S
func (b *rawBridge) StatFs(cancel <-chan struct{}, input *fuse.InHeader, out *fuse.StatfsOut) fuse.Status {
n, _ := b.inode(input.NodeId, 0)
return errnoToStatus(n.ops.StatFs(&fuse.Context{Caller: input.Caller, Cancel: cancel}, out))
return errnoToStatus(n.ops.Statfs(&fuse.Context{Caller: input.Caller, Cancel: cancel}, out))
}
func (b *rawBridge) Init(s *fuse.Server) {
......
......@@ -44,7 +44,7 @@ func (f *keepCacheFile) Open(ctx context.Context, flags uint32) (FileHandle, uin
return nil, fl, OK
}
func (f *keepCacheFile) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
func (f *keepCacheFile) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
f.mu.Lock()
defer f.mu.Unlock()
out.Size = uint64(len(f.content))
......
......@@ -24,7 +24,9 @@ type OperationStubs struct {
}
// check that we have implemented all interface methods
var _ Operations = &OperationStubs{}
var _ DirOperations = &OperationStubs{}
var _ FileOperations = &OperationStubs{}
var _ LockOperations = &OperationStubs{}
func (n *OperationStubs) inode() *Inode {
return &n.inode_
......@@ -50,7 +52,7 @@ func (n *OperationStubs) Inode() *Inode {
// StatFs zeroes the out argument and returns OK. This is because OSX
// filesystems must define this, or the mount will not work.
func (n *OperationStubs) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
func (n *OperationStubs) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
// this should be defined on OSX, or the FS won't mount
*out = fuse.StatfsOut{}
return OK
......@@ -61,12 +63,12 @@ func (n *OperationStubs) OnAdd(ctx context.Context) {
}
// GetAttr zeroes out argument and returns OK.
func (n *OperationStubs) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
func (n *OperationStubs) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
*out = fuse.AttrOut{}
return OK
}
func (n *OperationStubs) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
func (n *OperationStubs) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
return syscall.EROFS
}
......@@ -79,7 +81,7 @@ func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno
}
var out fuse.AttrOut
if s := n.inode().Operations().GetAttr(ctx, &out); s != 0 {
if s := n.inode().Operations().Getattr(ctx, &out); s != 0 {
return s
}
......@@ -91,12 +93,12 @@ func (n *OperationStubs) Access(ctx context.Context, mask uint32) syscall.Errno
// FSetAttr delegates to the FileHandle's if f is not nil, or else to the
// Inode's SetAttr method.
func (n *OperationStubs) FSetAttr(ctx context.Context, f FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
func (n *OperationStubs) Fsetattr(ctx context.Context, f FileHandle, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
if f != nil {
return f.SetAttr(ctx, in, out)
return f.Setattr(ctx, in, out)
}
return n.inode_.Operations().SetAttr(ctx, in, out)
return n.inode_.Operations().Setattr(ctx, in, out)
}
// The Lookup method on the OperationStubs type looks for an
......@@ -108,7 +110,7 @@ func (n *OperationStubs) Lookup(ctx context.Context, name string, out *fuse.Entr
}
var a fuse.AttrOut
errno := ch.Operations().GetAttr(ctx, &a)
errno := ch.Operations().Getattr(ctx, &a)
out.Attr = a.Attr
return ch, errno
}
......@@ -134,12 +136,12 @@ func (n *OperationStubs) Unlink(ctx context.Context, name string) syscall.Errno
}
// The default OpenDir always succeeds
func (n *OperationStubs) OpenDir(ctx context.Context) syscall.Errno {
func (n *OperationStubs) Opendir(ctx context.Context) syscall.Errno {
return OK
}
// The default ReadDir returns the list of children from the tree
func (n *OperationStubs) ReadDir(ctx context.Context) (DirStream, syscall.Errno) {
func (n *OperationStubs) Readdir(ctx context.Context) (DirStream, syscall.Errno) {
r := []fuse.DirEntry{}
for k, ch := range n.inode().Children() {
r = append(r, fuse.DirEntry{Mode: ch.Mode(),
......@@ -208,28 +210,28 @@ func (n *OperationStubs) Lseek(ctx context.Context, f FileHandle, off uint64, wh
return 0, syscall.ENOTSUP
}
// GetLk delegates to the FileHandlef
func (n *OperationStubs) GetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
// Getlk delegates to the FileHandlef
func (n *OperationStubs) Getlk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
if f != nil {
return f.GetLk(ctx, owner, lk, flags, out)
return f.Getlk(ctx, owner, lk, flags, out)
}
return syscall.ENOTSUP
}
// SetLk delegates to the FileHandle
func (n *OperationStubs) SetLk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
func (n *OperationStubs) Setlk(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
if f != nil {
return f.SetLk(ctx, owner, lk, flags)
return f.Setlk(ctx, owner, lk, flags)
}
return syscall.ENOTSUP
}
// SetLkw delegates to the FileHandle
func (n *OperationStubs) SetLkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
func (n *OperationStubs) Setlkw(ctx context.Context, f FileHandle, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
if f != nil {
return f.SetLkw(ctx, owner, lk, flags)
return f.Setlkw(ctx, owner, lk, flags)
}
return syscall.ENOTSUP
......@@ -261,13 +263,13 @@ func (n *OperationStubs) Allocate(ctx context.Context, f FileHandle, off uint64,
return syscall.ENOTSUP
}
// FGetAttr delegates to the FileHandle's if f is not nil, or else to the
// Fgetattr delegates to the FileHandle's if f is not nil, or else to the
// Inode's GetAttr method.
func (n *OperationStubs) FGetAttr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno {
func (n *OperationStubs) Fgetattr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno {
if f != nil {
f.GetAttr(ctx, out)
f.Getattr(ctx, out)
}
return n.inode_.ops.GetAttr(ctx, out)
return n.inode_.ops.Getattr(ctx, out)
}
// Open returns ENOTSUP
......@@ -320,15 +322,15 @@ func (f *FileHandleStubs) Write(ctx context.Context, data []byte, off int64) (wr
return 0, syscall.ENOTSUP
}
func (f *FileHandleStubs) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
func (f *FileHandleStubs) Getlk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
return syscall.ENOTSUP
}
func (f *FileHandleStubs) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
func (f *FileHandleStubs) Setlk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
return syscall.ENOTSUP
}
func (f *FileHandleStubs) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
func (f *FileHandleStubs) Setlkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
return syscall.ENOTSUP
}
......@@ -340,11 +342,11 @@ func (f *FileHandleStubs) Release(ctx context.Context) syscall.Errno {
return syscall.ENOTSUP
}
func (f *FileHandleStubs) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
func (f *FileHandleStubs) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
return syscall.ENOTSUP
}
func (f *FileHandleStubs) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
func (f *FileHandleStubs) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
return syscall.ENOTSUP
}
......
......@@ -64,7 +64,7 @@ const (
_OFD_SETLKW = 38
)
func (f *loopbackFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
func (f *loopbackFile) Getlk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (errno syscall.Errno) {
flk := syscall.Flock_t{}
lk.ToFlockT(&flk)
errno = ToErrno(syscall.FcntlFlock(uintptr(f.fd), _OFD_GETLK, &flk))
......@@ -72,11 +72,11 @@ func (f *loopbackFile) GetLk(ctx context.Context, owner uint64, lk *fuse.FileLoc
return
}
func (f *loopbackFile) SetLk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
func (f *loopbackFile) Setlk(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
return f.setLock(ctx, owner, lk, flags, false)
}
func (f *loopbackFile) SetLkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
func (f *loopbackFile) Setlkw(ctx context.Context, owner uint64, lk *fuse.FileLock, flags uint32) (errno syscall.Errno) {
return f.setLock(ctx, owner, lk, flags, true)
}
......@@ -110,12 +110,12 @@ func (f *loopbackFile) setLock(ctx context.Context, owner uint64, lk *fuse.FileL
}
}
func (f *loopbackFile) SetAttr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
func (f *loopbackFile) Setattr(ctx context.Context, in *fuse.SetAttrIn, out *fuse.AttrOut) syscall.Errno {
if errno := f.setAttr(ctx, in); errno != 0 {
return errno
}
return f.GetAttr(ctx, out)
return f.Getattr(ctx, out)
}
func (f *loopbackFile) setAttr(ctx context.Context, in *fuse.SetAttrIn) syscall.Errno {
......@@ -172,7 +172,7 @@ func (f *loopbackFile) setAttr(ctx context.Context, in *fuse.SetAttrIn) syscall.
return OK
}
func (f *loopbackFile) GetAttr(ctx context.Context, a *fuse.AttrOut) syscall.Errno {
func (f *loopbackFile) Getattr(ctx context.Context, a *fuse.AttrOut) syscall.Errno {
st := syscall.Stat_t{}
err := syscall.Fstat(f.fd, &st)
if err != nil {
......
......@@ -6,6 +6,7 @@ package nodefs
import (
"context"
"log"
"os"
"path/filepath"
"syscall"
......@@ -20,7 +21,7 @@ type loopbackRoot struct {
rootDev uint64
}
func (n *loopbackNode) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
func (n *loopbackNode) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
s := syscall.Statfs_t{}
err := syscall.Statfs(n.path(), &s)
if err != nil {
......@@ -30,7 +31,8 @@ func (n *loopbackNode) StatFs(ctx context.Context, out *fuse.StatfsOut) syscall.
return OK
}
func (n *loopbackRoot) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
func (n *loopbackRoot) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
log.Println("getattr")
st := syscall.Stat_t{}
err := syscall.Stat(n.rootPath, &st)
if err != nil {
......@@ -243,7 +245,7 @@ func (n *loopbackNode) Open(ctx context.Context, flags uint32) (fh FileHandle, f
return lf, 0, 0
}
func (n *loopbackNode) OpenDir(ctx context.Context) syscall.Errno {
func (n *loopbackNode) Opendir(ctx context.Context) syscall.Errno {
fd, err := syscall.Open(n.path(), syscall.O_DIRECTORY, 0755)
if err != nil {
return ToErrno(err)
......@@ -252,13 +254,13 @@ func (n *loopbackNode) OpenDir(ctx context.Context) syscall.Errno {
return OK
}
func (n *loopbackNode) ReadDir(ctx context.Context) (DirStream, syscall.Errno) {
func (n *loopbackNode) Readdir(ctx context.Context) (DirStream, syscall.Errno) {
return NewLoopbackDirStream(n.path())
}
func (n *loopbackNode) FGetAttr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno {
func (n *loopbackNode) Fgetattr(ctx context.Context, f FileHandle, out *fuse.AttrOut) syscall.Errno {
if f != nil {
return f.GetAttr(ctx, out)
return f.Getattr(ctx, out)
}
p := n.path()
......
......@@ -11,22 +11,22 @@ import (
"golang.org/x/sys/unix"
)
func (n *loopbackNode) GetXAttr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno) {
func (n *loopbackNode) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno) {
sz, err := syscall.Getxattr(n.path(), attr, dest)
return uint32(sz), ToErrno(err)
}
func (n *loopbackNode) SetXAttr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno {
func (n *loopbackNode) Setxattr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno {
err := syscall.Setxattr(n.path(), attr, data, int(flags))
return ToErrno(err)
}
func (n *loopbackNode) RemoveXAttr(ctx context.Context, attr string) syscall.Errno {
func (n *loopbackNode) Removexattr(ctx context.Context, attr string) syscall.Errno {
err := syscall.Removexattr(n.path(), attr)
return ToErrno(err)
}
func (n *loopbackNode) ListXAttr(ctx context.Context, dest []byte) (uint32, syscall.Errno) {
func (n *loopbackNode) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno) {
sz, err := syscall.Listxattr(n.path(), dest)
return uint32(sz), ToErrno(err)
}
......
......@@ -142,7 +142,7 @@ func TestFileBasic(t *testing.T) {
if got, err := ioutil.ReadFile(fn); err != nil {
t.Fatalf("ReadFile: %v", err)
} else if bytes.Compare(got, content) != 0 {
t.Errorf("got %q, want %q", got, content)
t.Errorf("ReadFile: got %q, want %q", got, content)
}
f, err := os.Open(fn)
......
......@@ -115,9 +115,9 @@ type zipFile struct {
var _ = (FileOperations)((*zipFile)(nil))
// GetAttr sets the minimum, which is the size. A more full-featured
// Getattr sets the minimum, which is the size. A more full-featured
// FS would also set timestamps and permissions.
func (zf *zipFile) GetAttr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
func (zf *zipFile) Getattr(ctx context.Context, out *fuse.AttrOut) syscall.Errno {
out.Size = zf.file.UncompressedSize64
return OK
}
......
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