posix: add New(), Shutdown(), and String() methods

This commit is contained in:
Ben McClelland
2023-05-24 14:22:35 -07:00
parent 0121ea6c7f
commit 3c3516822f
+24
View File
@@ -22,6 +22,8 @@ import (
)
type Posix struct {
rootfd *os.File
rootdir string
backend.BackendUnsupported
}
@@ -40,6 +42,28 @@ var (
newObjGID = 0
)
func New(rootdir string) (*Posix, error) {
err := os.Chdir(rootdir)
if err != nil {
return nil, fmt.Errorf("chdir %v: %w", rootdir, err)
}
f, err := os.Open(rootdir)
if err != nil {
return nil, fmt.Errorf("open %v: %w", rootdir, err)
}
return &Posix{rootfd: f, rootdir: rootdir}, nil
}
func (p *Posix) Shutdown() {
p.rootfd.Close()
}
func (p *Posix) Sring() string {
return "Posix Gateway"
}
func (p *Posix) ListBuckets() (*s3.ListBucketsOutput, error) {
entries, err := os.ReadDir(".")
if err != nil {