Make weed-fuse compatible with systemd-based mount (#6814)
* Make weed-fuse compatible with systemd-mount series * fix: add missing type annotation on skipAutofs param in FreeBSD build The parameter was declared without a type, causing a compile error on FreeBSD. * fix: guard hasAutofs nil dereference and make FsName conditional on autofs mode - Check option.hasAutofs for nil before dereferencing to prevent panic when RunMount is called without the flag initialized. - Only set FsName to "fuse" when autofs mode is active; otherwise preserve the descriptive server:path name for mount/df output. - Fix typo: recogize -> recognize. * fix: consistent error handling for autofs option and log ignored _netdev - Replace panic with fmt.Fprintf+return false for autofs parse errors, matching the pattern used by other fuse option parsers. - Log when _netdev option is silently stripped to aid debugging. --------- Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
@@ -223,13 +223,21 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
}
|
||||
|
||||
// Ensure target mount point availability
|
||||
if isValid := checkMountPointAvailable(dir); !isValid {
|
||||
skipAutofs := option.hasAutofs != nil && *option.hasAutofs
|
||||
if isValid := checkMountPointAvailable(dir, skipAutofs); !isValid {
|
||||
glog.Fatalf("Target mount point is not available: %s, please check!", dir)
|
||||
return true
|
||||
}
|
||||
|
||||
serverFriendlyName := strings.ReplaceAll(*option.filer, ",", "+")
|
||||
|
||||
// When autofs/systemd-mount is used, FsName must be "fuse" so util-linux/mount can recognize
|
||||
// it as a pseudo filesystem. Otherwise, preserve the descriptive name for mount/df output.
|
||||
fsName := serverFriendlyName + ":" + filerMountRootPath
|
||||
if skipAutofs {
|
||||
fsName = "fuse"
|
||||
}
|
||||
|
||||
// mount fuse
|
||||
fuseMountOptions := &fuse.MountOptions{
|
||||
AllowOther: *option.allowOthers,
|
||||
@@ -239,7 +247,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||
MaxReadAhead: 1024 * 1024 * 2,
|
||||
IgnoreSecurityLabels: false,
|
||||
RememberInodes: false,
|
||||
FsName: serverFriendlyName + ":" + filerMountRootPath,
|
||||
FsName: fsName,
|
||||
Name: "seaweedfs",
|
||||
SingleThreaded: false,
|
||||
DisableXAttrs: *option.disableXAttr,
|
||||
|
||||
Reference in New Issue
Block a user