1
2
3
4
5 package oshi.driver.unix.solaris.disk;
6
7 import java.util.HashMap;
8 import java.util.List;
9 import java.util.Map;
10
11 import oshi.annotation.concurrent.ThreadSafe;
12 import oshi.util.ExecutingCommand;
13 import oshi.util.ParseUtil;
14
15
16
17
18 @ThreadSafe
19 public final class Lshal {
20
21 private static final String LSHAL_CMD = "lshal";
22
23 private Lshal() {
24 }
25
26
27
28
29
30
31
32 public static Map<String, Integer> queryDiskToMajorMap() {
33 Map<String, Integer> majorMap = new HashMap<>();
34 List<String> lshal = ExecutingCommand.runNative(LSHAL_CMD);
35 String diskName = null;
36 for (String line : lshal) {
37 if (line.startsWith("udi ")) {
38 String udi = ParseUtil.getSingleQuoteStringValue(line);
39 diskName = udi.substring(udi.lastIndexOf('/') + 1);
40 } else {
41 line = line.trim();
42 if (line.startsWith("block.major") && diskName != null) {
43 majorMap.put(diskName, ParseUtil.getFirstIntValue(line));
44 }
45 }
46 }
47 return majorMap;
48 }
49 }