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

node.go 2.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //go:build linux || (darwin && amd64)
  2. package fuse
  3. import (
  4. "context"
  5. "syscall"
  6. fusefs "github.com/hanwen/go-fuse/v2/fs"
  7. "github.com/hanwen/go-fuse/v2/fuse"
  8. )
  9. type NodeBase struct {
  10. fusefs.Inode
  11. fs *Fuse
  12. }
  13. // Statfs implements statistics for the filesystem that holds this
  14. // Inode. If not defined, the `out` argument will zeroed with an OK
  15. // result. This is because OSX filesystems must Statfs, or the mount
  16. // will not work.
  17. func (n *NodeBase) Statfs(ctx context.Context, out *fuse.StatfsOut) syscall.Errno {
  18. const blockSize = 4096
  19. stats := n.fs.fs.Stats()
  20. // total, _, free := n.fsys.fs.Statfs()
  21. out.Blocks = uint64(stats.TotalDataBytes) / blockSize // Total data blocks in file system.
  22. out.Bfree = 1e9 // Free blocks in file system.
  23. out.Bavail = out.Bfree // Free blocks in file system if you're not root.
  24. out.Files = uint64(stats.TotalObjectCount) // Total files in file system.
  25. out.Ffree = 1e9 // Free files in file system.
  26. out.Bsize = blockSize // Block size
  27. out.NameLen = 255 // Maximum file name length?
  28. out.Frsize = blockSize // Fragment size, smallest addressable data size in the file system.
  29. return 0
  30. }
  31. // Getxattr should read data for the given attribute into
  32. // `dest` and return the number of bytes. If `dest` is too
  33. // small, it should return ERANGE and the size of the attribute.
  34. // If not defined, Getxattr will return ENOATTR.
  35. func (n *NodeBase) Getxattr(ctx context.Context, attr string, dest []byte) (uint32, syscall.Errno) {
  36. return 0, syscall.ENOSYS // we never implement this
  37. }
  38. var _ fusefs.NodeGetxattrer = (*NodeBase)(nil)
  39. // Setxattr should store data for the given attribute. See
  40. // setxattr(2) for information about flags.
  41. // If not defined, Setxattr will return ENOATTR.
  42. func (n *NodeBase) Setxattr(ctx context.Context, attr string, data []byte, flags uint32) syscall.Errno {
  43. return syscall.ENOSYS // we never implement this
  44. }
  45. var _ fusefs.NodeSetxattrer = (*NodeBase)(nil)
  46. // Removexattr should delete the given attribute.
  47. // If not defined, Removexattr will return ENOATTR.
  48. func (n *NodeBase) Removexattr(ctx context.Context, attr string) syscall.Errno {
  49. return syscall.ENOSYS // we never implement this
  50. }
  51. var _ fusefs.NodeRemovexattrer = (*NodeBase)(nil)
  52. // Listxattr should read all attributes (null terminated) into
  53. // `dest`. If the `dest` buffer is too small, it should return ERANGE
  54. // and the correct size. If not defined, return an empty list and
  55. // success.
  56. func (n *NodeBase) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno) {
  57. return 0, syscall.ENOSYS // we never implement this
  58. }
  59. var _ fusefs.NodeListxattrer = (*NodeBase)(nil)

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。