From: Kefu Chai Date: Wed, 13 Sep 2017 04:03:37 +0000 (+0800) Subject: mds: use the best-effort if procfs is not available X-Git-Tag: v13.0.1~880^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6f6e3af01feb9f7fac7ce8d9ee8e567644f17c08;p=ceph.git mds: use the best-effort if procfs is not available Signed-off-by: Kefu Chai --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 4c30b6747136..c8a83360b7bd 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -1071,7 +1071,14 @@ void MDSDaemon::respawn() * unlinked. */ char exe_path[PATH_MAX] = ""; - if (readlink(PROCPREFIX "/proc/self/exe", exe_path, PATH_MAX-1) == -1) { +#ifdef PROCPREFIX + if (readlink(PROCPREFIX "/proc/self/exe", exe_path, PATH_MAX-1) != -1) { + dout(1) << "respawning with exe " << exe_path << dendl; + strcpy(exe_path, PROCPREFIX "/proc/self/exe"); + } else { +#else + { +#endif /* Print CWD for the user's interest */ char buf[PATH_MAX]; char *cwd = getcwd(buf, sizeof(buf)); @@ -1080,9 +1087,6 @@ void MDSDaemon::respawn() /* Fall back to a best-effort: just running in our CWD */ strncpy(exe_path, orig_argv[0], PATH_MAX-1); - } else { - dout(1) << "respawning with exe " << exe_path << dendl; - strcpy(exe_path, PROCPREFIX "/proc/self/exe"); } dout(1) << " exe_path " << exe_path << dendl;