aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-16 21:29:22 +0200
committerJakob Unterwurzacher2016-06-16 21:29:22 +0200
commit82d87ff8eda1a8e43cda4a5f500fc579477ee606 (patch)
tree6faccc15d46a1120409bb2baee6134c542e917df /main.go
parent305e9c1045f0546967bfbd2d10f13a28b6227a76 (diff)
Add "-ro" (read-only) flag
From the man page: **-ro** : Mount the filesystem read-only Also add a test.
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.go b/main.go
index dba10bf..2d7b50f 100644
--- a/main.go
+++ b/main.go
@@ -43,7 +43,7 @@ const (
type argContainer struct {
debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,
plaintextnames, quiet, diriv, emenames, gcmiv128, nosyslog, wpanic,
- longnames, allow_other bool
+ longnames, allow_other, ro bool
masterkey, mountpoint, cipherdir, cpuprofile, config, extpass,
memprofile string
notifypid, scryptn int
@@ -182,6 +182,7 @@ func main() {
flagSet.BoolVar(&args.longnames, "longnames", true, "Store names longer than 176 bytes in extra files")
flagSet.BoolVar(&args.allow_other, "allow_other", false, "Allow other users to access the filesystem. "+
"Only works if user_allow_other is set in /etc/fuse.conf.")
+ flagSet.BoolVar(&args.ro, "ro", false, "Mount the filesystem read-only")
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")
@@ -419,6 +420,11 @@ func initFuseFrontend(key []byte, args argContainer, confFile *configfile.ConfFi
// Second column, "Type", will be shown as "fuse." + Name
mOpts.Name = "gocryptfs"
+ // The kernel enforces read-only operation, we just have to pass "ro".
+ if args.ro {
+ mOpts.Options = append(mOpts.Options, "ro")
+ }
+
srv, err := fuse.NewServer(conn.RawFS(), args.mountpoint, &mOpts)
if err != nil {
tlog.Fatal.Printf("Mount failed: %v", err)