Commit e59a45f1 authored by Aaron Jacobs's avatar Aaron Jacobs

Added support for setting the OS X volume name.

While I was at it, added tests for fsname. I can't figure out how to
test the volume name.

For GoogleCloudPlatform/gcsfuse#125.
parent aa1fe8b2
...@@ -129,6 +129,12 @@ type MountConfig struct { ...@@ -129,6 +129,12 @@ type MountConfig struct {
// entries will be cached for an arbitrarily long time. // entries will be cached for an arbitrarily long time.
EnableVnodeCaching bool EnableVnodeCaching bool
// OS X only.
//
// The name of the mounted volume, as displayed in the Finder. If empty, a
// default name involving the string 'osxfuse' is used.
VolumeName string
// Additional key=value options to pass unadulterated to the underlying mount // Additional key=value options to pass unadulterated to the underlying mount
// command. See `man 8 mount`, the fuse documentation, etc. for // command. See `man 8 mount`, the fuse documentation, etc. for
// system-specific information. // system-specific information.
...@@ -172,11 +178,18 @@ func (c *MountConfig) toMap() (opts map[string]string) { ...@@ -172,11 +178,18 @@ func (c *MountConfig) toMap() (opts map[string]string) {
opts["ro"] = "" opts["ro"] = ""
} }
// OS X: set novncache when appropriate. // Handle OS X options.
if isDarwin && !c.EnableVnodeCaching { if isDarwin {
if !c.EnableVnodeCaching {
opts["novncache"] = "" opts["novncache"] = ""
} }
if c.VolumeName != "" {
// Cf. https://github.com/osxfuse/osxfuse/wiki/Mount-options#volname
opts["volname"] = c.VolumeName
}
}
// OS X: disable the use of "Apple Double" (._foo and .DS_Store) files, which // OS X: disable the use of "Apple Double" (._foo and .DS_Store) files, which
// just add noise to debug output and can have significant cost on // just add noise to debug output and can have significant cost on
// network-based file systems. // network-based file systems.
......
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"syscall" "syscall"
"github.com/jacobsa/fuse/fuseops" "github.com/jacobsa/fuse/fuseops"
. "github.com/jacobsa/oglematchers"
. "github.com/jacobsa/ogletest" . "github.com/jacobsa/ogletest"
) )
...@@ -72,9 +71,7 @@ func (t *StatFSTest) Syscall_ZeroValues() { ...@@ -72,9 +71,7 @@ func (t *StatFSTest) Syscall_ZeroValues() {
ExpectEq(0, stat.Ffree) ExpectEq(0, stat.Ffree)
ExpectEq("osxfusefs", convertName(stat.Fstypename[:])) ExpectEq("osxfusefs", convertName(stat.Fstypename[:]))
ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:])) ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:]))
ExpectThat( ExpectEq(fsName, convertName(stat.Mntfromname[:]))
convertName(stat.Mntfromname[:]),
MatchesRegexp(`mount_osxfusefs@osxfuse\d+`))
} }
func (t *StatFSTest) Syscall_NonZeroValues() { func (t *StatFSTest) Syscall_NonZeroValues() {
...@@ -108,9 +105,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() { ...@@ -108,9 +105,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
ExpectEq(canned.InodesFree, stat.Ffree) ExpectEq(canned.InodesFree, stat.Ffree)
ExpectEq("osxfusefs", convertName(stat.Fstypename[:])) ExpectEq("osxfusefs", convertName(stat.Fstypename[:]))
ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:])) ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:]))
ExpectThat( ExpectEq(fsName, convertName(stat.Mntfromname[:]))
convertName(stat.Mntfromname[:]),
MatchesRegexp(`mount_osxfusefs@osxfuse\d+`))
} }
func (t *StatFSTest) UnsupportedBlockSizes() { func (t *StatFSTest) UnsupportedBlockSizes() {
......
...@@ -34,6 +34,9 @@ import ( ...@@ -34,6 +34,9 @@ import (
func TestStatFS(t *testing.T) { RunTests(t) } func TestStatFS(t *testing.T) { RunTests(t) }
const fsName = "some_fs_name"
const volumeName = "Some volume"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Helpers // Helpers
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -117,6 +120,10 @@ func (t *StatFSTest) SetUp(ti *TestInfo) { ...@@ -117,6 +120,10 @@ func (t *StatFSTest) SetUp(ti *TestInfo) {
// being issued from the client. // being issued from the client.
t.MountConfig.DisableWritebackCaching = true t.MountConfig.DisableWritebackCaching = true
// Configure names.
t.MountConfig.FSName = fsName
t.MountConfig.VolumeName = volumeName
// Create the file system. // Create the file system.
t.fs = statfs.New() t.fs = statfs.New()
t.Server = fuseutil.NewFileSystemServer(t.fs) t.Server = fuseutil.NewFileSystemServer(t.fs)
......
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