Skip to content

Commit

Permalink
Added additional pseudo filesystems (#1105)
Browse files Browse the repository at this point in the history
* Added additional pseudo filesystems

* Fix typo

* Move PSEUDO_FS into AbstractFileSystem

* Rename PSEUDO_FS to PSEUDO_FS_TYPES to be more consistent

* Fix typo
  • Loading branch information
Space2Man committed Feb 13, 2020
1 parent 5cadbd0 commit 0cee9ab
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,61 @@ public abstract class AbstractFileSystem implements FileSystem {
protected static final List<String> NETWORK_FS_TYPES = Arrays.asList( "afs", "cifs", "smbfs", "sshfs", "ncpfs", "ncp", "nfs", "nfs4",
"gfs", "gds2", "glusterfs" );


protected static final List<String> PSEUDO_FS_TYPES = Arrays.asList(//
// Linux defines a set of virtual file systems
"anon_inodefs", // anonymous inodes - inodes without filenames
"autofs", // automounter file system, used by Linux, Solaris, FreeBSD
"bdev", // keep track of block_device vs major/minor mapping
"binfmt_misc", // Binary format support file system
"bpf", // Virtual filesystem for Berkeley Paket Filter
"cgroup", // Cgroup file system
"cgroup2", // Cgroup file system
"configfs", // Config file system
"cpuset", // pseudo-filesystem interface to the kernel cpuset mechanism
"dax", // Direct Access (DAX) can be used on memory-backed block devices
"debugfs", // Debug file system
"devpts", // Dev pseudo terminal devices file system
"devtmpfs", // Dev temporary file system
"drm", // Direct Rendering Manager
"ecryptfs", // POSIX-compliant enterprise cryptographic filesystem for Linux
"efivarfs", // (U)EFI variable filesystem
"fuse", //
// NOTE: FUSE's fuseblk is not evalued because used as file system
// representation of a FUSE block storage
// "fuseblk" // FUSE block file system
"fusectl", // FUSE control file system
"hugetlbfs", // Huge pages support file system
"inotifyfs", // support inotify
"mqueue", // Message queue file system
"nfsd", // NFS file system
"overlay", // Overlay file system https://wiki.archlinux.org/index.php/Overlay_filesystem
// "pipefs", // for pipes but only visible inside kernel
"proc", // Proc file system, used by Linux and Solaris
"pstore", // Pstore file system
// "ramfs", // Old filesystem used for RAM disks
"rootfs", // Minimal fs to support kernel boot
"rpc_pipefs", // Sun RPC file system
"securityfs", // Kernel security file system
"selinuxfs", // SELinux file system
"sunrpc", // Sun RPC file system
"sysfs", // SysFS file system
"systemd-1", // Systemd file system
// "tmpfs", // Temporary file system
// NOTE: tmpfs is evaluated apart, because Linux, Solaris, FreeBSD use it for RAMdisks
"tracefs", // thin stackable file system for capturing file system traces
"usbfs", // removed in linux 3.5 but still seen in some systems
// FreeBSD / Solaris defines a set of virtual file systems
"procfs", // Proc file system
"devfs", // Dev temporary file system
"ctfs", // Contract file system
"fdescfs", // fd
"objfs", // Object file system
"mntfs", // Mount file system
"sharefs", // Share file system
"lofs" // Library file system
);

@Override
public OSFileStore[] getFileStores() {
return getFileStores(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,6 @@
public class LinuxFileSystem extends AbstractFileSystem {

private static final Logger LOG = LoggerFactory.getLogger(LinuxFileSystem.class);

// Linux defines a set of virtual file systems
private static final List<String> PSEUDO_FS = Arrays.asList(//
"rootfs", // Minimal fs to support kernel boot
"sysfs", // SysFS file system
"proc", // Proc file system
"devtmpfs", // Dev temporary file system
"devpts", // Dev pseudo terminal devices file system
"securityfs", // Kernel security file system
"cgroup", // Cgroup file system
"pstore", // Pstore file system
"hugetlbfs", // Huge pages support file system
"configfs", // Config file system
"selinuxfs", // SELinux file system
"systemd-1", // Systemd file system
"binfmt_misc", // Binary format support file system
"mqueue", // Message queue file system
"debugfs", // Debug file system
"nfsd", // NFS file system
"sunrpc", // Sun RPC file system
"rpc_pipefs", // Sun RPC file system
"fusectl", // FUSE control file system
// NOTE: FUSE's fuseblk is not evalued because used as file system
// representation of a FUSE block storage
// "fuseblk" // FUSE block file system
// "tmpfs", // Temporary file system
// NOTE: tmpfs is evaluated apart, because Linux uses it for
// RAMdisks
"overlay" // Overlay file system https://wiki.archlinux.org/index.php/Overlay_filesystem
);

// System path mounted as tmpfs
private static final List<String> TMP_FS_PATHS = Arrays.asList("/run", "/sys", "/proc");

Expand Down Expand Up @@ -138,7 +107,7 @@ private static List<OSFileStore> getFileStoreMatching(String nameToMatch, Map<St
String path = split[1].replaceAll("\\\\040", " ");
String type = split[2];
if ((localOnly && NETWORK_FS_TYPES.contains(type)) // Skip non-local drives if requested
|| PSEUDO_FS.contains(type) // exclude non-fs types
|| PSEUDO_FS_TYPES.contains(type) // exclude non-fs types
|| path.equals("/dev") // exclude plain dev directory
|| ParseUtil.filePathStartsWith(TMP_FS_PATHS, path) // well known prefixes
|| path.endsWith("/shm") // exclude shared memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@
*/
public class FreeBsdFileSystem extends AbstractFileSystem {

// Linux defines a set of virtual file systems
private static final List<String> PSEUDO_FS = Arrays.asList( //
"procfs", // Proc file system
"devfs", // Dev temporary file system
"ctfs", // Contract file system
"fdescfs", // fd
"objfs", // Object file system
"mntfs", // Mount file system
"sharefs", // Share file system
"lofs", // Library file system
"autofs" // Auto mounting fs
// "tmpfs", // Temporary file system
// NOTE: tmpfs is evaluated apart, because Solaris uses it for
// RAMdisks
);

// System path mounted as tmpfs
private static final List<String> TMP_FS_PATHS = Arrays.asList("/system", "/tmp", "/dev/fd");

Expand Down Expand Up @@ -122,7 +106,7 @@ public OSFileStore[] getFileStores(boolean localOnly) {
String options = split[3];

// Skip non-local drives if requested, and exclude pseudo file systems
if ((localOnly && NETWORK_FS_TYPES.contains(type)) || PSEUDO_FS.contains(type) || path.equals("/dev")
if ((localOnly && NETWORK_FS_TYPES.contains(type)) || PSEUDO_FS_TYPES.contains(type) || path.equals("/dev")
|| ParseUtil.filePathStartsWith(TMP_FS_PATHS, path)
|| volume.startsWith("rpool") && !path.equals("/")) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@
*/
public class SolarisFileSystem extends AbstractFileSystem {

// Solaris defines a set of virtual file systems
private static final List<String> PSEUDO_FS = Arrays.asList(//
"proc", // Proc file system
"devfs", // Dev temporary file system
"ctfs", // Contract file system
"objfs", // Object file system
"mntfs", // Mount file system
"sharefs", // Share file system
"lofs", // Library file system
"autofs" // Auto mounting fs
// "tmpfs", // Temporary file system
// NOTE: tmpfs is evaluated apart, because Solaris uses it for
// RAMdisks
);

// System path mounted as tmpfs
private static final List<String> TMP_FS_PATHS = Arrays.asList("/system", "/tmp", "/dev/fd");

Expand Down Expand Up @@ -125,7 +110,7 @@ private static List<OSFileStore> getFileStoreMatching(String nameToMatch, boolea
String options = split[3];

// Skip non-local drives if requested, and exclude pseudo file systems
if ((localOnly && NETWORK_FS_TYPES.contains(type)) || PSEUDO_FS.contains(type) || path.equals("/dev")
if ((localOnly && NETWORK_FS_TYPES.contains(type)) || PSEUDO_FS_TYPES.contains(type) || path.equals("/dev")
|| ParseUtil.filePathStartsWith(TMP_FS_PATHS, path)
|| volume.startsWith("rpool") && !path.equals("/")) {
continue;
Expand Down

0 comments on commit 0cee9ab

Please sign in to comment.