package nfsfs import ( "io" "io/fs" "os" "path/filepath" "strings" "time" "imuslab.com/arozos/mod/filesystem/arozfs" ) /* NFSFS.go Network File System as File System Abstraction */ type NFSFileSystemAbstraction struct { uuid string hierarchy string } func NewNFSFileSystemAbstraction(uuid string, hierarchy string, hostname string, target string, dir string, username string, password string) (NFSFileSystemAbstraction, error) { return NFSFileSystemAbstraction{ uuid: uuid, hierarchy: hierarchy, }, nil } func (l NFSFileSystemAbstraction) Chmod(filename string, mode os.FileMode) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Chown(filename string, uid int, gid int) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Chtimes(filename string, atime time.Time, mtime time.Time) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Create(filename string) (arozfs.File, error) { return nil, arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Mkdir(filename string, mode os.FileMode) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) MkdirAll(filename string, mode os.FileMode) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Name() string { return "" } func (l NFSFileSystemAbstraction) Open(filename string) (arozfs.File, error) { return nil, arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) OpenFile(filename string, flag int, perm os.FileMode) (arozfs.File, error) { return nil, arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Remove(filename string) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) RemoveAll(path string) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Rename(oldname, newname string) error { return arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Stat(filename string) (os.FileInfo, error) { return nil, arozfs.ErrNullOperation } func (l NFSFileSystemAbstraction) Close() error { return nil } /* Abstraction Utilities */ func (a NFSFileSystemAbstraction) VirtualPathToRealPath(subpath string, username string) (string, error) { return arozfs.GenericVirtualPathToRealPathTranslator(a.uuid, a.hierarchy, subpath, username) } func (a NFSFileSystemAbstraction) RealPathToVirtualPath(fullpath string, username string) (string, error) { return arozfs.GenericRealPathToVirtualPathTranslator(a.uuid, a.hierarchy, fullpath, username) } func (a NFSFileSystemAbstraction) FileExists(realpath string) bool { return false } func (a NFSFileSystemAbstraction) IsDir(realpath string) bool { return false } func (a NFSFileSystemAbstraction) Glob(realpathWildcard string) ([]string, error) { return []string{}, arozfs.ErrNullOperation } func (a NFSFileSystemAbstraction) GetFileSize(realpath string) int64 { return 0 } func (a NFSFileSystemAbstraction) GetModTime(realpath string) (int64, error) { return 0, arozfs.ErrOperationNotSupported } func (a NFSFileSystemAbstraction) WriteFile(filename string, content []byte, mode os.FileMode) error { return arozfs.ErrNullOperation } func (a NFSFileSystemAbstraction) ReadFile(filename string) ([]byte, error) { return []byte(""), arozfs.ErrOperationNotSupported } func (a NFSFileSystemAbstraction) ReadDir(filename string) ([]fs.DirEntry, error) { return []fs.DirEntry{}, arozfs.ErrOperationNotSupported } func (a NFSFileSystemAbstraction) WriteStream(filename string, stream io.Reader, mode os.FileMode) error { return arozfs.ErrNullOperation } func (a NFSFileSystemAbstraction) ReadStream(filename string) (io.ReadCloser, error) { return nil, arozfs.ErrOperationNotSupported } func (a NFSFileSystemAbstraction) Walk(root string, walkFn filepath.WalkFunc) error { return arozfs.ErrOperationNotSupported } //Utilities func filterFilepath(rawpath string) string { rawpath = arozfs.ToSlash(filepath.Clean(strings.TrimSpace(rawpath))) if strings.HasPrefix(rawpath, "./") { return rawpath[1:] } else if rawpath == "." || rawpath == "" { return "/" } return rawpath }