Skip to content

Commit a969d80

Browse files
author
jogi
committed
Merge remote-tracking branch 'upstream/master'
2 parents 6cadb69 + 0cee9ab commit a969d80

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxDisks.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
3333

34+
import com.sun.jna.Pointer;
35+
3436
import oshi.hardware.Disks;
3537
import oshi.hardware.HWDiskStore;
3638
import oshi.hardware.HWPartition;
@@ -119,12 +121,16 @@ public HWDiskStore[] getDisks() {
119121
LOG.debug("Reached all disks. Exiting ");
120122
break;
121123
}
124+
String devnode = Udev.INSTANCE.udev_device_get_devnode(device);
125+
if (devnode == null) {
126+
LOG.warn("Failed to retrieve devnode for device {}", Pointer.nativeValue(device.getPointer()));
127+
continue;
128+
}
122129
// Ignore loopback and ram disks; do nothing
123-
if (!Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/loop")
124-
&& !Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/ram")) {
130+
if (!devnode.startsWith("/dev/loop") && !devnode.startsWith("/dev/ram")) {
125131
if ("disk".equals(Udev.INSTANCE.udev_device_get_devtype(device))) {
126132
store = new HWDiskStore();
127-
store.setName(Udev.INSTANCE.udev_device_get_devnode(device));
133+
store.setName(devnode);
128134

129135
// Avoid model and serial in virtual environments
130136
store.setModel(Udev.INSTANCE.udev_device_get_property_value(device, "ID_MODEL") == null ? "Unknown"

0 commit comments

Comments
 (0)