Skip to content

Commit

Permalink
drivers: enhance check for mount fs type
Browse files Browse the repository at this point in the history
when checking that a mount has a specific file system type, also
validate that it is different than its parent directory.

This helps when using virtiofs as the underlying file system since the
check used for fuse-overlayfs would fail since they both use FUSE.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Jun 14, 2022
1 parent 8951d01 commit f10e276
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/driver_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package graphdriver
Expand Down Expand Up @@ -168,5 +169,16 @@ func Mounted(fsType FsMagic, mountPath string) (bool, error) {
if err := unix.Statfs(mountPath, &buf); err != nil {
return false, err
}
return FsMagic(buf.Type) == fsType, nil
if FsMagic(buf.Type) != fsType {
return false, nil
}
// it is already the root
if mountPath == "/" {
return true, nil
}

if err := unix.Statfs(filepath.Dir(mountPath), &buf); err != nil {
return true, err
}
return FsMagic(buf.Type) != fsType, nil
}

0 comments on commit f10e276

Please sign in to comment.