update
This commit is contained in:
parent
7b1863109c
commit
ef751771d2
107 changed files with 9435 additions and 850 deletions
src/host/vfs
|
@ -8,12 +8,14 @@ import (
|
|||
"time"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/pkg/ctxio"
|
||||
"go.opentelemetry.io/otel"
|
||||
)
|
||||
|
||||
type File interface {
|
||||
IsDir() bool
|
||||
Size() int64
|
||||
Stat() (fs.FileInfo, error)
|
||||
|
||||
fs.DirEntry
|
||||
|
||||
ctxio.Reader
|
||||
ctxio.ReaderAt
|
||||
|
@ -22,6 +24,8 @@ type File interface {
|
|||
|
||||
var ErrNotImplemented = errors.New("not implemented")
|
||||
|
||||
var tracer = otel.Tracer("git.kmsign.ru/royalcat/tstor/src/host/vfs")
|
||||
|
||||
type Filesystem interface {
|
||||
// Open opens the named file for reading. If successful, methods on the
|
||||
// returned file can be used for reading; the associated file descriptor has
|
||||
|
@ -35,10 +39,12 @@ type Filesystem interface {
|
|||
Stat(ctx context.Context, filename string) (fs.FileInfo, error)
|
||||
Unlink(ctx context.Context, filename string) error
|
||||
|
||||
// As filesystem mounted to some path, make sense to have the filesystem implement DirEntry
|
||||
fs.DirEntry
|
||||
}
|
||||
|
||||
const defaultMode = fs.FileMode(0555)
|
||||
// readonly
|
||||
const roMode = fs.FileMode(0555)
|
||||
|
||||
type fileInfo struct {
|
||||
name string
|
||||
|
@ -87,10 +93,10 @@ func (fi *fileInfo) Size() int64 {
|
|||
|
||||
func (fi *fileInfo) Mode() fs.FileMode {
|
||||
if fi.isDir {
|
||||
return defaultMode | fs.ModeDir
|
||||
return roMode | fs.ModeDir
|
||||
}
|
||||
|
||||
return defaultMode
|
||||
return roMode
|
||||
}
|
||||
|
||||
func (fi *fileInfo) ModTime() time.Time {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue