Commit c0387f23 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Hide ReadOnlyFileSystem type to reduce API clutter.

parent 8c5c22a9
......@@ -7,62 +7,68 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
// This is a wrapper that only exposes read-only operations.
type ReadonlyFileSystem struct {
// NewReadonlyFileSystem returns a wrapper that only exposes read-only
// operations.
func NewReadonlyFileSystem(fs FileSystem) FileSystem {
return &readonlyFileSystem{fs}
}
type readonlyFileSystem struct {
FileSystem
}
var _ = (FileSystem)((*ReadonlyFileSystem)(nil))
var _ = (FileSystem)((*readonlyFileSystem)(nil))
func (fs *ReadonlyFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
func (fs *readonlyFileSystem) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
return fs.FileSystem.GetAttr(name, context)
}
func (fs *ReadonlyFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) {
func (fs *readonlyFileSystem) Readlink(name string, context *fuse.Context) (string, fuse.Status) {
return fs.FileSystem.Readlink(name, context)
}
func (fs *ReadonlyFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status {
func (fs *readonlyFileSystem) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status {
func (fs *readonlyFileSystem) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Unlink(name string, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Symlink(value string, linkName string, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Rename(oldName string, newName string, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Link(oldName string, newName string, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Chmod(name string, mode uint32, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Chown(name string, uid uint32, gid uint32, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Truncate(name string, offset uint64, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) Open(name string, flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
func (fs *readonlyFileSystem) Open(name string, flags uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
}
......@@ -70,46 +76,46 @@ func (fs *ReadonlyFileSystem) Open(name string, flags uint32, context *fuse.Cont
return &fuse.ReadOnlyFile{file}, code
}
func (fs *ReadonlyFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) {
func (fs *readonlyFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) {
return fs.FileSystem.OpenDir(name, context)
}
func (fs *ReadonlyFileSystem) OnMount(nodeFs *PathNodeFs) {
func (fs *readonlyFileSystem) OnMount(nodeFs *PathNodeFs) {
fs.FileSystem.OnMount(nodeFs)
}
func (fs *ReadonlyFileSystem) OnUnmount() {
func (fs *readonlyFileSystem) OnUnmount() {
fs.FileSystem.OnUnmount()
}
func (fs *ReadonlyFileSystem) String() string {
return fmt.Sprintf("ReadonlyFileSystem(%v)", fs.FileSystem)
func (fs *readonlyFileSystem) String() string {
return fmt.Sprintf("readonlyFileSystem(%v)", fs.FileSystem)
}
func (fs *ReadonlyFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Access(name string, mode uint32, context *fuse.Context) (code fuse.Status) {
return fs.FileSystem.Access(name, mode, context)
}
func (fs *ReadonlyFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
func (fs *readonlyFileSystem) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file fuse.File, code fuse.Status) {
return nil, fuse.EPERM
}
func (fs *ReadonlyFileSystem) Utimens(name string, atime *time.Time, ctime *time.Time, context *fuse.Context) (code fuse.Status) {
func (fs *readonlyFileSystem) Utimens(name string, atime *time.Time, ctime *time.Time, context *fuse.Context) (code fuse.Status) {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
func (fs *readonlyFileSystem) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
return fs.FileSystem.GetXAttr(name, attr, context)
}
func (fs *ReadonlyFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status {
func (fs *readonlyFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status {
return fuse.EPERM
}
func (fs *ReadonlyFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) {
func (fs *readonlyFileSystem) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) {
return fs.FileSystem.ListXAttr(name, context)
}
func (fs *ReadonlyFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status {
func (fs *readonlyFileSystem) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status {
return fuse.EPERM
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment