13 #include <sys/types.h> 19 #include "../../util/header.h" 20 #include "../../util/util.h" 22 #define SYSINFO_MANU "Manufacturer:" 23 #define SYSINFO_TYPE "Type:" 24 #define SYSINFO_MODEL "Model:" 25 #define SRVLVL_CPUMF "CPU-MF:" 26 #define SRVLVL_VERSION "version=" 27 #define SRVLVL_AUTHORIZATION "authorization=" 28 #define SYSINFO "/proc/sysinfo" 29 #define SRVLVL "/proc/service_levels" 33 char *cp, *line = NULL, *line2;
34 char type[8], model[33],
version[8], manufacturer[32], authorization[8];
35 int tpsize = 0, mdsize = 0, vssize = 0, mfsize = 0, atsize = 0;
37 unsigned long line_sz;
51 memset(manufacturer, 0,
sizeof(manufacturer));
52 memset(type, 0,
sizeof(type));
53 memset(model, 0,
sizeof(model));
54 memset(version, 0,
sizeof(version));
55 memset(authorization, 0,
sizeof(authorization));
61 while ((read = getline(&line, &line_sz, sysinfo)) != -1) {
65 while ((cp = strtok_r(line2,
"\n ", &line2))) {
66 mfsize += scnprintf(manufacturer + mfsize,
67 sizeof(manufacturer) - mfsize,
"%s", cp);
74 while ((cp = strtok_r(line2,
"\n ", &line2))) {
75 tpsize += scnprintf(type + tpsize,
76 sizeof(type) - tpsize,
"%s", cp);
83 while ((cp = strtok_r(line2,
"\n ", &line2))) {
84 mdsize += scnprintf(model + mdsize,
sizeof(model) - mdsize,
85 "%s%s", model[0] ?
"," :
"", cp);
93 if (!manufacturer[0] || !type[0] || !model[0])
101 sysinfo = fopen(
SRVLVL,
"r");
104 while ((read = getline(&line, &line_sz, sysinfo)) != -1) {
109 while ((cp = strtok_r(line2,
"\n ", &line2))) {
112 char *sep = strchr(cp,
'=');
114 vssize += scnprintf(version + vssize,
115 sizeof(version) - vssize,
"%s", sep + 1);
119 char *sep = strchr(cp,
'=');
121 atsize += scnprintf(authorization + atsize,
122 sizeof(authorization) - atsize,
"%s", sep + 1);
131 if (version[0] && authorization[0] )
132 nbytes = snprintf(buffer, sz,
"%s,%s,%s,%s,%s",
133 manufacturer, type, model, version,
136 nbytes = snprintf(buffer, sz,
"%s,%s,%s", manufacturer, type,
138 return (nbytes >= sz) ? -1 : 0;
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms