summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-01-21 23:55:37 +0100
committerJakob Unterwurzacher2016-01-21 23:55:37 +0100
commitcec2da3e3391e382d9c24fc85324893e85ce2088 (patch)
tree7161feff45564f0432cffd92a84bd6a0ff4e5037
parentd1631696556cb6460db1d6eedf9fbc3015433b1c (diff)
Add "-memprofile" option
-rw-r--r--main.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/main.go b/main.go
index f9570e0..61e7020 100644
--- a/main.go
+++ b/main.go
@@ -38,8 +38,9 @@ const (
type argContainer struct {
debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,
plaintextnames, quiet, diriv, emenames, gcmiv128 bool
- masterkey, mountpoint, cipherdir, cpuprofile, config, extpass string
- notifypid, scryptn int
+ masterkey, mountpoint, cipherdir, cpuprofile, config, extpass,
+ memprofile string
+ notifypid, scryptn int
}
var flagSet *flag.FlagSet
@@ -149,14 +150,14 @@ func main() {
flagSet.BoolVar(&args.passwd, "passwd", false, "Change password")
flagSet.BoolVar(&args.foreground, "f", false, "Stay in the foreground")
flagSet.BoolVar(&args.version, "version", false, "Print version and exit")
- flagSet.BoolVar(&args.plaintextnames, "plaintextnames", false, "Do not encrypt "+
- "file names")
+ flagSet.BoolVar(&args.plaintextnames, "plaintextnames", false, "Do not encrypt file names")
flagSet.BoolVar(&args.quiet, "q", false, "Quiet - silence informational messages")
flagSet.BoolVar(&args.diriv, "diriv", true, "Use per-directory file name IV")
flagSet.BoolVar(&args.emenames, "emenames", true, "Use EME filename encryption. This option implies diriv.")
flagSet.BoolVar(&args.gcmiv128, "gcmiv128", true, "Use an 128-bit IV for GCM encryption instead of Go's default of 96 bits")
flagSet.StringVar(&args.masterkey, "masterkey", "", "Mount with explicit master key")
flagSet.StringVar(&args.cpuprofile, "cpuprofile", "", "Write cpu profile to specified file")
+ flagSet.StringVar(&args.memprofile, "memprofile", "", "Write memory profile to specified file")
flagSet.StringVar(&args.config, "config", "", "Use specified config file instead of CIPHERDIR/gocryptfs.conf")
flagSet.StringVar(&args.extpass, "extpass", "", "Use external program for the password prompt")
flagSet.IntVar(&args.notifypid, "notifypid", 0, "Send USR1 to the specified process after "+
@@ -206,15 +207,32 @@ func main() {
}
// "-cpuprofile"
if args.cpuprofile != "" {
+ cryptfs.Info.Printf("Writing CPU profile to %s", args.cpuprofile)
f, err := os.Create(args.cpuprofile)
if err != nil {
fmt.Println(err)
os.Exit(ERREXIT_INIT)
}
- cryptfs.Info.Printf("Writing CPU profile to %s", args.cpuprofile)
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
+ // "-memprofile"
+ if args.memprofile != "" {
+ cryptfs.Info.Printf("Writing mem profile to %s", args.memprofile)
+ f, err := os.Create(args.memprofile)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(ERREXIT_INIT)
+ }
+ defer func() {
+ pprof.WriteHeapProfile(f)
+ f.Close()
+ return
+ }()
+ }
+ if args.cpuprofile != "" || args.memprofile != "" {
+ fmt.Printf("Note: You must unmount gracefully, otherwise the profile file(s) will stay empty!\n")
+ }
// "-openssl"
if args.openssl == false {
cryptfs.Info.Printf("Openssl disabled")