|
Lines 43-52
Link Here
|
| 43 |
#include <sys/utsname.h> |
43 |
#include <sys/utsname.h> |
| 44 |
#include <sys/wait.h> |
44 |
#include <sys/wait.h> |
| 45 |
|
45 |
|
| 46 |
#ifdef __linux__ |
|
|
| 47 |
# include <asm/setup.h> /* for COMMAND_LINE_SIZE */ |
| 48 |
#endif |
| 49 |
|
| 50 |
#include <errno.h> |
46 |
#include <errno.h> |
| 51 |
#include <dirent.h> |
47 |
#include <dirent.h> |
| 52 |
#include <ctype.h> |
48 |
#include <ctype.h> |
|
Lines 176-185
Link Here
|
| 176 |
proc_getent(const char *ent) |
172 |
proc_getent(const char *ent) |
| 177 |
{ |
173 |
{ |
| 178 |
FILE *fp; |
174 |
FILE *fp; |
| 179 |
char proc[COMMAND_LINE_SIZE]; |
175 |
char *proc, *p, *value = NULL; |
| 180 |
char *p; |
176 |
size_t i; |
| 181 |
char *value = NULL; |
|
|
| 182 |
int i; |
| 183 |
|
177 |
|
| 184 |
if (!exists("/proc/cmdline")) |
178 |
if (!exists("/proc/cmdline")) |
| 185 |
return NULL; |
179 |
return NULL; |
|
Lines 189-196
Link Here
|
| 189 |
return NULL; |
183 |
return NULL; |
| 190 |
} |
184 |
} |
| 191 |
|
185 |
|
| 192 |
memset(proc, 0, sizeof(proc)); |
186 |
proc = NULL; |
| 193 |
fgets(proc, sizeof(proc), fp); |
187 |
i = 0; |
|
|
188 |
if (rc_getline(&proc, &i, fp) == -1 || proc == NULL) |
| 189 |
eerror("rc_getline: %s", strerror(errno)); |
| 194 |
if (*proc && (p = strstr(proc, ent))) { |
190 |
if (*proc && (p = strstr(proc, ent))) { |
| 195 |
i = p - proc; |
191 |
i = p - proc; |
| 196 |
if (i == '\0' || proc[i - 1] == ' ') { |
192 |
if (i == '\0' || proc[i - 1] == ' ') { |
|
Lines 202-207
Link Here
|
| 202 |
} else |
198 |
} else |
| 203 |
errno = ENOENT; |
199 |
errno = ENOENT; |
| 204 |
fclose(fp); |
200 |
fclose(fp); |
|
|
201 |
free(proc); |
| 205 |
|
202 |
|
| 206 |
return value; |
203 |
return value; |
| 207 |
} |
204 |
} |