Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/oshi/oshi into openbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis committed Jan 17, 2021
2 parents 7b9e519 + c5fd098 commit e953502
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[#1489](https://github.com/oshi/oshi/pull/1489): Use IOUSB plane to iterate/recurse Mac USB tree - [@dbwiddis](https://github.com/dbwiddis).
* [#1490](https://github.com/oshi/oshi/pull/1490): Apple M1 Baseboard and Firmware backups - [@dbwiddis](https://github.com/dbwiddis).
* [#1494](https://github.com/oshi/oshi/pull/1494): Deprecate MACOSX platform enum - [@dbwiddis](https://github.com/dbwiddis).
* [#1495](https://github.com/oshi/oshi/pull/1495): Report Linux filesystem label - [@dbwiddis](https://github.com/dbwiddis).


# 5.3.0 (2020-10-11), 5.3.1 (2020-10-18), 5.3.2 (2020-10-25), 5.3.3 (2020-10-28), 5.3.4 (2020-11-01), 5.3.5 (2020-11-11), 5.3.6 (2020-11-15), 5.3.7 (2020-12-20)
Expand Down
5 changes: 3 additions & 2 deletions oshi-core/src/main/java/oshi/software/os/OSFileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public interface OSFileStore {
/**
* Label of the File System
*
* @return The volume label of the file system, on Windows. Other operating
* systems is redundant with the name.
* @return 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.
*/
String getLabel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import oshi.annotation.concurrent.ThreadSafe;
import oshi.software.common.AbstractFileSystem;
import oshi.software.os.OSFileStore;
import oshi.util.ExecutingCommand;
import oshi.util.FileSystemUtil;
import oshi.util.FileUtil;
import oshi.util.ParseUtil;
Expand Down Expand Up @@ -122,6 +123,8 @@ private static List<OSFileStore> getFileStoreMatching(String nameToMatch, Map<St
boolean localOnly) {
List<OSFileStore> fsList = new ArrayList<>();

Map<String, String> labelMap = queryLabelMap();

// Parse /proc/mounts to get fs types
List<String> mounts = FileUtil.readFile(ProcPath.MOUNTS);
for (String mount : mounts) {
Expand Down Expand Up @@ -217,12 +220,23 @@ private static List<OSFileStore> getFileStoreMatching(String nameToMatch, Map<St
LOG.error("Failed to get file counts from statvfs. {}", e.getMessage());
}

fsList.add(new LinuxOSFileStore(name, volume, name, path, options, uuid, logicalVolume, description, type,
freeSpace, usableSpace, totalSpace, freeInodes, totalInodes));
fsList.add(new LinuxOSFileStore(name, volume, labelMap.getOrDefault(path, name), path, options, uuid,
logicalVolume, description, type, freeSpace, usableSpace, totalSpace, freeInodes, totalInodes));
}
return fsList;
}

private static Map<String, String> queryLabelMap() {
Map<String, String> labelMap = new HashMap<>();
for (String line : ExecutingCommand.runNative("lsblk -o mountpoint,label")) {
String[] split = ParseUtil.whitespaces.split(line, 2);
if (split.length == 2) {
labelMap.put(split[0], split[1]);
}
}
return labelMap;
}

@Override
public long getOpenFileDescriptors() {
return getFileDescriptors(0);
Expand Down
4 changes: 3 additions & 1 deletion oshi-core/src/main/resources/oshi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ oshi.pseudo.filesystem.types=anon_inodefs,autofs,bdev,binfmt_misc,bpf,cgroup,cgr
# https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)
# The "glob:" syntax is automatically added unless another syntax (regex:) is specified.
# Similar syntax may be used for "includes" which take precedence over excludes.
oshi.os.aix.filesystem.path.excludes=/run**,/sys**,/dev,/proc**,[!/]**

# Note: glob:* mathches all paths not starting with /
oshi.os.aix.filesystem.path.excludes=/run**,/sys**,/dev,/proc**,*

oshi.os.freebsd.filesystem.path.excludes=/system**,/tmp**,/dev,/dev/fd**
oshi.os.freebsd.filesystem.volume.excludes=rpool*
Expand Down

0 comments on commit e953502

Please sign in to comment.