Fix compile on Linux.
This commit is contained in:
parent
e1e36b2872
commit
79d40707db
@ -147,6 +147,43 @@ static bool rm_dir (const char *pathname, bool top)
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* Other systems may need this at some point, but for now it's Linux only */
|
||||
#ifdef __linux__
|
||||
static bool file_regex (const char *file, const char *regex)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
regex_t re;
|
||||
bool retval = false;
|
||||
int result;
|
||||
|
||||
if (! (fp = fopen (file, "r")))
|
||||
return (false);
|
||||
|
||||
if ((result = regcomp (&re, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
|
||||
fclose (fp);
|
||||
line = xmalloc (sizeof (char) * BUFSIZ);
|
||||
regerror (result, &re, line, BUFSIZ);
|
||||
fprintf (stderr, "file_regex: %s", line);
|
||||
free (line);
|
||||
return (false);
|
||||
}
|
||||
|
||||
while ((line = rc_getline (fp))) {
|
||||
if (regexec (&re, line, 0, NULL, 0) == 0)
|
||||
retval = true;
|
||||
free (line);
|
||||
if (retval)
|
||||
break;
|
||||
}
|
||||
fclose (fp);
|
||||
regfree (&re);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
const char *rc_sys (void)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
@ -160,13 +197,9 @@ const char *rc_sys (void)
|
||||
|
||||
#ifdef __linux__
|
||||
if (exists ("/proc/xen")) {
|
||||
if ((fp = fopen ("/proc/xen/capabilities", "r"))) {
|
||||
fclose (fp);
|
||||
if (file_regex ("/proc/xen/capabilities", "control_d"))
|
||||
return (RC_SYS_XEN0);
|
||||
}
|
||||
if (! sys[0])
|
||||
return (RC_SYS_XENU);
|
||||
if (file_regex ("/proc/xen/capabilities", "control_d"))
|
||||
return (RC_SYS_XEN0);
|
||||
return (RC_SYS_XENU);
|
||||
} else if (file_regex ("/proc/cpuinfo", "UML"))
|
||||
return (RC_SYS_UML);
|
||||
else if (file_regex ("/proc/self/status",
|
||||
|
@ -235,42 +235,6 @@ char **env_filter (void)
|
||||
return (env);
|
||||
}
|
||||
|
||||
/* Other systems may need this at some point, but for now it's Linux only */
|
||||
#ifdef __linux__
|
||||
static bool file_regex (const char *file, const char *regex)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
regex_t re;
|
||||
bool retval = false;
|
||||
int result;
|
||||
|
||||
if (! (fp = fopen (file, "r")))
|
||||
return (false);
|
||||
|
||||
if ((result = regcomp (&re, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
|
||||
fclose (fp);
|
||||
line = xmalloc (sizeof (char) * BUFSIZ);
|
||||
regerror (result, &re, line, BUFSIZ);
|
||||
fprintf (stderr, "file_regex: %s", line);
|
||||
free (line);
|
||||
return (false);
|
||||
}
|
||||
|
||||
while ((line = rc_getline (fp))) {
|
||||
if (regexec (&re, line, 0, NULL, 0) == 0)
|
||||
retval = true;
|
||||
free (line);
|
||||
if (retval)
|
||||
break;
|
||||
}
|
||||
fclose (fp);
|
||||
regfree (&re);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
#endif
|
||||
|
||||
char **env_config (void)
|
||||
{
|
||||
char **env = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user