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