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() {
// Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.")
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")
memprofile := flag.String("memprofile", "", "write memory profile to this file")
flag.Parse()
......@@ -55,7 +56,9 @@ func main() {
os.Exit(2)
}
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)
if err != nil {
fmt.Println(err)
......@@ -65,13 +68,17 @@ func main() {
defer pprof.StopCPUProfile()
}
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)
signal.Notify(profSig, syscall.SIGUSR1)
go writeMemProfile(*memprofile, profSig)
}
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)
......@@ -97,7 +104,8 @@ func main() {
if err != nil {
log.Fatalf("Mount fail: %v\n", err)
}
fmt.Println("Mounted!")
if !*quiet {
fmt.Println("Mounted!")
}
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