github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/util/mountOpts_linux.go (about)

     1  package util
     2  
     3  import (
     4  	"os"
     5  
     6  	"golang.org/x/sys/unix"
     7  )
     8  
     9  func getDefaultMountOptions(path string) (defaultMountOptions, error) {
    10  	opts := defaultMountOptions{false, true, true}
    11  	if path == "" {
    12  		return opts, nil
    13  	}
    14  	var statfs unix.Statfs_t
    15  	if e := unix.Statfs(path, &statfs); e != nil {
    16  		return opts, &os.PathError{Op: "statfs", Path: path, Err: e}
    17  	}
    18  	opts.nodev = (statfs.Flags&unix.MS_NODEV == unix.MS_NODEV)
    19  	opts.noexec = (statfs.Flags&unix.MS_NOEXEC == unix.MS_NOEXEC)
    20  	opts.nosuid = (statfs.Flags&unix.MS_NOSUID == unix.MS_NOSUID)
    21  
    22  	return opts, nil
    23  }