In order to figure out how the interface methods relate to various command line tools (stat, ls, touch, echo for all the various file manipulation), I tried to use the following code to return custom errors... Instead I am getting this error for almost all operations I can try: ls: cannot access 'mnt': Input/output error
note: pay attention to some of the comments as they explain the different ways I've tried to use this library.
package main
import (
"context"
"errors"
"github.com/dgraph-io/badger"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseops"
"github.com/jacobsa/fuse/fuseutil"
)
// NOTE:
// requires osxfuse to be installed for MacOS
func check(err error) {
if err != nil {
panic(err)
}
}
type DbFs struct {
// tried with and without this type
// fuseutil.NotImplementedFileSystem
}
func (d *DbFs) StatFS(ctx context.Context, op *fuseops.StatFSOp) error {
return errors.New("unable to perform stat, stat not yet impl")
}
func (d *DbFs) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) error {
return errors.New("unable to perform lookup, lookup not yet impl")
}
// This method seems to cause the error, if this doesn't exist
// "function not implemented" is the error
func (d *DbFs) GetInodeAttributes(ctx context.Context, op *fuseops.GetInodeAttributesOp) error {
// tried an failed
// op.AttributesExpiration = time.Now().Add(time.Hour * 10)
// op.Attributes = fuseops.InodeAttributes{
// Nlink: 1,
// Mode: 0777,
// Size: 0,
// }
return errors.New("unable to perform getinode, getinode not yet impl")
}
func (d *DbFs) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) error {
return errors.New("unable to perform setInode, setInode not yet impl")
}
func (d *DbFs) ForgetInode(ctx context.Context, op *fuseops.ForgetInodeOp) error {
return errors.New("unable to perform mkdir, mkdir not yet impl")
}
func (d *DbFs) MkDir(ctx context.Context, op *fuseops.MkDirOp) error {
return errors.New("unable to perform mkdir, mkdir not yet impl")
}
func (d *DbFs) MkNode(ctx context.Context, op *fuseops.MkNodeOp) error {
return errors.New("unable to perform mknode, mknode not yet impl")
}
func (d *DbFs) CreateFile(ctx context.Context, op *fuseops.CreateFileOp) error {
return errors.New("unable to perform createfile, createfile not yet impl")
}
func (d *DbFs) CreateSymlink(ctx context.Context, op *fuseops.CreateSymlinkOp) error {
return errors.New("unable to perform createsymlink, createsymlink not yet impl")
}
func (d *DbFs) Rename(ctx context.Context, op *fuseops.RenameOp) error {
return errors.New("unable to perform rename, rename not yet impl")
}
func (d *DbFs) RmDir(ctx context.Context, op *fuseops.RmDirOp) error {
return errors.New("unable to perform rmDir, rmDir not yet impl")
}
func (d *DbFs) Unlink(ctx context.Context, op *fuseops.UnlinkOp) error {
return errors.New("unable to perform unlink, unlink not yet impl")
}
func (d *DbFs) OpenDir(ctx context.Context, op *fuseops.OpenDirOp) error {
return errors.New("unable to perform opendir, open not yet impl")
}
func (d *DbFs) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) error {
return errors.New("unable to perform readdir, readdir not yet impl")
}
func (d *DbFs) ReleaseDirHandle(ctx context.Context, op *fuseops.ReleaseDirHandleOp) error {
return errors.New("unable to perform releasedirhandle, releasedirhandle not yet impl")
}
func (d *DbFs) OpenFile(ctx context.Context, op *fuseops.OpenFileOp) error {
return errors.New("unable to perform openfile, openfile not yet impl")
}
func (d *DbFs) ReadFile(ctx context.Context, op *fuseops.ReadFileOp) error {
return errors.New("unable to perform readfile, readfile not yet impl")
}
func (d *DbFs) WriteFile(ctx context.Context, op *fuseops.WriteFileOp) error {
return errors.New("unable to perform writefile, writefile not yet impl")
}
func (d *DbFs) SyncFile(ctx context.Context, op *fuseops.SyncFileOp) error {
return errors.New("unable to perform getxattr, getxattr not yet impl")
}
func (d *DbFs) FlushFile(ctx context.Context, op *fuseops.FlushFileOp) error {
return errors.New("unable to perform getxattr, getxattr not yet impl")
}
func (d *DbFs) ReleaseFileHandle(ctx context.Context, op *fuseops.ReleaseFileHandleOp) error {
return errors.New("unable to perform getxattr, getxattr not yet impl")
}
func (d *DbFs) ReadSymlink(ctx context.Context, op *fuseops.ReadSymlinkOp) error {
return errors.New("unable to perform getxattr, getxattr not yet impl")
}
func (d *DbFs) RemoveXattr(ctx context.Context, op *fuseops.RemoveXattrOp) error {
return errors.New("unable to perform getxattr, getxattr not yet impl")
}
func (d *DbFs) GetXattr(ctx context.Context, op *fuseops.GetXattrOp) error {
return errors.New("unable to perform getxattr, getxattr not yet impl")
}
func (d *DbFs) ListXattr(ctx context.Context, op *fuseops.ListXattrOp) error {
return errors.New("unable to perform listxattr, listxattr not yet impl")
}
func (d *DbFs) SetXattr(ctx context.Context, op *fuseops.SetXattrOp) error {
return errors.New("unable to perform setxattr, setxattr not yet impl")
}
func (d *DbFs) Destroy() {}
func main() {
dstore := "./atfs"
opts := badger.DefaultOptions
opts.Dir = dstore
opts.ValueDir = dstore
db, err := badger.Open(opts)
defer db.Close()
check(err)
fs := &DbFs{}
server := fuseutil.NewFileSystemServer(fs)
mfs, err := fuse.Mount("./mnt", server, &fuse.MountConfig{})
check(err)
check(mfs.Join(context.Background()))
}