Commits

Paul Ruane  committed 991130e

Replaced the --allow-other option of the 'mount' command with a more general --options option, in which mount options such as 'allow_other' can be passed.

  • Participants
  • Parent commits 3553778

Comments (0)

Files changed (5)

File src/tmsu/cli/mount.go

 the database at TMSU_DB is mounted.
 
 Where neither FILE is specified nor TMSU_DB defined then the default database
-is mounted.`,
-	Options: Options{Option{"--allow-other", "-o", "allow other users access to the VFS (requires root or setting in fuse.conf)", false, ""}},
+is mounted.
+
+To allow other users access to the mounted filesystem, pass the 'allow_other'
+FUSE option, e.g. 'tmsu mount --option=allow_other mp'. (FUSE only allows the
+root user to use this option unless 'user_allow_other' is present in
+'/etc/fuse.conf'.)`,
+	Options: Options{Option{"--options", "-o", "mount options (passed to fusermount)", true, ""}},
 	Exec:    mountExec,
 }
 
 func mountExec(options Options, args []string) error {
-	allowOther := options.HasOption("--allow-other")
+	var mountOptions string
+	if options.HasOption("--options") {
+		mountOptions = options.Get("--options").Argument
+	}
 
 	argCount := len(args)
 
 	case 1:
 		mountPath := args[0]
 
-		err := mountDefault(mountPath, allowOther)
+		err := mountDefault(mountPath, mountOptions)
 		if err != nil {
 			return err
 		}
 		databasePath := args[0]
 		mountPath := args[1]
 
-		err := mountExplicit(databasePath, mountPath, allowOther)
+		err := mountExplicit(databasePath, mountPath, mountOptions)
 		if err != nil {
 			return err
 		}
 	return nil
 }
 
-func mountDefault(mountPath string, allowOther bool) error {
-	if err := mountExplicit(database.Path, mountPath, allowOther); err != nil {
+func mountDefault(mountPath string, mountOptions string) error {
+	if err := mountExplicit(database.Path, mountPath, mountOptions); err != nil {
 		return err
 	}
 
 	return nil
 }
 
-func mountExplicit(databasePath string, mountPath string, allowOther bool) error {
+func mountExplicit(databasePath string, mountPath string, mountOptions string) error {
 	if alreadyMounted(mountPath) {
 		return fmt.Errorf("%v: mount path already in use", mountPath)
 	}
 
 	log.Suppf("spawning daemon to mount VFS for database '%v' at '%v'.", databasePath, mountPath)
 
-	args := []string{"vfs", databasePath, mountPath}
-	if allowOther {
-		args = append(args, "--allow-other")
-	}
-
+	args := []string{"vfs", databasePath, mountPath, "--options=" + mountOptions}
 	daemon := exec.Command(os.Args[0], args...)
 
 	errorPipe, err := daemon.StderrPipe()

File src/tmsu/cli/option.go

 			parseOptions = false
 		} else {
 			if parseOptions && arg[0] == '-' {
-				parts := strings.Split(arg, "=")
-				if len(parts) > 2 {
-					err = fmt.Errorf("syntax error: %v", arg)
-					return
-				}
+				parts := strings.SplitN(arg, "=", 2)
 				optionName := parts[0]
 
 				option := lookupOption(possibleOptions, optionName)

File src/tmsu/cli/tag.go

 
 	for _, implication := range implications {
 		if !contains(tagIds, implication.ImpliedTag.Id) {
-			log.Infof("tag '%v' is implied.", implication.ImpliedTag.Name)
+			log.Warnf("tag '%v' is implied.", implication.ImpliedTag.Name)
 			tagIds = append(tagIds, implication.ImpliedTag.Id)
 		}
 	}

File src/tmsu/cli/vfs.go

 
 import (
 	"fmt"
+	"strings"
 	"tmsu/vfs"
 )
 
 	Name:        "vfs",
 	Synopsis:    "",
 	Description: "",
-	Options:     Options{{"--allow-other", "-o", "turn on FUSE 'allow_other' option", false, ""}},
+	Options:     Options{{"--options", "-o", "mount options", true, ""}},
 	Exec:        vfsExec,
 }
 
 		fmt.Errorf("Mountpoint not specified.")
 	}
 
-	allowOther := options.HasOption("--allow-other")
+	mountOptions := []string{}
+	if options.HasOption("--options") {
+		mountOptions = strings.Split(options.Get("--options").Argument, ",")
+	}
+
 	databasePath := args[0]
 	mountPath := args[1]
 
-	vfs, err := vfs.MountVfs(databasePath, mountPath, allowOther)
+	vfs, err := vfs.MountVfs(databasePath, mountPath, mountOptions)
 	if err != nil {
 		return fmt.Errorf("could not mount virtual filesystem for database '%v' at '%v': %v", databasePath, mountPath, err)
 	}

File src/tmsu/vfs/fusevfs.go

 	server    *fuse.Server
 }
 
-func MountVfs(databasePath string, mountPath string, allowOther bool) (*FuseVfs, error) {
+func MountVfs(databasePath string, mountPath string, options []string) (*FuseVfs, error) {
 	fuseVfs := FuseVfs{}
 	pathFs := pathfs.NewPathNodeFs(&fuseVfs, nil)
 	conn := nodefs.NewFileSystemConnector(pathFs, nil)
-	mountOptions := &fuse.MountOptions{AllowOther: allowOther}
+	mountOptions := &fuse.MountOptions{Options: options}
 
 	server, err := fuse.NewServer(conn.RawFS(), mountPath, mountOptions)
 	if err != nil {