fs

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 0 means not use data cache
	BlockSize       = 0
	MaxReadAheadNum = 0
	DataCacheExpire = 0 * time.Second
	DataCachePath   = "/var/cache/pfs_data_cache"

	Driver           = meta.MemDriver
	MetaCacheExpire  = 0 * time.Second
	EntryCacheExpire = 0 * time.Second
	PathCacheExpire  = 0 * time.Second
	MetaCachePath    = "/var/cache/pfs_meta_cache"
)

fs server not use cache

Functions

func NewMetaCache

func NewMetaCache(entryCacheSize, attrCacheSize int, entryExpire int, attrExpire int) *metaCache

func SetDataCache

func SetDataCache(config cache.Config)

func SetLinkMetaDirPrefix

func SetLinkMetaDirPrefix(dirPrefix string)

func SetMetaCache

func SetMetaCache(config meta.Config)

func SetPFSServer

func SetPFSServer(server string)

pfsServer服务地址

Types

type DirEntry

type DirEntry struct {
	// contains filtered or unexported fields
}

func NewDirEntry

func NewDirEntry(dir base.DirEntry, info FileInfo) DirEntry

func (*DirEntry) Info

func (d *DirEntry) Info() (os.FileInfo, error)

func (*DirEntry) IsDir

func (d *DirEntry) IsDir() bool

func (*DirEntry) Name

func (d *DirEntry) Name() string

func (*DirEntry) Type

func (d *DirEntry) Type() os.FileMode

type FSClient

type FSClient interface {
	Create(path string) (io.WriteCloser, error)
	Open(path string) (io.ReadCloser, error)
	CreateFile(path string, content []byte) (int, error)
	SaveFile(file io.Reader, destPath, fileName string) error
	Remove(path string) error
	RemoveAll(path string) error
	IsDir(path string) (bool, error)
	Exist(path string) (bool, error)
	IsEmptyDir(path string) (bool, error)
	Mkdir(path string, perm os.FileMode) error
	MkdirAll(path string, perm os.FileMode) error
	ListDir(path string) ([]os.FileInfo, error)
	Readdirnames(path string, n int) ([]string, error)
	Rename(srcPath, dstPath string) error
	Copy(srcPath, dstPath string) error
	Size(path string) (int64, error)
	Chmod(path string, fm os.FileMode) error
	Chown(name string, uid, gid int) error
	Walk(root string, walkFn filepath.WalkFunc) error
	Stat(path string) (os.FileInfo, error)
}

func NewFSClient

func NewFSClient(fsMeta common.FSMeta, links map[string]common.FSMeta) (FSClient, error)

func NewFSClientWithFsID

func NewFSClientWithFsID(fsID string) (FSClient, error)

func NewFSClientWithServer

func NewFSClientWithServer(server, fsID string) (FSClient, error)

type File

type File struct {
	// contains filtered or unexported fields
}

参考os.file对外的接口实现, 部分未实现

func NewPFILE

func NewPFILE(fh uint64, inode vfs.Ino, attr FileInfo, fs *FileSystem) File

func (*File) Chmod

func (f *File) Chmod(mode os.FileMode) error

func (*File) Chown

func (f *File) Chown(uid, gid int) error

func (*File) Close

func (f *File) Close() error

func (*File) Fd

func (f *File) Fd() uintptr

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(b []byte) (int, error)

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (int, error)

func (*File) ReadDir

func (f *File) ReadDir(n int) ([]os.DirEntry, error)

func (*File) Readdir

func (f *File) Readdir(n int) ([]os.FileInfo, error)

func (*File) Readdirnames

func (f *File) Readdirnames(n int) ([]string, error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (ret int64, err error)

seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (*File) SetDeadline

func (f *File) SetDeadline(t time.Time) error

func (*File) SetReadDeadline

func (f *File) SetReadDeadline(t time.Time) error

func (*File) SetWriteDeadline

func (f *File) SetWriteDeadline(t time.Time) error

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

func (*File) Sync

func (f *File) Sync() error

func (*File) SyscallConn

func (f *File) SyscallConn() (syscall.RawConn, error)

func (*File) Truncate

func (f *File) Truncate(size int64) error

func (*File) Write

func (f *File) Write(b []byte) (int, error)

func (*File) WriteAt

func (f *File) WriteAt(b []byte, off int64) (int, error)

func (*File) WriteString

func (f *File) WriteString(s string) (n int, err error)

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

func NewFileInfoForCreate

func NewFileInfoForCreate(path string, mode os.FileMode) FileInfo

func (*FileInfo) IsDir

func (i *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (i *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (i *FileInfo) Mode() os.FileMode

func (*FileInfo) Name

func (i *FileInfo) Name() string

func (*FileInfo) Size

func (i *FileInfo) Size() int64

func (*FileInfo) String

func (i *FileInfo) String() string

func (*FileInfo) Sys

func (i *FileInfo) Sys() interface{}

type FileSystem

type FileSystem struct {
	// contains filtered or unexported fields
}

func NewFileSystem

func NewFileSystem(fsMeta common.FSMeta, links map[string]common.FSMeta, skipSub bool, hasCache bool,
	linkMetaDirPrefix string, config *vfs.Config) (*FileSystem, error)

entryExpire 记录path对应的ino信息,一般不会修改,因此可以不设置过期时间(entryExpire = 0)。 attrExpire 记录ino对应节点的attr属性,包括mode、uid、gid和mtime等信息,文件修改时会改变。

func (*FileSystem) Chmod

func (fs *FileSystem) Chmod(name string, mode os.FileMode) error

func (*FileSystem) Chown

func (fs *FileSystem) Chown(name string, uid, gid int) error

func (*FileSystem) Create

func (fs *FileSystem) Create(name string, flags uint32, mode uint32) (*File, error)

func (*FileSystem) Mkdir

func (fs *FileSystem) Mkdir(name string, mode os.FileMode) error

func (*FileSystem) Open

func (fs *FileSystem) Open(path_ string) (*File, error)

func (*FileSystem) Rename

func (fs *FileSystem) Rename(oldPath string, newPath string) error

func (*FileSystem) Rmdir

func (fs *FileSystem) Rmdir(name string) error

func (*FileSystem) Stat

func (fs *FileSystem) Stat(path_ string) (os.FileInfo, error)
func (fs *FileSystem) Unlink(name string) error

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

func (*MockClient) Chmod

func (c *MockClient) Chmod(path string, fm os.FileMode) error

func (*MockClient) Chown added in v0.14.5

func (c *MockClient) Chown(name string, uid, gid int) error

func (*MockClient) Copy

func (c *MockClient) Copy(srcPath, dstPath string) error

func (*MockClient) Create

func (c *MockClient) Create(path string) (io.WriteCloser, error)

func (*MockClient) CreateFile

func (c *MockClient) CreateFile(path string, content []byte) (int, error)

func (*MockClient) Exist

func (c *MockClient) Exist(path string) (bool, error)

func (*MockClient) IsDir

func (c *MockClient) IsDir(path string) (bool, error)

func (*MockClient) IsEmptyDir

func (c *MockClient) IsEmptyDir(path string) (bool, error)

func (*MockClient) ListDir

func (c *MockClient) ListDir(path string) ([]os.FileInfo, error)

func (*MockClient) Mkdir

func (c *MockClient) Mkdir(path string, perm os.FileMode) error

func (*MockClient) MkdirAll

func (c *MockClient) MkdirAll(path string, perm os.FileMode) error

func (*MockClient) Open

func (c *MockClient) Open(path string) (io.ReadCloser, error)

func (*MockClient) Readdirnames

func (c *MockClient) Readdirnames(path string, n int) ([]string, error)

func (*MockClient) Remove

func (c *MockClient) Remove(path string) error

func (*MockClient) RemoveAll

func (c *MockClient) RemoveAll(path string) error

func (*MockClient) Rename

func (c *MockClient) Rename(srcPath, dstPath string) error

func (*MockClient) SaveFile

func (c *MockClient) SaveFile(file io.Reader, destPath, fileName string) error

func (*MockClient) Size

func (c *MockClient) Size(path string) (int64, error)

func (*MockClient) Stat

func (c *MockClient) Stat(path string) (os.FileInfo, error)

func (*MockClient) Walk

func (c *MockClient) Walk(root string, walkFn filepath.WalkFunc) error

type PFSClient

type PFSClient struct {
	// contains filtered or unexported fields
}

func NewFSClientForTest

func NewFSClientForTest(fsMeta fsCommon.FSMeta) (*PFSClient, error)

func NewPFSClient

func NewPFSClient(fsMeta fsCommon.FSMeta, links map[string]fsCommon.FSMeta) (*PFSClient, error)

func (*PFSClient) Chmod

func (c *PFSClient) Chmod(path string, fm os.FileMode) error

func (*PFSClient) Chown added in v0.14.5

func (c *PFSClient) Chown(name string, uid, gid int) error

func (*PFSClient) Copy

func (c *PFSClient) Copy(srcPath, dstPath string) error

func (*PFSClient) Create

func (c *PFSClient) Create(path string) (io.WriteCloser, error)

func (*PFSClient) CreateFile

func (c *PFSClient) CreateFile(path string, content []byte) (int, error)

func (*PFSClient) Exist

func (c *PFSClient) Exist(path string) (bool, error)

func (*PFSClient) IsDir

func (c *PFSClient) IsDir(path string) (bool, error)

func (*PFSClient) IsEmptyDir

func (c *PFSClient) IsEmptyDir(path string) (bool, error)

func (*PFSClient) ListDir

func (c *PFSClient) ListDir(path string) ([]os.FileInfo, error)

func (*PFSClient) Mkdir

func (c *PFSClient) Mkdir(path string, perm os.FileMode) error

func (*PFSClient) MkdirAll

func (c *PFSClient) MkdirAll(path string, perm os.FileMode) error

func (*PFSClient) Open

func (c *PFSClient) Open(path string) (io.ReadCloser, error)

func (*PFSClient) Readdirnames

func (c *PFSClient) Readdirnames(path string, n int) ([]string, error)

func (*PFSClient) Remove

func (c *PFSClient) Remove(path string) error

func (*PFSClient) RemoveAll

func (c *PFSClient) RemoveAll(path string) error

func (*PFSClient) Rename

func (c *PFSClient) Rename(srcPath, dstPath string) error

func (*PFSClient) SaveFile

func (c *PFSClient) SaveFile(file io.Reader, destPath, fileName string) error

func (*PFSClient) Size

func (c *PFSClient) Size(path string) (int64, error)

func (*PFSClient) Stat

func (c *PFSClient) Stat(path string) (os.FileInfo, error)

func (*PFSClient) Walk

func (c *PFSClient) Walk(root string, walkFn filepath.WalkFunc) error

Jump to

Keyboard shortcuts

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