1
2
3
4
5 package oshi.driver.unix.freebsd.disk;
6
7 import java.util.HashMap;
8 import java.util.Map;
9 import java.util.regex.Matcher;
10 import java.util.regex.Pattern;
11
12 import oshi.annotation.concurrent.ThreadSafe;
13 import oshi.util.ExecutingCommand;
14
15
16
17
18 @ThreadSafe
19 public final class Mount {
20
21 private static final String MOUNT_CMD = "mount";
22 private static final Pattern MOUNT_PATTERN = Pattern.compile("/dev/(\\S+p\\d+) on (\\S+) .*");
23
24 private Mount() {
25 }
26
27
28
29
30
31
32 public static Map<String, String> queryPartitionToMountMap() {
33
34 Map<String, String> mountMap = new HashMap<>();
35 for (String mnt : ExecutingCommand.runNative(MOUNT_CMD)) {
36 Matcher m = MOUNT_PATTERN.matcher(mnt);
37 if (m.matches()) {
38 mountMap.put(m.group(1), m.group(2));
39 }
40 }
41 return mountMap;
42 }
43 }