1
2
3
4
5 package oshi.driver.linux;
6
7 import oshi.annotation.concurrent.ThreadSafe;
8 import oshi.util.FileUtil;
9 import oshi.util.ParseUtil;
10 import oshi.util.Util;
11 import oshi.util.platform.linux.SysPath;
12
13
14
15
16 @ThreadSafe
17 public final class Sysfs {
18
19 private Sysfs() {
20 }
21
22
23
24
25
26
27 public static String querySystemVendor() {
28 final String sysVendor = FileUtil.getStringFromFile(SysPath.DMI_ID + "sys_vendor").trim();
29 if (!sysVendor.isEmpty()) {
30 return sysVendor;
31 }
32 return null;
33 }
34
35
36
37
38
39
40 public static String queryProductModel() {
41 final String productName = FileUtil.getStringFromFile(SysPath.DMI_ID + "product_name").trim();
42 final String productVersion = FileUtil.getStringFromFile(SysPath.DMI_ID + "product_version").trim();
43 if (productName.isEmpty()) {
44 if (!productVersion.isEmpty()) {
45 return productVersion;
46 }
47 } else {
48 if (!productVersion.isEmpty() && !"None".equals(productVersion)) {
49 return productName + " (version: " + productVersion + ")";
50 }
51 return productName;
52 }
53 return null;
54 }
55
56
57
58
59
60
61 public static String queryProductSerial() {
62
63
64 String serial = FileUtil.getStringFromFile(SysPath.DMI_ID + "product_serial");
65 if (!serial.isEmpty() && !"None".equals(serial)) {
66 return serial;
67 }
68 return queryBoardSerial();
69 }
70
71
72
73
74
75
76 public static String queryUUID() {
77
78
79 String uuid = FileUtil.getStringFromFile(SysPath.DMI_ID + "product_uuid");
80 if (!uuid.isEmpty() && !"None".equals(uuid)) {
81 return uuid;
82 }
83 return null;
84 }
85
86
87
88
89
90
91 public static String queryBoardVendor() {
92 final String boardVendor = FileUtil.getStringFromFile(SysPath.DMI_ID + "board_vendor").trim();
93 if (!boardVendor.isEmpty()) {
94 return boardVendor;
95 }
96 return null;
97 }
98
99
100
101
102
103
104 public static String queryBoardModel() {
105 final String boardName = FileUtil.getStringFromFile(SysPath.DMI_ID + "board_name").trim();
106 if (!boardName.isEmpty()) {
107 return boardName;
108 }
109 return null;
110 }
111
112
113
114
115
116
117 public static String queryBoardVersion() {
118 final String boardVersion = FileUtil.getStringFromFile(SysPath.DMI_ID + "board_version").trim();
119 if (!boardVersion.isEmpty()) {
120 return boardVersion;
121 }
122 return null;
123 }
124
125
126
127
128
129
130 public static String queryBoardSerial() {
131 final String boardSerial = FileUtil.getStringFromFile(SysPath.DMI_ID + "board_serial").trim();
132 if (!boardSerial.isEmpty()) {
133 return boardSerial;
134 }
135 return null;
136 }
137
138
139
140
141
142
143 public static String queryBiosVendor() {
144 final String biosVendor = FileUtil.getStringFromFile(SysPath.DMI_ID + "bios_vendor").trim();
145 if (biosVendor.isEmpty()) {
146 return biosVendor;
147 }
148 return null;
149 }
150
151
152
153
154
155
156 public static String queryBiosDescription() {
157 final String modalias = FileUtil.getStringFromFile(SysPath.DMI_ID + "modalias").trim();
158 if (!modalias.isEmpty()) {
159 return modalias;
160 }
161 return null;
162 }
163
164
165
166
167
168
169
170 public static String queryBiosVersion(String biosRevision) {
171 final String biosVersion = FileUtil.getStringFromFile(SysPath.DMI_ID + "bios_version").trim();
172 if (!biosVersion.isEmpty()) {
173 return biosVersion + (Util.isBlank(biosRevision) ? "" : " (revision " + biosRevision + ")");
174 }
175 return null;
176 }
177
178
179
180
181
182
183 public static String queryBiosReleaseDate() {
184 final String biosDate = FileUtil.getStringFromFile(SysPath.DMI_ID + "bios_date").trim();
185 if (!biosDate.isEmpty()) {
186 return ParseUtil.parseMmDdYyyyToYyyyMmDD(biosDate);
187 }
188 return null;
189 }
190 }