You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
608 B

3 years ago
  1. package mount
  2. import (
  3. "context"
  4. "syscall"
  5. "github.com/hanwen/go-fuse/v2/fs"
  6. "github.com/hanwen/go-fuse/v2/fuse"
  7. )
  8. type WeedFS struct {
  9. fs.Inode
  10. }
  11. func (r *WeedFS) OnAdd(ctx context.Context) {
  12. ch := r.NewPersistentInode(
  13. ctx, &fs.MemRegularFile{
  14. Data: []byte("file.txt"),
  15. Attr: fuse.Attr{
  16. Mode: 0644,
  17. },
  18. }, fs.StableAttr{Ino: 2})
  19. r.AddChild("file.txt", ch, false)
  20. }
  21. func (r *WeedFS) Getattr(ctx context.Context, fh fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
  22. out.Mode = 0755
  23. return 0
  24. }
  25. var _ = (fs.NodeGetattrer)((*WeedFS)(nil))
  26. var _ = (fs.NodeOnAdder)((*WeedFS)(nil))