vm: Use the old FreeBSD os-freebsd.cpp so we don't need procfs installed (it's not mounted by default).
parent
080303530a
commit
d139924bf5
|
@ -1,33 +1,45 @@
|
||||||
#include "master.hpp"
|
#include "master.hpp"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
namespace factor {
|
namespace factor {
|
||||||
char *vm_saved_path;
|
char *vm_saved_path;
|
||||||
|
|
||||||
/*
|
|
||||||
FreeBSD needs proc mounted for this function to work.
|
|
||||||
"mount -t procfs proc /proc"
|
|
||||||
*/
|
|
||||||
|
|
||||||
const char* vm_executable_path(){
|
|
||||||
ssize_t bufsiz = 4096;
|
/* From SBCL */
|
||||||
while (true) {
|
const char *vm_executable_path()
|
||||||
char* buf = new char [bufsiz + 1];
|
{
|
||||||
ssize_t size = readlink("/proc/curproc/file", buf, bufsiz);
|
char path[PATH_MAX + 1];
|
||||||
if (size < 0) {
|
|
||||||
fatal_error("Cannot read /proc/curproc/file", errno);
|
if (getosreldate() >= 600024)
|
||||||
}
|
{
|
||||||
else {
|
/* KERN_PROC_PATHNAME is available */
|
||||||
if (size < bufsiz) {
|
size_t len = PATH_MAX + 1;
|
||||||
buf[size] = '\0';
|
int mib[4];
|
||||||
const char* ret = safe_strdup(buf);
|
|
||||||
delete[] buf;
|
mib[0] = CTL_KERN;
|
||||||
return ret;
|
mib[1] = KERN_PROC;
|
||||||
} else {
|
mib[2] = KERN_PROC_PATHNAME;
|
||||||
delete[] buf;
|
mib[3] = -1;
|
||||||
bufsiz *= 2;
|
if (sysctl(mib, 4, &path, &len, NULL, 0) != 0)
|
||||||
}
|
return NULL;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
size = readlink("/proc/curproc/file", path, sizeof(path) - 1);
|
||||||
|
if (size < 0)
|
||||||
|
return NULL;
|
||||||
|
path[size] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strcmp(path, "unknown") == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return safe_strdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue