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

Rename MountOptions to FileSystemOptions.

Introduce new MountOptions struct with AllowOther option.
parent 094ee880
......@@ -28,7 +28,7 @@ func main() {
}
options := unionfs.AutoUnionFsOptions{
UnionFsOptions: ufsOptions,
MountOptions: fuse.MountOptions{
FileSystemOptions: fuse.FileSystemOptions{
EntryTimeout: 1.0,
AttrTimeout: 1.0,
NegativeTimeout: 1.0,
......
......@@ -39,7 +39,7 @@ func main() {
finalFs = timing
}
opts := &fuse.MountOptions{
opts := &fuse.FileSystemOptions{
// These options are to be compatible with libfuse defaults,
// making benchmarking easier.
NegativeTimeout: 1.0,
......@@ -71,7 +71,7 @@ func main() {
mountPoint := flag.Arg(0)
fmt.Println("Mounting")
err := state.Mount(mountPoint)
err := state.Mount(mountPoint, nil)
if err != nil {
fmt.Printf("Mount fail: %v\n", err)
os.Exit(1)
......
......@@ -86,12 +86,16 @@ type File interface {
// MountOptions contains time out options for a FileSystem. The
// default copied from libfuse and set in NewMountOptions() is
// (1s,1s,0s).
type MountOptions struct {
type FileSystemOptions struct {
EntryTimeout float64
AttrTimeout float64
NegativeTimeout float64
}
type MountOptions struct {
AllowOther bool
}
// DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
type DefaultFileSystem struct{}
......
......@@ -4,11 +4,11 @@ import (
"fmt"
)
func MountFileSystem(mountpoint string, fs FileSystem, opts *MountOptions) (*MountState, *FileSystemConnector, os.Error) {
func MountFileSystem(mountpoint string, fs FileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, os.Error) {
conn := NewFileSystemConnector(fs, opts)
mountState := NewMountState(conn)
fmt.Printf("Go-FUSE Version %v.\nMounting...\n", Version())
err := mountState.Mount(mountpoint)
err := mountState.Mount(mountpoint, nil)
if err != nil {
return nil, nil, err
}
......
......@@ -68,7 +68,7 @@ func (me *testCase) Setup(t *testing.T) {
me.connector.Debug = true
me.state = NewMountState(rfs)
me.state.Mount(me.mountPoint)
me.state.Mount(me.mountPoint, nil)
//me.state.Debug = false
me.state.Debug = true
......
......@@ -33,7 +33,7 @@ func Socketpair(network string) (l, r *os.File, err os.Error) {
// Create a FUSE FS on the specified mount point. The returned
// mount point is always absolute.
func mount(mountPoint string) (f *os.File, finalMountPoint string, err os.Error) {
func mount(mountPoint string, options string) (f *os.File, finalMountPoint string, err os.Error) {
local, remote, err := Socketpair("unixgram")
if err != nil {
return
......@@ -50,8 +50,15 @@ func mount(mountPoint string) (f *os.File, finalMountPoint string, err os.Error)
}
mountPoint = filepath.Clean(filepath.Join(cwd, mountPoint))
}
cmd := []string{"/bin/fusermount", mountPoint}
if options != "" {
cmd = append(cmd, "-o")
cmd = append(cmd, options)
}
proc, err := os.StartProcess("/bin/fusermount",
[]string{"/bin/fusermount", mountPoint},
cmd,
&os.ProcAttr{
Env: []string{"_FUSE_COMMFD=3"},
Files: []*os.File{os.Stdin, os.Stdout, os.Stderr, remote}})
......
......@@ -45,8 +45,14 @@ func (me *MountState) MountPoint() string {
}
// Mount filesystem on mountPoint.
func (me *MountState) Mount(mountPoint string) os.Error {
file, mp, err := mount(mountPoint)
func (me *MountState) Mount(mountPoint string, opts *MountOptions) os.Error {
optStr := ""
if opts != nil && opts.AllowOther {
optStr = "allow_other"
}
file, mp, err := mount(mountPoint, optStr)
if err != nil {
return err
}
......
......@@ -17,7 +17,7 @@ func TestPathDebug(t *testing.T) {
defer os.RemoveAll(mountPoint)
state := NewMountState(connector)
state.Mount(mountPoint)
state.Mount(mountPoint, nil)
state.Debug = true
defer state.Unmount()
......
......@@ -46,7 +46,7 @@ type mountData struct {
// consider if we can measure significant contention for
// multi-mount filesystems.
options *MountOptions
options *FileSystemOptions
}
func newMount(fs FileSystem) *mountData {
......@@ -165,8 +165,8 @@ func (me *inode) setParent(newParent *inode) {
}
}
func NewMountOptions() *MountOptions {
return &MountOptions{
func NewFileSystemOptions() *FileSystemOptions {
return &FileSystemOptions{
NegativeTimeout: 0.0,
AttrTimeout: 1.0,
EntryTimeout: 1.0,
......@@ -422,7 +422,7 @@ func EmptyFileSystemConnector() (out *FileSystemConnector) {
return out
}
func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *MountOptions) Status {
func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *FileSystemOptions) Status {
var node *inode
if mountPoint != "/" {
......@@ -465,7 +465,7 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Mou
node.mount = newMount(fs)
if opts == nil {
opts = NewMountOptions()
opts = NewFileSystemOptions()
}
node.mount.options = opts
return OK
......
......@@ -12,7 +12,7 @@ import (
var _ = fmt.Println
func NewFileSystemConnector(fs FileSystem, opts *MountOptions) (out *FileSystemConnector) {
func NewFileSystemConnector(fs FileSystem, opts *FileSystemOptions) (out *FileSystemConnector) {
out = EmptyFileSystemConnector()
if code := out.Mount("/", fs, opts); code != OK {
panic("root mount failed.")
......
......@@ -32,7 +32,7 @@ type AutoUnionFs struct {
type AutoUnionFsOptions struct {
UnionFsOptions
fuse.MountOptions
fuse.FileSystemOptions
// If set, run updateKnownFses() after mounting.
UpdateOnMount bool
......@@ -134,7 +134,7 @@ func (me *AutoUnionFs) addFs(name string, roots []string) (code fuse.Status) {
}
gofs, code := me.createFs(name, roots)
if gofs != nil {
me.connector.Mount("/"+name, gofs, &me.options.MountOptions)
me.connector.Mount("/"+name, gofs, &me.options.FileSystemOptions)
}
return code
}
......
......@@ -17,7 +17,7 @@ const entryTtl = 0.1
var testAOpts = AutoUnionFsOptions{
UnionFsOptions: testOpts,
MountOptions: fuse.MountOptions{
FileSystemOptions: fuse.FileSystemOptions{
EntryTimeout: entryTtl,
AttrTimeout: entryTtl,
NegativeTimeout: 0,
......@@ -44,7 +44,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
WriteFile(wd+"/ro/file2", "file2")
fs := NewAutoUnionFs(wd+"/store", testAOpts)
state, _, err := fuse.MountFileSystem(wd + "/mount", fs, &testAOpts.MountOptions)
state, _, err := fuse.MountFileSystem(wd + "/mount", fs, &testAOpts.FileSystemOptions)
CheckSuccess(err)
state.Debug = true
go state.Loop(false)
......
......@@ -42,7 +42,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
fses = append(fses, fuse.NewLoopbackFileSystem(wd+"/ro"))
ufs := NewUnionFs("testFs", fses, testOpts)
opts := &fuse.MountOptions{
opts := &fuse.FileSystemOptions{
EntryTimeout: entryTtl,
AttrTimeout: entryTtl,
NegativeTimeout: entryTtl,
......
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