main: pass args struct instead of having a huge function call
This commit is contained in:
parent
a04a92cdab
commit
b3d96b6a20
15
main.go
15
main.go
@ -267,7 +267,7 @@ func main() {
|
|||||||
args.plaintextnames = confFile.IsFeatureFlagSet(cryptfs.FlagPlaintextNames)
|
args.plaintextnames = confFile.IsFeatureFlagSet(cryptfs.FlagPlaintextNames)
|
||||||
}
|
}
|
||||||
// Initialize FUSE server
|
// Initialize FUSE server
|
||||||
srv := pathfsFrontend(masterkey, args.cipherdir, args.mountpoint, args.fusedebug, args.openssl, args.plaintextnames)
|
srv := pathfsFrontend(masterkey, args)
|
||||||
cryptfs.Info.Println("Filesystem ready.")
|
cryptfs.Info.Println("Filesystem ready.")
|
||||||
// We are ready - send USR1 signal to our parent
|
// We are ready - send USR1 signal to our parent
|
||||||
if args.notifypid > 0 {
|
if args.notifypid > 0 {
|
||||||
@ -281,12 +281,11 @@ func main() {
|
|||||||
// main exits with code 0
|
// main exits with code 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// pathfsFrontend - initialize FUSE server based on go-fuse's PathFS
|
// pathfsFrontend - initialize FUSE server based on go-fuse's PathFS.
|
||||||
// Calls os.Exit on errors
|
// Calls os.Exit on errors
|
||||||
func pathfsFrontend(key []byte, cipherdir string, mountpoint string,
|
func pathfsFrontend(key []byte, args argContainer) *fuse.Server {
|
||||||
debug bool, openssl bool, plaintextNames bool) *fuse.Server {
|
|
||||||
|
|
||||||
finalFs := pathfs_frontend.NewFS(key, cipherdir, openssl, plaintextNames)
|
finalFs := pathfs_frontend.NewFS(key, args.cipherdir, args.openssl, args.plaintextnames)
|
||||||
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}
|
pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}
|
||||||
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
|
pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)
|
||||||
fuseOpts := &nodefs.Options{
|
fuseOpts := &nodefs.Options{
|
||||||
@ -301,16 +300,16 @@ func pathfsFrontend(key []byte, cipherdir string, mountpoint string,
|
|||||||
mOpts.AllowOther = false
|
mOpts.AllowOther = false
|
||||||
// Set values shown in "df -T" and friends
|
// Set values shown in "df -T" and friends
|
||||||
// First column, "Filesystem"
|
// First column, "Filesystem"
|
||||||
mOpts.Options = append(mOpts.Options, "fsname="+cipherdir)
|
mOpts.Options = append(mOpts.Options, "fsname="+args.cipherdir)
|
||||||
// Second column, "Type", will be shown as "fuse." + Name
|
// Second column, "Type", will be shown as "fuse." + Name
|
||||||
mOpts.Name = "gocryptfs"
|
mOpts.Name = "gocryptfs"
|
||||||
|
|
||||||
srv, err := fuse.NewServer(conn.RawFS(), mountpoint, &mOpts)
|
srv, err := fuse.NewServer(conn.RawFS(), args.mountpoint, &mOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Mount failed: %v", err)
|
fmt.Printf("Mount failed: %v", err)
|
||||||
os.Exit(ERREXIT_MOUNT)
|
os.Exit(ERREXIT_MOUNT)
|
||||||
}
|
}
|
||||||
srv.SetDebug(debug)
|
srv.SetDebug(args.debug)
|
||||||
|
|
||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user