Commit 713e99eb authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

example: loopback: support -q (quiet)

Getting rid of the "Mounted!" message makes it easier
to integrate into xfstests, which barks at all and any
unexpected output.

Used by https://github.com/rfjakob/fuse-xfstests/commit/ab1d77ccdb8cf16f79cb312bcb3aaadb23660807

Change-Id: Idff314474b4980ef6f6fc2460b338a840bb0e409
parent be5a8417
...@@ -45,6 +45,7 @@ func main() { ...@@ -45,6 +45,7 @@ func main() {
// Scans the arg list and sets up flags // Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.") debug := flag.Bool("debug", false, "print debugging messages.")
other := flag.Bool("allow-other", false, "mount with -o allowother.") other := flag.Bool("allow-other", false, "mount with -o allowother.")
quiet := flag.Bool("q", false, "quiet")
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to this file") cpuprofile := flag.String("cpuprofile", "", "write cpu profile to this file")
memprofile := flag.String("memprofile", "", "write memory profile to this file") memprofile := flag.String("memprofile", "", "write memory profile to this file")
flag.Parse() flag.Parse()
...@@ -55,7 +56,9 @@ func main() { ...@@ -55,7 +56,9 @@ func main() {
os.Exit(2) os.Exit(2)
} }
if *cpuprofile != "" { if *cpuprofile != "" {
fmt.Printf("Writing cpu profile to %s\n", *cpuprofile) if !*quiet {
fmt.Printf("Writing cpu profile to %s\n", *cpuprofile)
}
f, err := os.Create(*cpuprofile) f, err := os.Create(*cpuprofile)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
...@@ -65,13 +68,17 @@ func main() { ...@@ -65,13 +68,17 @@ func main() {
defer pprof.StopCPUProfile() defer pprof.StopCPUProfile()
} }
if *memprofile != "" { if *memprofile != "" {
log.Printf("send SIGUSR1 to %d to dump memory profile", os.Getpid()) if !*quiet {
log.Printf("send SIGUSR1 to %d to dump memory profile", os.Getpid())
}
profSig := make(chan os.Signal, 1) profSig := make(chan os.Signal, 1)
signal.Notify(profSig, syscall.SIGUSR1) signal.Notify(profSig, syscall.SIGUSR1)
go writeMemProfile(*memprofile, profSig) go writeMemProfile(*memprofile, profSig)
} }
if *cpuprofile != "" || *memprofile != "" { if *cpuprofile != "" || *memprofile != "" {
fmt.Printf("Note: You must unmount gracefully, otherwise the profile file(s) will stay empty!\n") if !*quiet {
fmt.Printf("Note: You must unmount gracefully, otherwise the profile file(s) will stay empty!\n")
}
} }
orig := flag.Arg(1) orig := flag.Arg(1)
...@@ -97,7 +104,8 @@ func main() { ...@@ -97,7 +104,8 @@ func main() {
if err != nil { if err != nil {
log.Fatalf("Mount fail: %v\n", err) log.Fatalf("Mount fail: %v\n", err)
} }
if !*quiet {
fmt.Println("Mounted!") fmt.Println("Mounted!")
}
server.Wait() server.Wait()
} }
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