- moved pid==0 handling into getprocentry-legacy.c and access /proc/self
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 17 Oct 2003 20:27:12 +0000 (20:27 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 17 Oct 2003 20:27:12 +0000 (20:27 +0000)
  instead of /proc/<self-pid> there; this solves problems when 'fakeinit'
  flag is used
- removed '#include <compat.h>'; it's now in global <config.h>

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@193 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/getctx.c
util-vserver/lib/getinitpid.c
util-vserver/lib/getprocentry-legacy.c

index 90bbb83..4018133 100644 (file)
@@ -19,7 +19,6 @@
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
-#include "compat.h"
 
 #ifdef VC_ENABLE_API_COMPAT
 #  include "getctx-compat.hc"
 #include "vserver-internal.h"
 #include "internal.h"
 
-#include <unistd.h>
 #include <sys/types.h>
 
 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));
 }
index 75d7e2b..fbc178c 100644 (file)
@@ -19,7 +19,6 @@
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
-#include "compat.h"
 
 #ifdef VC_ENABLE_API_COMPAT
 #  include "getinitpid-compat.hc"
 #include "vserver-internal.h"
 #include "internal.h"
 
-#include <unistd.h>
 #include <sys/types.h>
 
 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));
 }
index 331bcad..32e128b 100644 (file)
@@ -19,7 +19,6 @@
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #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;