1
2
3
4
5 package oshi.util.platform.linux;
6
7 import java.io.File;
8
9 import oshi.annotation.concurrent.ThreadSafe;
10 import oshi.util.GlobalConfig;
11
12
13
14
15
16
17
18 @ThreadSafe
19 public final class DevPath {
20
21
22
23
24 public static final String DEV = queryDevConfig() + "/";
25
26 public static final String DISK_BY_UUID = DEV + "disk/by-uuid";
27 public static final String DM = DEV + "dm";
28 public static final String LOOP = DEV + "loop";
29 public static final String MAPPER = DEV + "mapper/";
30 public static final String RAM = DEV + "ram";
31
32 private DevPath() {
33 }
34
35 private static String queryDevConfig() {
36 String devPath = GlobalConfig.get(GlobalConfig.OSHI_UTIL_DEV_PATH, "/dev");
37
38 devPath = '/' + devPath.replaceAll("/$|^/", "");
39 if (!new File(devPath).exists()) {
40 throw new GlobalConfig.PropertyException(GlobalConfig.OSHI_UTIL_DEV_PATH, "The path does not exist");
41 }
42 return devPath;
43 }
44 }