Class LinuxHWDiskStore

java.lang.Object
oshi.hardware.common.AbstractHWDiskStore
oshi.hardware.common.platform.linux.LinuxHWDiskStore
All Implemented Interfaces:
HWDiskStore
Direct Known Subclasses:
LinuxHWDiskStoreNF

@ThreadSafe public abstract class LinuxHWDiskStore extends AbstractHWDiskStore
Linux hard disk implementation.
  • Field Details

  • Constructor Details

    • LinuxHWDiskStore

      protected LinuxHWDiskStore(String name, String model, String serial, long size)
      Creates a LinuxHWDiskStore with unknown disk type.
      Parameters:
      name - the disk name
      model - the disk model
      serial - the serial number
      size - the disk size in bytes
    • LinuxHWDiskStore

      protected LinuxHWDiskStore(String name, String model, String serial, long size, String diskType)
      Creates a LinuxHWDiskStore.
      Parameters:
      name - the disk name
      model - the disk model
      serial - the serial number
      size - the disk size in bytes
      diskType - the disk type
  • Method Details

    • getMutablePartitionList

      protected List<HWPartition> getMutablePartitionList()
      Gets the mutable partition list for building.
      Returns:
      the mutable partition list
    • computeDiskStats

      protected static void computeDiskStats(LinuxHWDiskStore store, String devstat)
      Computes and sets disk statistics from a stat string.
      Parameters:
      store - the disk store to update
      devstat - the stat string from sysfs or /proc/diskstats
    • readMountsMap

      protected static Map<String,String> readMountsMap()
      Reads /proc/mounts into a map of device to mount point.
      Returns:
      a map of device paths to mount points
    • getPartitionNameForDmDevice

      protected static String getPartitionNameForDmDevice(String vgName, String lvName)
      Gets the partition name for a device-mapper device.
      Parameters:
      vgName - the volume group name
      lvName - the logical volume name
      Returns:
      the partition name path
    • getMountPointOfDmDevice

      protected static String getMountPointOfDmDevice(String vgName, String lvName)
      Gets the mount point path for a device-mapper device.
      Parameters:
      vgName - the volume group name
      lvName - the logical volume name
      Returns:
      the mount point path
    • getModelForDmDevice

      protected static String getModelForDmDevice(String dmUuid)
      Gets the model description for a device-mapper device.
      Parameters:
      dmUuid - the device-mapper UUID
      Returns:
      the model description
    • isLogicalVolume

      protected static boolean isLogicalVolume(String dmUuid)
      Checks whether a device-mapper UUID identifies an LVM logical volume.
      Parameters:
      dmUuid - the device-mapper UUID
      Returns:
      whether the UUID identifies an LVM logical volume
    • isEncryptedVolume

      protected static boolean isEncryptedVolume(String dmUuid)
      Checks whether a device-mapper UUID identifies an encrypted volume.
      Parameters:
      dmUuid - the device-mapper UUID
      Returns:
      whether the UUID identifies an encrypted volume
    • getDmDevicePath

      protected static String getDmDevicePath(String dmName, String devnode)
      Gets the preferred path for a device-mapper device.
      Parameters:
      dmName - the device-mapper name
      devnode - the device node path
      Returns:
      the device path
    • getMountPointForDmDevice

      protected static String getMountPointForDmDevice(Map<String,String> mountsMap, String dmName, String devnode, String sysPath)
      Gets the mount point for a device-mapper device.
      Parameters:
      mountsMap - the map of device paths to mount points
      dmName - the device-mapper name
      devnode - the device node path
      sysPath - the sysfs path for the device
      Returns:
      the mount point or dependent device names
    • addDeviceMapperPartition

      protected static void addDeviceMapperPartition(LinuxHWDiskStore store, Map<String,String> mountsMap, String dmUuid, String vgName, String lvName, String dmName, String devnode, String sysname, String sysPath, String fsType, String fsUuid, String fsLabel, long size, int major, int minor)
      Adds a partition entry for a supported device-mapper device.
      Parameters:
      store - the disk store to update
      mountsMap - the map of device paths to mount points
      dmUuid - the device-mapper UUID
      vgName - the LVM volume group name
      lvName - the LVM logical volume name
      dmName - the device-mapper name
      devnode - the device node path
      sysname - the sysfs device name
      sysPath - the sysfs path for the device
      fsType - the filesystem type
      fsUuid - the filesystem UUID
      fsLabel - the filesystem label
      size - the partition size in bytes
      major - the major device ID
      minor - the minor device ID
    • getDependentNamesFromHoldersDirectory

      protected static String getDependentNamesFromHoldersDirectory(String sysPath)
      Gets dependent device names from the holders directory.
      Parameters:
      sysPath - the sysfs path for the device
      Returns:
      space-separated holder names, or empty string
    • finalizePartitions

      protected static void finalizePartitions(List<HWDiskStore> result)
      Sorts and makes partition lists unmodifiable for all disk stores.
      Parameters:
      result - the list of disk stores to finalize