X-Git-Url: http://git.onelab.eu/?p=util-vserver.git;a=blobdiff_plain;f=lib%2Fgetctx-legacy.hc;fp=lib%2Fgetctx-legacy.hc;h=0000000000000000000000000000000000000000;hp=4f585b08a5fc6917ff4dbee57ad60e45d6cf021c;hb=d8fc1f54604dba7f52d3d220363140ab42af19c4;hpb=30a26545c44a9b6643e01602535309cb53fbe435 diff --git a/lib/getctx-legacy.hc b/lib/getctx-legacy.hc deleted file mode 100644 index 4f585b0..0000000 --- a/lib/getctx-legacy.hc +++ /dev/null @@ -1,81 +0,0 @@ -// $Id: getctx-legacy.hc,v 1.1.2.3 2003/12/30 13:45:57 ensc Exp $ --*- c++ -*-- - -// Copyright (C) 2003 Enrico Scholz -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - -#ifndef H_UTIL_VSERVER_LIB_GETCTX_LEGACY_H -#define H_UTIL_VSERVER_LIB_GETCTX_LEGACY_H - -#ifdef HAVE_CONFIG_H -# include -#endif -#include "compat.h" - -#include "vserver.h" -#include "vserver-internal.h" -#include -#include -#include -#include - -#define CTX_TAG "\ns_context: " - -static xid_t -vc_X_getctx_legacy(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; - - if (pid<0 || (uint32_t)(pid)>99999) { - errno = EINVAL; - return 0; - } - - 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 VC_NOCTX; - - len = read(fd, buf, cur_bufsize); - close(fd); - - if (len