fs

package
v0.0.0-...-da19d2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugServer

func DebugServer(w http.ResponseWriter, req *http.Request)

DebugServer hello world, the web server

func InitInode

func InitInode(inode uint64)

InitInode inode

func NewConfig

func NewConfig(user, password string, privateKeyPath string) *ssh.ClientConfig

NewConfig creates a new config

func NewSftp

func NewSftp(config *ssh.ClientConfig, server string) (*sftp.Client, error)

NewSftp sftp

func PublicKeyFile

func PublicKeyFile(file string) (ssh.AuthMethod, error)

PublicKeyFile ssh

Types

type Dir

type Dir struct {
	*Node
	Files *[]*File
	Dirs  *[]*Dir
	sync.Mutex
}

Dir implements both Node and Handle

func (*Dir) Attr

func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error

Attr sets attrs on the given fuse.Attr

func (*Dir) Create

func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error)

Create Dir

func (d *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (fs.Node, error)

Link Dir

func (*Dir) Lookup

func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error)

Lookup looks up a path

func (*Dir) Mkdir

func (d *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error)

Mkdir Dir

func (*Dir) Open

func (d *Dir) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)

Open Dir

func (*Dir) ReadDirAll

func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)

ReadDirAll returns a list of sshfs

func (*Dir) Release

func (d *Dir) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release Dir

func (*Dir) Remove

func (d *Dir) Remove(ctx context.Context, req *fuse.RemoveRequest) error

Remove Dir

func (*Dir) Rename

func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error

Rename Dir

func (*Dir) Setattr

func (d *Dir) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error

Setattr Dir

func (d *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) (fs.Node, error)

Symlink Dir

type File

type File struct {
	*Node

	sync.Mutex
	// contains filtered or unexported fields
}

File Node

func (*File) Attr

func (f *File) Attr(ctx context.Context, a *fuse.Attr) error

Attr File

func (*File) Flush

func (f *File) Flush(ctx context.Context, req *fuse.FlushRequest) error

Flush File

func (*File) Fsync

func (f *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error

Fsync File

func (*File) Open

func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)

Open File

func (*File) Read

func (f *File) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error

Read File

func (*File) Release

func (f *File) Release(ctx context.Context, req *fuse.ReleaseRequest) error

Release File

func (*File) Setattr

func (f *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error

Setattr File

func (*File) Write

func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error

Write File

type Node

type Node struct {
	*File
	*Dir
	// contains filtered or unexported fields
}

Node 文件系统节点,用于描述目录或者文件的文件系统属性

func GetNodeByID

func GetNodeByID(inode uint64) (*Node, bool)

GetNodeByID 根据 id 获取 Node 对象

func NewNode

func NewNode(sftp *sftp.Client, inode uint64, parent *Node, name string, isdir, isroot bool) *Node

NewNode 新增节点

func NewRoot

func NewRoot(root string, c *sftp.Client) *Node

NewRoot creates a new root and returns it

func (*Node) GetChild

func (n *Node) GetChild(name string) (*Node, bool)

GetChild 根据名称获取子 Node

func (*Node) GetInode

func (n *Node) GetInode() uint64

GetInode 获取节点 inode

func (*Node) IsDir

func (n *Node) IsDir() bool

IsDir 判断是否目录

func (*Node) IsRoot

func (n *Node) IsRoot() bool

IsRoot 判断是否根目录

func (*Node) LocalPath

func (n *Node) LocalPath() string

LocalPath 获取本地路径

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

MarshalJSON 自定义序列化

func (*Node) Path

func (n *Node) Path() string

Path 获取节点绝对路径 从当前节点开始,一直向父节点循环

func (*Node) Remove

func (n *Node) Remove()

Remove 删除 Node

func (*Node) Rename

func (n *Node) Rename(onode, ndir *Node, nname string)

Rename Node

func (*Node) Save

func (n *Node) Save()

Save 缓存 FsNode

type SSHFS

type SSHFS struct {
	*sftp.Client
	// contains filtered or unexported fields
}

SSHFS is a ssh filesystem

func New

func New(config *ssh.ClientConfig, mountpoint, server, root string) (*SSHFS, error)

New returns a new SSHFS

func (*SSHFS) Mount

func (v *SSHFS) Mount() error

Mount the FS at the given mountpoint

func (*SSHFS) Root

func (v *SSHFS) Root() (fs.Node, error)

Root returns the struct that does the actual work

func (*SSHFS) Statfs

func (v *SSHFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error

Statfs sshfs

func (*SSHFS) Unmount

func (v *SSHFS) Unmount() error

Unmount the FS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL