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:
Weihao Jiang
2026-03-19 03:18:40 +08:00
committed by GitHub
parent e59bcfebcc
commit 01987bcafd
6 changed files with 39 additions and 7 deletions

View File

@@ -69,7 +69,7 @@ type Info struct {
// Mounted determines if a specified mountpoint has been mounted.
// On Linux it looks at /proc/self/mountinfo and on Solaris at mnttab.
func mounted(mountPoint string) (bool, error) {
func mounted(mountPoint string, skipAutofs bool) (bool, error) {
entries, err := parseMountTable()
if err != nil {
return false, err
@@ -78,6 +78,10 @@ func mounted(mountPoint string) (bool, error) {
// Search the table for the mountPoint
for _, e := range entries {
if e.Mountpoint == mountPoint {
// Check if the mountpoint is autofs
if skipAutofs && e.Fstype == "autofs" {
continue
}
return true, nil
}
}
@@ -137,13 +141,13 @@ func parseInfoFile(r io.Reader) ([]*Info, error) {
return out, nil
}
func checkMountPointAvailable(dir string) bool {
func checkMountPointAvailable(dir string, skipAutofs bool) bool {
mountPoint := dir
if mountPoint != "/" && strings.HasSuffix(mountPoint, "/") {
mountPoint = mountPoint[0 : len(mountPoint)-1]
}
if mounted, err := mounted(mountPoint); err != nil || mounted {
if mounted, err := mounted(mountPoint, skipAutofs); err != nil || mounted {
if err != nil {
glog.Errorf("check %s: %v", mountPoint, err)
}