#include "acconfig.h"
+#include "include/compat.h"
#include "include/types.h"
#include "MemoryModel.h"
#include "common/config.h"
{
ifstream f;
- f.open("/proc/self/status");
+ f.open(PROCPREFIX "/proc/self/status");
if (!f.is_open()) {
- ldout(cct, 0) << "check_memory_usage unable to open /proc/self/status" << dendl;
+ ldout(cct, 0) << "check_memory_usage unable to open " PROCPREFIX "/proc/self/status" << dendl;
return;
}
while (!f.eof()) {
}
f.close();
- f.open("/proc/self/maps");
+ f.open(PROCPREFIX "/proc/self/maps");
if (!f.is_open()) {
- ldout(cct, 0) << "check_memory_usage unable to open /proc/self/maps" << dendl;
+ ldout(cct, 0) << "check_memory_usage unable to open " PROCPREFIX "/proc/self/maps" << dendl;
return;
}
*
*/
+#include "include/compat.h"
#include "include/mempool.h"
#include "armor.h"
#include "common/environment.h"
int r;
std::string err;
struct stat stat_result;
- if (::stat("/proc/sys/fs/pipe-max-size", &stat_result) == -1)
+ if (::stat(PROCPREFIX "/proc/sys/fs/pipe-max-size", &stat_result) == -1)
return -errno;
- r = safe_read_file("/proc/sys/fs/", "pipe-max-size",
+ r = safe_read_file(PROCPREFIX "/proc/sys/fs/", "pipe-max-size",
buf, sizeof(buf) - 1);
if (r < 0)
return r;
*
*/
+#include "include/compat.h"
#include "fd.h"
#include <sys/types.h>
void dump_open_fds(CephContext *cct)
{
- const char *fn = "/proc/self/fd";
+ const char *fn = PROCPREFIX "/proc/self/fd";
DIR *d = opendir(fn);
if (!d) {
lderr(cct) << "dump_open_fds unable to open " << fn << dendl;
#include <sys/utsname.h>
#include <boost/lexical_cast.hpp>
+#include "include/compat.h"
#include "include/util.h"
#include "common/debug.h"
#include "common/errno.h"
}
// memory
- FILE *f = fopen("/proc/meminfo", "r");
+ FILE *f = fopen(PROCPREFIX "/proc/meminfo", "r");
if (f) {
char buf[100];
while (!feof(f)) {
}
// processor
- f = fopen("/proc/cpuinfo", "r");
+ f = fopen(PROCPREFIX "/proc/cpuinfo", "r");
if (f) {
char buf[100];
while (!feof(f)) {
string get_name_by_pid(pid_t pid)
{
char proc_pid_path[PATH_MAX] = {0};
- snprintf(proc_pid_path, PATH_MAX, "/proc/%d/cmdline", pid);
+ snprintf(proc_pid_path, PATH_MAX, PROCPREFIX "/proc/%d/cmdline", pid);
int fd = open(proc_pid_path, O_RDONLY);
if (fd < 0) {
#include "acconfig.h"
+#if defined(__linux__)
+#define PROCPREFIX
+#endif
+
#if defined(__FreeBSD__)
+// FreeBSD supports Linux procfs with its compatibility module
+// And all compatibility stuff is standard mounted on this
+#define PROCPREFIX "/compat/linux"
+
/* Make sure that ENODATA is defined in the correct way */
#ifndef ENODATA
#define ENODATA ENOATTR
*
*/
+#include "include/compat.h"
#include "mdstypes.h"
#include "MDBalancer.h"
load.req_rate = mds->get_req_rate();
load.queue_len = messenger->get_dispatch_queue_len();
- ifstream cpu("/proc/loadavg");
+ ifstream cpu(PROCPREFIX "/proc/loadavg");
if (cpu.is_open())
cpu >> load.cpu_load_avg;
else
- derr << "input file '/proc/loadavg' not found" << dendl;
+ derr << "input file " PROCPREFIX "'/proc/loadavg' not found" << dendl;
dout(15) << "get_load " << load << dendl;
return load;
#include <unistd.h>
+#include "include/compat.h"
#include "global/signal_handler.h"
#include "include/types.h"
* unlinked.
*/
char exe_path[PATH_MAX] = "";
- if (readlink("/proc/self/exe", exe_path, PATH_MAX-1) == -1) {
+ if (readlink(PROCPREFIX "/proc/self/exe", exe_path, PATH_MAX-1) == -1) {
/* Print CWD for the user's interest */
char buf[PATH_MAX];
char *cwd = getcwd(buf, sizeof(buf));
strncpy(exe_path, orig_argv[0], PATH_MAX-1);
} else {
dout(1) << "respawning with exe " << exe_path << dendl;
- strcpy(exe_path, "/proc/self/exe");
+ strcpy(exe_path, PROCPREFIX "/proc/self/exe");
}
dout(1) << " exe_path " << exe_path << dendl;