Class AbstractOSFileStore

java.lang.Object
oshi.software.common.AbstractOSFileStore
All Implemented Interfaces:
OSFileStore
Direct Known Subclasses:
LinuxOSFileStore, MacOSFileStore, WindowsOSFileStore

@ThreadSafe public abstract class AbstractOSFileStore extends Object implements OSFileStore
Common implementations for OSFileStore
  • Constructor Details

    • AbstractOSFileStore

      protected AbstractOSFileStore(String name, String volume, String label, String mount, String options, String uuid, boolean local, String logicalVolume, String description, String fsType, long freeSpace, long usableSpace, long totalSpace, long freeInodes, long totalInodes)
      Creates an AbstractOSFileStore with all parameters.
      Parameters:
      name - the file store name
      volume - the volume name
      label - the volume label
      mount - the mount point
      options - the mount options
      uuid - the UUID
      local - whether this is a local file store
      logicalVolume - the logical volume
      description - the description
      fsType - the filesystem type
      freeSpace - free space in bytes
      usableSpace - usable space in bytes
      totalSpace - total space in bytes
      freeInodes - free inodes
      totalInodes - total inodes
  • Method Details

    • getName

      public String getName()
      Description copied from interface: OSFileStore
      Name of the File System. A human-readable label that does not necessarily correspond to a file system path.
      Specified by:
      getName in interface OSFileStore
      Returns:
      The file system name
    • getVolume

      public String getVolume()
      Description copied from interface: OSFileStore
      Volume name of the File System. Generally a path representing the device (e.g., /dev/foo which is being mounted.
      Specified by:
      getVolume in interface OSFileStore
      Returns:
      The volume name of the file system
    • getLabel

      public String getLabel()
      Description copied from interface: OSFileStore
      Label of the File System. An optional replacement for the name on Windows and Linux.
      Specified by:
      getLabel in interface OSFileStore
      Returns:
      The volume label of the file system. Only relevant on Windows and on Linux, if assigned; otherwise defaults to the FileSystem name. On other operating systems is redundant with the name.
    • getMount

      public String getMount()
      Description copied from interface: OSFileStore
      Mount point of the File System. The directory users will normally use to interface with the file store.
      Specified by:
      getMount in interface OSFileStore
      Returns:
      The mountpoint of the file system
    • getOptions

      public String getOptions()
      Description copied from interface: OSFileStore
      Filesystem options.
      Specified by:
      getOptions in interface OSFileStore
      Returns:
      A comma-deimited string of options
    • getUUID

      public String getUUID()
      Description copied from interface: OSFileStore
      UUID/GUID of the File System.
      Specified by:
      getUUID in interface OSFileStore
      Returns:
      The file system UUID/GUID
    • isLocal

      public boolean isLocal()
      Description copied from interface: OSFileStore
      Indicates whether this file store is local, providing low-latency access.

      Local file stores are directly attached storage that return immediate results for file operations. This excludes network-mounted file systems (e.g., NFS, CIFS/SMB, AFP) which may have higher latency or require network round-trips.

      On macOS, this corresponds to the MNT_LOCAL mount flag. On other platforms, this returns false for file systems with network types such as nfs, cifs, smbfs, and afs.

      Specified by:
      isLocal in interface OSFileStore
      Returns:
      true if the file store is locally attached (not a network drive); false otherwise
    • getLogicalVolume

      public String getLogicalVolume()
      Description copied from interface: OSFileStore
      Logical volume of the File System. Provides an optional alternative volume identifier for the file system. Only supported on Linux, provides symlink value via '/dev/mapper/' (used with LVM file systems).
      Specified by:
      getLogicalVolume in interface OSFileStore
      Returns:
      The logical volume of the file system
    • getDescription

      public String getDescription()
      Description copied from interface: OSFileStore
      Description of the File System.
      Specified by:
      getDescription in interface OSFileStore
      Returns:
      The file system description
    • getType

      public String getType()
      Description copied from interface: OSFileStore
      Type of the File System (FAT, NTFS, etx2, ext4, etc.)
      Specified by:
      getType in interface OSFileStore
      Returns:
      The file system type
    • getFreeSpace

      public long getFreeSpace()
      Description copied from interface: OSFileStore
      Free space on the drive. This space is unallocated but may require elevated permissions to write.
      Specified by:
      getFreeSpace in interface OSFileStore
      Returns:
      Free space on the drive (in bytes)
    • getUsableSpace

      public long getUsableSpace()
      Description copied from interface: OSFileStore
      Usable space on the drive. This is space available to unprivileged users.
      Specified by:
      getUsableSpace in interface OSFileStore
      Returns:
      Usable space on the drive (in bytes)
    • getTotalSpace

      public long getTotalSpace()
      Description copied from interface: OSFileStore
      Total space/capacity of the drive.
      Specified by:
      getTotalSpace in interface OSFileStore
      Returns:
      Total capacity of the drive (in bytes)
    • getFreeInodes

      public long getFreeInodes()
      Description copied from interface: OSFileStore
      Usable / free inodes on the drive. Not applicable on Windows.
      Specified by:
      getFreeInodes in interface OSFileStore
      Returns:
      Usable / free inodes on the drive (count), or -1 if unimplemented
    • getTotalInodes

      public long getTotalInodes()
      Description copied from interface: OSFileStore
      Total / maximum number of inodes of the filesystem. Not applicable on Windows.
      Specified by:
      getTotalInodes in interface OSFileStore
      Returns:
      Total / maximum number of inodes of the filesystem (count), or -1 if unimplemented
    • updateFrom

      protected void updateFrom(OSFileStore fileStore)
      Copies mutable attributes from another file store into this one.
      Parameters:
      fileStore - the source file store
    • updateSpaceAndInodes

      protected void updateSpaceAndInodes(long freeSpace, long usableSpace, long totalSpace, long freeInodes, long totalInodes)
      Updates only the space and inode fields.
      Parameters:
      freeSpace - free space in bytes
      usableSpace - usable space in bytes
      totalSpace - total space in bytes
      freeInodes - free inodes
      totalInodes - total inodes
    • updateSpace

      protected void updateSpace(long freeSpace, long usableSpace, long totalSpace)
      Updates only the space fields (no inodes).
      Parameters:
      freeSpace - free space in bytes
      usableSpace - usable space in bytes
      totalSpace - total space in bytes
    • toString

      public String toString()
      Overrides:
      toString in class Object