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

Add ReadonlyFileSystem.

parent 5cd3775f
......@@ -22,6 +22,7 @@ MANUAL_GOFILES=api.go \
pathdebug.go \
pathfilesystem.go \
pathops.go \
readonlyfs.go \
request.go \
switchfs.go \
timingfs.go \
......
package fuse
import (
"os"
)
// This is a wrapper that only exposes read-only operations.
type ReadonlyFileSystem struct {
FileSystem
}
func (me *ReadonlyFileSystem) GetAttr(name string, context *Context) (*os.FileInfo, Status) {
return me.FileSystem.GetAttr(name, context)
}
func (me *ReadonlyFileSystem) Readlink(name string, context *Context) (string, Status) {
return me.FileSystem.Readlink(name, context)
}
func (me *ReadonlyFileSystem) Mknod(name string, mode uint32, dev uint32, context *Context) Status {
return EPERM
}
func (me *ReadonlyFileSystem) Mkdir(name string, mode uint32, context *Context) Status {
return EPERM
}
func (me *ReadonlyFileSystem) Unlink(name string, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Rmdir(name string, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Symlink(value string, linkName string, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Rename(oldName string, newName string, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Link(oldName string, newName string, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Chmod(name string, mode uint32, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Chown(name string, uid uint32, gid uint32, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Truncate(name string, offset uint64, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) Open(name string, flags uint32, context *Context) (file File, code Status) {
if flags & O_ANYWRITE != 0 {
return nil, EPERM
}
// TODO - wrap the File object inside a R/O wrapper too?
return me.FileSystem.Open(name, flags, context)
}
func (me *ReadonlyFileSystem) OpenDir(name string, context *Context) (stream chan DirEntry, status Status) {
return me.FileSystem.OpenDir(name, context)
}
func (me *ReadonlyFileSystem) Mount(conn *FileSystemConnector) {
me.FileSystem.Mount(conn)
}
func (me *ReadonlyFileSystem) Unmount() {
me.FileSystem.Unmount()
}
func (me *ReadonlyFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
return me.FileSystem.Access(name, mode, context)
}
func (me *ReadonlyFileSystem) Create(name string, flags uint32, mode uint32, context *Context) (file File, code Status) {
return nil, EPERM
}
func (me *ReadonlyFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64, context *Context) (code Status) {
return EPERM
}
func (me *ReadonlyFileSystem) GetXAttr(name string, attr string, context *Context) ([]byte, Status) {
return me.FileSystem.GetXAttr(name, attr, context)
}
func (me *ReadonlyFileSystem) SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status {
return EPERM
}
func (me *ReadonlyFileSystem) ListXAttr(name string, context *Context) ([]string, Status) {
return me.FileSystem.ListXAttr(name, context)
}
func (me *ReadonlyFileSystem) RemoveXAttr(name string, attr string, context *Context) Status {
return 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