]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
core: Prefix /proc/ with FreeBSD emulation
authorWillem Jan Withagen <wjw@digiware.nl>
Sun, 2 Apr 2017 22:04:01 +0000 (00:04 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Wed, 5 Apr 2017 19:36:22 +0000 (21:36 +0200)
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/common/MemoryModel.cc
src/common/buffer.cc
src/common/fd.cc
src/common/util.cc
src/global/signal_handler.cc
src/include/compat.h
src/mds/MDBalancer.cc
src/mds/MDSDaemon.cc

index 99bb1ca35c6bdd76109b09fa2bed98c041f2199b..fc14a04389bfedc9cf7b6790e44821ebb84c81a1 100644 (file)
@@ -1,5 +1,6 @@
 
 #include "acconfig.h"
+#include "include/compat.h"
 #include "include/types.h"
 #include "MemoryModel.h"
 #include "common/config.h"
@@ -21,9 +22,9 @@ void MemoryModel::_sample(snap *psnap)
 {
   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()) {
@@ -45,9 +46,9 @@ void MemoryModel::_sample(snap *psnap)
   }
   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;
   }
 
index 56b5770fa012ca92ff2dd4378e6e570250f134ba..790e4551f36249d810eb36b84b697227a662a1f2 100644 (file)
@@ -12,6 +12,7 @@
  * 
  */
 
+#include "include/compat.h"
 #include "include/mempool.h"
 #include "armor.h"
 #include "common/environment.h"
@@ -118,9 +119,9 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
     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;
index 45d6a129b0542ee715de44b34cdb577d417f3434..19f817daf48553fc851713cb3c357f9f2b1ef855 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include "include/compat.h"
 #include "fd.h"
 
 #include <sys/types.h>
@@ -24,7 +25,7 @@
 
 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;
index 73b457ff5419c8bfd09bfc2c7a2226daecb2fdd4..3cc1c49e78bb52b18b030ca7597f7e49aa40a045 100644 (file)
@@ -16,6 +16,7 @@
 #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"
@@ -202,7 +203,7 @@ void collect_sys_info(map<string, string> *m, CephContext *cct)
   }
 
   // memory
-  FILE *f = fopen("/proc/meminfo", "r");
+  FILE *f = fopen(PROCPREFIX "/proc/meminfo", "r");
   if (f) {
     char buf[100];
     while (!feof(f)) {
@@ -223,7 +224,7 @@ void collect_sys_info(map<string, string> *m, CephContext *cct)
   }
 
   // processor
-  f = fopen("/proc/cpuinfo", "r");
+  f = fopen(PROCPREFIX "/proc/cpuinfo", "r");
   if (f) {
     char buf[100];
     while (!feof(f)) {
index 2ddc0149893f2a2beaabc523e27999ffae73e7ff..d4099e1e201ee73c5a1dad39c5e8ee2044c4adc5 100644 (file)
@@ -160,7 +160,7 @@ void install_standard_sighandlers(void)
 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) {
index ecd8a61fe3eafd2ad41e4400ab653f8b1fbb44af..d4120478c88ead29a932704e25c5bd8a33849a13 100644 (file)
 
 #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
index afe4296f179f691557301972550bc6d7db26724d..3e114ddd4b914764a9d1971a231782fd8406cfdb 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include "include/compat.h"
 #include "mdstypes.h"
 
 #include "MDBalancer.h"
@@ -154,11 +155,11 @@ mds_load_t MDBalancer::get_load(utime_t now)
   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;
index 2d24d1bf0fd541d58302f7993371f85b06d6eb24..273e5eca7c18bbdc13d4d7c35fe8238b0fde766e 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <unistd.h>
 
+#include "include/compat.h"
 #include "global/signal_handler.h"
 
 #include "include/types.h"
@@ -1041,7 +1042,7 @@ void MDSDaemon::respawn()
    * 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));
@@ -1052,7 +1053,7 @@ void MDSDaemon::respawn()
     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;