X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Flib%2Fgetctx.c;h=c8c5b77301ed95b7e8ffc26aca903129f49b00be;hb=b38d70e7594b43cdd63b9e27ea5783001ef8407c;hp=9a76ed8123ce97c98ed7222c0af4acef552260eb;hpb=a10f15f15ac3c657f960b3a67e05dffc422f0c71;p=util-vserver.git diff --git a/util-vserver/lib/getctx.c b/util-vserver/lib/getctx.c index 9a76ed8..c8c5b77 100644 --- a/util-vserver/lib/getctx.c +++ b/util-vserver/lib/getctx.c @@ -20,54 +20,23 @@ # include #endif -#include "vserver.h" -#include "internal.h" -#include -#include -#include -#include - -#define CTX_TAG "\ns_context: " - -ctx_t -getctx(pid_t pid) -{ - static volatile size_t bufsize=4097; - // TODO: is this really race-free? - size_t cur_bufsize = bufsize; - int fd; - char status_name[ sizeof("/proc/01234/status") ]; - char buf[cur_bufsize]; - size_t len; - char *pos = 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"); - - fd = open(status_name, O_RDONLY); - if (fd==-1) return CTX_NOCTX; +#ifdef VC_ENABLE_API_COMPAT +# include "getctx-compat.hc" +#endif - len = read(fd, buf, cur_bufsize); - close(fd); +#ifdef VC_ENABLE_API_LEGACY +# include "getctx-legacy.hc" +#endif - if (len -#if 0 -ctx_t -getcctx() +xid_t +vc_X_getctx(pid_t pid) { - return getctx(getpid()); + CALL_VC(CALL_VC_COMPAT(vc_X_getctx, pid), + CALL_VC_LEGACY(vc_X_getctx, pid)); } -#endif