diff options
author | Jakob Unterwurzacher | 2015-09-18 22:14:07 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-09-18 22:14:07 +0200 |
commit | 8fe5ec7381778bbbf90a7ad0e9d1f05cb2d9ac23 (patch) | |
tree | 567874364416aafa400336a103d0423f4a76f0f3 /main.go | |
parent | e84c1e3741bd7f7b3be8a424ee142005b1e7601f (diff) |
Add --cpuprofile flag
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,6 +1,7 @@ package main import ( + "runtime/pprof" "io/ioutil" "flag" "fmt" @@ -73,7 +74,19 @@ func main() { flag.BoolVar(&fusedebug, "fusedebug", false, "Enable fuse library debug output") flag.BoolVar(&init, "init", false, "Initialize encrypted directory") flag.BoolVar(&zerokey, "zerokey", false, "Use all-zero dummy master key") + var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") + flag.Parse() + if *cpuprofile != "" { + f, err := os.Create(*cpuprofile) + if err != nil { + fmt.Println(err) + os.Exit(ERREXIT_INIT) + } + fmt.Printf("Writing CPU profile to %s\n", *cpuprofile) + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } if debug { cryptfs.Debug.Enable() cryptfs.Debug.Printf("Debug output enabled\n") @@ -102,7 +115,7 @@ func main() { key := make([]byte, cryptfs.KEY_LEN) if zerokey { fmt.Printf("Zerokey mode active: using all-zero dummy master key.\n") - fmt.Printf("ZEROKEY MODE PROVIDES NO SECURITY AT ALL.\n") + fmt.Printf("ZEROKEY MODE PROVIDES NO SECURITY AT ALL AND SHOULD ONLY BE USED FOR TESTING.\n") } else { cfname := filepath.Join(cipherdir, cryptfs.ConfDefaultName) _, err = os.Stat(cfname) @@ -218,9 +231,6 @@ func cluefsFrontend(key []byte, cipherdir string, mountpoint string) { fmt.Println(err) os.Exit(ERREXIT_MOUNT2) } - - // We are done - os.Exit(0) } func pathfsFrontend(key []byte, cipherdir string, mountpoint string, debug bool){ |