Skip to content

Commit 0cee9ab

Browse files
authored
Added additional pseudo filesystems (oshi#1105)
* Added additional pseudo filesystems * Fix typo * Move PSEUDO_FS into AbstractFileSystem * Rename PSEUDO_FS to PSEUDO_FS_TYPES to be more consistent * Fix typo
1 parent 5cadbd0 commit 0cee9ab

File tree

4 files changed

+58
-65
lines changed

4 files changed

+58
-65
lines changed

oshi-core/src/main/java/oshi/software/common/AbstractFileSystem.java

+55
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,61 @@ public abstract class AbstractFileSystem implements FileSystem {
3737
protected static final List<String> NETWORK_FS_TYPES = Arrays.asList( "afs", "cifs", "smbfs", "sshfs", "ncpfs", "ncp", "nfs", "nfs4",
3838
"gfs", "gds2", "glusterfs" );
3939

40+
41+
protected static final List<String> PSEUDO_FS_TYPES = Arrays.asList(//
42+
// Linux defines a set of virtual file systems
43+
"anon_inodefs", // anonymous inodes - inodes without filenames
44+
"autofs", // automounter file system, used by Linux, Solaris, FreeBSD
45+
"bdev", // keep track of block_device vs major/minor mapping
46+
"binfmt_misc", // Binary format support file system
47+
"bpf", // Virtual filesystem for Berkeley Paket Filter
48+
"cgroup", // Cgroup file system
49+
"cgroup2", // Cgroup file system
50+
"configfs", // Config file system
51+
"cpuset", // pseudo-filesystem interface to the kernel cpuset mechanism
52+
"dax", // Direct Access (DAX) can be used on memory-backed block devices
53+
"debugfs", // Debug file system
54+
"devpts", // Dev pseudo terminal devices file system
55+
"devtmpfs", // Dev temporary file system
56+
"drm", // Direct Rendering Manager
57+
"ecryptfs", // POSIX-compliant enterprise cryptographic filesystem for Linux
58+
"efivarfs", // (U)EFI variable filesystem
59+
"fuse", //
60+
// NOTE: FUSE's fuseblk is not evalued because used as file system
61+
// representation of a FUSE block storage
62+
// "fuseblk" // FUSE block file system
63+
"fusectl", // FUSE control file system
64+
"hugetlbfs", // Huge pages support file system
65+
"inotifyfs", // support inotify
66+
"mqueue", // Message queue file system
67+
"nfsd", // NFS file system
68+
"overlay", // Overlay file system https://wiki.archlinux.org/index.php/Overlay_filesystem
69+
// "pipefs", // for pipes but only visible inside kernel
70+
"proc", // Proc file system, used by Linux and Solaris
71+
"pstore", // Pstore file system
72+
// "ramfs", // Old filesystem used for RAM disks
73+
"rootfs", // Minimal fs to support kernel boot
74+
"rpc_pipefs", // Sun RPC file system
75+
"securityfs", // Kernel security file system
76+
"selinuxfs", // SELinux file system
77+
"sunrpc", // Sun RPC file system
78+
"sysfs", // SysFS file system
79+
"systemd-1", // Systemd file system
80+
// "tmpfs", // Temporary file system
81+
// NOTE: tmpfs is evaluated apart, because Linux, Solaris, FreeBSD use it for RAMdisks
82+
"tracefs", // thin stackable file system for capturing file system traces
83+
"usbfs", // removed in linux 3.5 but still seen in some systems
84+
// FreeBSD / Solaris defines a set of virtual file systems
85+
"procfs", // Proc file system
86+
"devfs", // Dev temporary file system
87+
"ctfs", // Contract file system
88+
"fdescfs", // fd
89+
"objfs", // Object file system
90+
"mntfs", // Mount file system
91+
"sharefs", // Share file system
92+
"lofs" // Library file system
93+
);
94+
4095
@Override
4196
public OSFileStore[] getFileStores() {
4297
return getFileStores(false);

oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystem.java

+1-32
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,6 @@
5555
public class LinuxFileSystem extends AbstractFileSystem {
5656

5757
private static final Logger LOG = LoggerFactory.getLogger(LinuxFileSystem.class);
58-
59-
// Linux defines a set of virtual file systems
60-
private static final List<String> PSEUDO_FS = Arrays.asList(//
61-
"rootfs", // Minimal fs to support kernel boot
62-
"sysfs", // SysFS file system
63-
"proc", // Proc file system
64-
"devtmpfs", // Dev temporary file system
65-
"devpts", // Dev pseudo terminal devices file system
66-
"securityfs", // Kernel security file system
67-
"cgroup", // Cgroup file system
68-
"pstore", // Pstore file system
69-
"hugetlbfs", // Huge pages support file system
70-
"configfs", // Config file system
71-
"selinuxfs", // SELinux file system
72-
"systemd-1", // Systemd file system
73-
"binfmt_misc", // Binary format support file system
74-
"mqueue", // Message queue file system
75-
"debugfs", // Debug file system
76-
"nfsd", // NFS file system
77-
"sunrpc", // Sun RPC file system
78-
"rpc_pipefs", // Sun RPC file system
79-
"fusectl", // FUSE control file system
80-
// NOTE: FUSE's fuseblk is not evalued because used as file system
81-
// representation of a FUSE block storage
82-
// "fuseblk" // FUSE block file system
83-
// "tmpfs", // Temporary file system
84-
// NOTE: tmpfs is evaluated apart, because Linux uses it for
85-
// RAMdisks
86-
"overlay" // Overlay file system https://wiki.archlinux.org/index.php/Overlay_filesystem
87-
);
88-
8958
// System path mounted as tmpfs
9059
private static final List<String> TMP_FS_PATHS = Arrays.asList("/run", "/sys", "/proc");
9160

@@ -138,7 +107,7 @@ private static List<OSFileStore> getFileStoreMatching(String nameToMatch, Map<St
138107
String path = split[1].replaceAll("\\\\040", " ");
139108
String type = split[2];
140109
if ((localOnly && NETWORK_FS_TYPES.contains(type)) // Skip non-local drives if requested
141-
|| PSEUDO_FS.contains(type) // exclude non-fs types
110+
|| PSEUDO_FS_TYPES.contains(type) // exclude non-fs types
142111
|| path.equals("/dev") // exclude plain dev directory
143112
|| ParseUtil.filePathStartsWith(TMP_FS_PATHS, path) // well known prefixes
144113
|| path.endsWith("/shm") // exclude shared memory

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystem.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,6 @@
4444
*/
4545
public class FreeBsdFileSystem extends AbstractFileSystem {
4646

47-
// Linux defines a set of virtual file systems
48-
private static final List<String> PSEUDO_FS = Arrays.asList( //
49-
"procfs", // Proc file system
50-
"devfs", // Dev temporary file system
51-
"ctfs", // Contract file system
52-
"fdescfs", // fd
53-
"objfs", // Object file system
54-
"mntfs", // Mount file system
55-
"sharefs", // Share file system
56-
"lofs", // Library file system
57-
"autofs" // Auto mounting fs
58-
// "tmpfs", // Temporary file system
59-
// NOTE: tmpfs is evaluated apart, because Solaris uses it for
60-
// RAMdisks
61-
);
62-
6347
// System path mounted as tmpfs
6448
private static final List<String> TMP_FS_PATHS = Arrays.asList("/system", "/tmp", "/dev/fd");
6549

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

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

oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystem.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,6 @@
4747
*/
4848
public class SolarisFileSystem extends AbstractFileSystem {
4949

50-
// Solaris defines a set of virtual file systems
51-
private static final List<String> PSEUDO_FS = Arrays.asList(//
52-
"proc", // Proc file system
53-
"devfs", // Dev temporary file system
54-
"ctfs", // Contract file system
55-
"objfs", // Object file system
56-
"mntfs", // Mount file system
57-
"sharefs", // Share file system
58-
"lofs", // Library file system
59-
"autofs" // Auto mounting fs
60-
// "tmpfs", // Temporary file system
61-
// NOTE: tmpfs is evaluated apart, because Solaris uses it for
62-
// RAMdisks
63-
);
64-
6550
// System path mounted as tmpfs
6651
private static final List<String> TMP_FS_PATHS = Arrays.asList("/system", "/tmp", "/dev/fd");
6752

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

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

0 commit comments

Comments
 (0)