From: Enrico Scholz Date: Fri, 17 Oct 2003 20:27:12 +0000 (+0000) Subject: - moved pid==0 handling into getprocentry-legacy.c and access /proc/self X-Git-Tag: VERSION_0_10~1217 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db07ac9c353b6f8461418e12053db8bb6bc32374;p=util-vserver.git - moved pid==0 handling into getprocentry-legacy.c and access /proc/self instead of /proc/ there; this solves problems when 'fakeinit' flag is used - removed '#include '; it's now in global git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@193 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/lib/getctx.c b/util-vserver/lib/getctx.c index 90bbb83..4018133 100644 --- a/util-vserver/lib/getctx.c +++ b/util-vserver/lib/getctx.c @@ -19,7 +19,6 @@ #ifdef HAVE_CONFIG_H # include #endif -#include "compat.h" #ifdef VC_ENABLE_API_COMPAT # include "getctx-compat.hc" @@ -33,14 +32,11 @@ #include "vserver-internal.h" #include "internal.h" -#include #include ctx_t vc_X_getctx(pid_t pid) { - if (pid==0) pid=getpid(); - CALL_VC(CALL_VC_COMPAT(vc_X_getctx, pid), CALL_VC_LEGACY(vc_X_getctx, pid)); } diff --git a/util-vserver/lib/getinitpid.c b/util-vserver/lib/getinitpid.c index 75d7e2b..fbc178c 100644 --- a/util-vserver/lib/getinitpid.c +++ b/util-vserver/lib/getinitpid.c @@ -19,7 +19,6 @@ #ifdef HAVE_CONFIG_H # include #endif -#include "compat.h" #ifdef VC_ENABLE_API_COMPAT # include "getinitpid-compat.hc" @@ -33,14 +32,11 @@ #include "vserver-internal.h" #include "internal.h" -#include #include pid_t vc_X_getinitpid(pid_t pid) { - if (pid==0) pid=getpid(); - CALL_VC(CALL_VC_COMPAT(vc_X_getinitpid, pid), CALL_VC_LEGACY(vc_X_getinitpid, pid)); } diff --git a/util-vserver/lib/getprocentry-legacy.c b/util-vserver/lib/getprocentry-legacy.c index 331bcad..32e128b 100644 --- a/util-vserver/lib/getprocentry-legacy.c +++ b/util-vserver/lib/getprocentry-legacy.c @@ -19,7 +19,6 @@ #ifdef HAVE_CONFIG_H # include #endif -#include "compat.h" #include "utils-legacy.h" #include "internal.h" @@ -49,16 +48,19 @@ utilvserver_getProcEntry(pid_t pid, size_t len; char * res = 0; - if (pid<=0 || (uint32_t)(pid)>99999) { + if (pid<0 || (uint32_t)(pid)>99999) { errno = EINVAL; return 0; } - strcpy(status_name, "/proc/"); - len = utilvserver_uint2str(status_name+sizeof("/proc/")-1, - sizeof(status_name)-sizeof("/proc//status")+1, - pid, 10); - strcpy(status_name+sizeof("/proc/")+len-1, "/status"); + if (pid==0) strcpy(status_name, "/proc/self/status"); + else { + strcpy(status_name, "/proc/"); + len = utilvserver_uint2str(status_name+sizeof("/proc/")-1, + sizeof(status_name)-sizeof("/proc//status")+1, + pid, 10); + strcpy(status_name+sizeof("/proc/")+len-1, "/status"); + } fd = open(status_name, O_RDONLY); if (fd==-1) return 0;