1
2
3
4
5 package oshi.driver.unix.aix;
6
7 import java.util.HashMap;
8 import java.util.Map;
9
10 import oshi.annotation.concurrent.ThreadSafe;
11 import oshi.util.ExecutingCommand;
12 import oshi.util.ParseUtil;
13 import oshi.util.tuples.Pair;
14
15
16
17
18 @ThreadSafe
19 public final class Ls {
20
21 private Ls() {
22 }
23
24
25
26
27
28
29 public static Map<String, Pair<Integer, Integer>> queryDeviceMajorMinor() {
30
31
32
33
34
35
36 Map<String, Pair<Integer, Integer>> majMinMap = new HashMap<>();
37 for (String s : ExecutingCommand.runNative("ls -l /dev")) {
38
39 if (!s.isEmpty() && s.charAt(0) == 'b') {
40
41 int idx = s.lastIndexOf(' ');
42 if (idx > 0 && idx < s.length()) {
43 String device = s.substring(idx + 1);
44 int major = ParseUtil.getNthIntValue(s, 2);
45 int minor = ParseUtil.getNthIntValue(s, 3);
46 majMinMap.put(device, new Pair<>(major, minor));
47 }
48 }
49 }
50 return majMinMap;
51 }
52 }