diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-12-27 20:49:27 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-12-27 20:49:27 +0900 |
| commit | ef1ebf12d98359c0d75ce48a1b05737f7e4e93c0 (patch) | |
| tree | 4953ff9b2ee1ae400b3cf4ffb130f7da0650d514 /cmd/sharefs/main.go | |
| parent | 775a9f57c9ec3bc6877e3973a8c4972558707375 (diff) | |
cmd/sharefs: handle mount -t fuse.sharefs
This should have been handled in a custom option parsing function, but that much extra complexity is unnecessary for this edge case. Honestly I do not know why libfuse does not handle this itself.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/sharefs/main.go')
| -rw-r--r-- | cmd/sharefs/main.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cmd/sharefs/main.go b/cmd/sharefs/main.go index 941a1668..c9fe9f2f 100644 --- a/cmd/sharefs/main.go +++ b/cmd/sharefs/main.go @@ -3,14 +3,29 @@ package main import ( "log" "os" + "slices" ) // sharefsName is the prefix used by log.std in the sharefs process. const sharefsName = "sharefs" +// handleMountArgs returns an alternative, libfuse-compatible args slice for +// args passed by mount -t fuse.sharefs [options] sharefs <mountpoint>. +// +// In this case, args always has a length of 5 with index 0 being what comes +// after "fuse." in the filesystem type, 1 is the uninterpreted string passed +// to mount (sharefsName is used as the magic string to enable this hack), +// 2 is passed through to libfuse as mountpoint, and 3 is always "-o". +func handleMountArgs(args []string) []string { + if len(args) == 5 && args[1] == sharefsName && args[3] == "-o" { + return []string{sharefsName, args[2], "-o", args[4]} + } + return slices.Clone(args) +} + func main() { log.SetFlags(0) log.SetPrefix(sharefsName + ": ") - os.Exit(_main(os.Args...)) + os.Exit(_main(handleMountArgs(os.Args)...)) } |
