Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/pkg/fsutil/fsutil_linux.go
2601 views
1
// SPDX-FileCopyrightText: Copyright The Lima Authors
2
// SPDX-License-Identifier: Apache-2.0
3
4
package fsutil
5
6
import (
7
"errors"
8
"os"
9
"path/filepath"
10
11
"golang.org/x/sys/unix"
12
)
13
14
// IsNFS checks if the path is on NFS. If the path does not exist yet, it will walk
15
// up parent directories until one exists, or it hits '/' or '.'.
16
// Any other stat errors will cause IsNFS to fail.
17
func IsNFS(path string) (bool, error) {
18
for len(path) > 1 {
19
_, err := os.Stat(path)
20
if err == nil {
21
break
22
}
23
if !errors.Is(err, os.ErrNotExist) {
24
return false, err
25
}
26
path = filepath.Dir(path)
27
}
28
29
var sf unix.Statfs_t
30
if err := unix.Statfs(path, &sf); err != nil {
31
return false, err
32
}
33
return sf.Type == unix.NFS_SUPER_MAGIC, nil
34
}
35
36