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

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

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