X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fvps.c;h=a3055a360fec9d6cb9d20337b67475990e38fb3b;hb=5b39edfee423f5f3cbe8fa223dcfdc9e8d66e286;hp=aac59f4d60aa71bc60de97259a140f98a931c815;hpb=6afa2d4b4b24055db250911aa8674c09fa623752;p=util-vserver.git diff --git a/util-vserver/src/vps.c b/util-vserver/src/vps.c index aac59f4..a3055a3 100644 --- a/util-vserver/src/vps.c +++ b/util-vserver/src/vps.c @@ -21,16 +21,23 @@ #endif #include "util.h" -#include "wrappers.h" -#include "wrappers-vserver.h" #include "pathconfig.h" #include #include #include +#include +#include +#include + +#define ENSC_WRAPPERS_VSERVER 1 +#define ENSC_WRAPPERS_STDLIB 1 +#define ENSC_WRAPPERS_UNISTD 1 +#define ENSC_WRAPPERS_FCNTL 1 +#include #define CTXNR_WIDTH 5 -#define HUNK_SIZE 0x40; +#define HUNK_SIZE 0x4000 #define CONTEXT_WIDTH 20 #define CONTEXT_PLACE " " @@ -44,21 +51,52 @@ struct ContextMapping { static struct ContextMapping *mapping = 0; static size_t mapping_len = 0; + +static void +showHelp(int fd, char const *cmd, int res) +{ + WRITE_MSG(fd, "Usage: "); + WRITE_STR(fd, cmd); + WRITE_MSG(fd, + " *\n\n" + "Please report bugs to " PACKAGE_BUGREPORT "\n"); + exit(res); +} + +static void +showVersion() +{ + WRITE_MSG(1, + "vps " VERSION " -- shows processes in vserver-contexts\n" + "This program is part of " PACKAGE_STRING "\n\n" + "Copyright (C) 2004 Enrico Scholz\n" + VERSION_COPYRIGHT_DISCLAIMER); + exit(0); +} + + static size_t writeContextInfo(xid_t ctx, char const *name) { - char buf[sizeof(ctx)*3+1]; - size_t l = utilvserver_fmt_ulong(buf, ctx); size_t l1 = name==0 ? 0 : strlen(name); size_t res = CTXNR_WIDTH + 1; + + if (ctx==VC_NOCTX) { + if (31) { + if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0); + if (strcmp(argv[1], "--version")==0) showVersion(); + } - if (vc_X_getctx(0)!=1) - Evc_new_s_context(1, vc_get_securecaps(), 0); + signal(SIGCHLD, SIG_DFL); + + if (!switchToWatchXid(&errptr)) { + perror(errptr); + exit(wrapper_exit_code); + } + + if (access("/proc/uptime",R_OK)==-1 && errno==ENOENT) + WRITE_MSG(2, + "WARNING: can not access /proc/uptime. Usually, this is caused by\n" + " procfs-security. Please read the FAQ for more details\n" + " http://www.linux-vserver.org/index.php?page=Linux-Vserver+FAQ\n"); Epipe(p); pid = Efork(); @@ -212,8 +267,5 @@ int main(int argc, char *argv[]) Eclose(p[0]); processOutput(data, len); - - exitLikeProcess(pid); - perror("exitLikeProcess()"); - return wrapper_exit_code; + exitLikeProcess(pid, "ps", wrapper_exit_code); }