|
|
@ -2,9 +2,12 @@ package command |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"math" |
|
|
|
"os" |
|
|
|
"os/signal" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"syscall" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@ -105,6 +108,14 @@ func runFuse(cmd *Command, args []string) bool { |
|
|
|
switch parameter.name { |
|
|
|
case "child": |
|
|
|
masterProcess = false |
|
|
|
if parsed, err := strconv.ParseInt(parameter.value, 10, 64); err == nil { |
|
|
|
if parsed > math.MaxInt || parsed <= 0 { |
|
|
|
panic(fmt.Errorf("parent PID %s is invalid", err)) |
|
|
|
} |
|
|
|
mountOptions.fuseCommandPid = int(parsed) |
|
|
|
} else { |
|
|
|
panic(fmt.Errorf("parent PID %s is invalid", err)) |
|
|
|
} |
|
|
|
case "arg0": |
|
|
|
mountOptions.dir = ¶meter.value |
|
|
|
case "filer": |
|
|
@ -211,7 +222,12 @@ func runFuse(cmd *Command, args []string) bool { |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
|
|
|
|
argv := append(os.Args, "-o", "child") |
|
|
|
// pass our PID to the child process
|
|
|
|
pid := os.Getpid() |
|
|
|
argv := append(os.Args, "-o", "child="+strconv.Itoa(pid)) |
|
|
|
|
|
|
|
c := make(chan os.Signal, 1) |
|
|
|
signal.Notify(c, syscall.SIGUSR1) |
|
|
|
|
|
|
|
attr := os.ProcAttr{} |
|
|
|
attr.Env = os.Environ() |
|
|
@ -228,8 +244,11 @@ func runFuse(cmd *Command, args []string) bool { |
|
|
|
panic(fmt.Errorf("master process can not release child process: %s", err)) |
|
|
|
} |
|
|
|
|
|
|
|
select { |
|
|
|
case <-c: |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if fusermountPath != "" { |
|
|
|
if err := os.Setenv("PATH", fusermountPath); err != nil { |
|
|
|