// SPDX-FileCopyrightText: Copyright The Lima Authors1// SPDX-License-Identifier: Apache-2.023package fsutil45import (6"errors"7"os"8"path/filepath"910"golang.org/x/sys/unix"11)1213// IsNFS checks if the path is on NFS. If the path does not exist yet, it will walk14// up parent directories until one exists, or it hits '/' or '.'.15// Any other stat errors will cause IsNFS to fail.16func IsNFS(path string) (bool, error) {17for len(path) > 1 {18_, err := os.Stat(path)19if err == nil {20break21}22if !errors.Is(err, os.ErrNotExist) {23return false, err24}25path = filepath.Dir(path)26}2728var sf unix.Statfs_t29if err := unix.Statfs(path, &sf); err != nil {30return false, err31}32return sf.Type == unix.NFS_SUPER_MAGIC, nil33}343536