summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-11-29 19:06:11 +0100
committerJakob Unterwurzacher2015-11-29 19:09:12 +0100
commit6f764b386786b92023fa696594105f702226b3ff (patch)
treecf927b67da800821c464bb144dfa1b102f55557b
parentbb116282b7db6a6400586d756c6dfdcc8f85fdab (diff)
Handle all operations except mounting without forking a child
This saves 170ms for each start (why do we take 170ms to start up?) and cuts down test time by 2 seconds.
-rw-r--r--TODO.md1
-rw-r--r--main.go9
2 files changed, 4 insertions, 6 deletions
diff --git a/TODO.md b/TODO.md
index 1f65807..3763984 100644
--- a/TODO.md
+++ b/TODO.md
@@ -3,3 +3,4 @@
* add test case
* Add "--pwfile" parameter that reads the password from a file
* Use that for additional test cases
+* Find out why "./gocryptfs -version" takes 170ms.
diff --git a/main.go b/main.go
index 7184255..e602ed2 100644
--- a/main.go
+++ b/main.go
@@ -155,13 +155,10 @@ func main() {
"Setting this to a lower value speeds up mounting but makes the password susceptible to brute-force attacks")
flagSet.Parse(os.Args[1:])
- // By default, let the child handle everything.
- // The parent *could* handle operations that do not require backgrounding by
- // itself, but that would make the code paths more complicated.
- if !args.foreground {
+ // Fork a child into the background if "-f" is not set and we are mounting a filesystem
+ if !args.foreground && flagSet.NArg() == 2 {
forkChild() // does not return
}
- // Getting here means we *are* the child
// "-v"
if args.version {
printVersion()
@@ -231,7 +228,7 @@ func main() {
}
// Mount
// Check mountpoint
- if flagSet.NArg() < 2 {
+ if flagSet.NArg() != 2 {
usageText()
os.Exit(ERREXIT_USAGE)
}