X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fchroot-rm.c;h=dc34836dcd8567bfb4be52d8e32668b606c585d0;hb=feda714e8feec0c6711f6d68326819e03f16c4b4;hp=9fef602d1dd042157ddc7921d050ca325db869fd;hpb=6b7199096799544b9d748a6e5a9a13a5e598c694;p=util-vserver.git diff --git a/util-vserver/src/chroot-rm.c b/util-vserver/src/chroot-rm.c index 9fef602..dc34836 100644 --- a/util-vserver/src/chroot-rm.c +++ b/util-vserver/src/chroot-rm.c @@ -26,19 +26,53 @@ #include #include +#define ENSC_WRAPPERS_UNISTD 1 +#include + +int wrapper_exit_code = 1; + +static void +showHelp(int fd, char const *cmd, int res) +{ + WRITE_MSG(fd, "Usage: "); + WRITE_STR(fd, cmd); + WRITE_MSG(fd, + " +\n\n" + "This program removes by assuming the current directory\n" + "as a chroot directory.\n\n" + "Please report bugs to " PACKAGE_BUGREPORT "\n"); + exit(res); +} + +static void +showVersion() +{ + WRITE_MSG(1, + "chroot-rm " VERSION " -- removes files under current directory\n" + "This program is part of " PACKAGE_STRING "\n\n" + "Copyright (C) 2003 Enrico Scholz\n" + VERSION_COPYRIGHT_DISCLAIMER); + exit(0); +} + int main(int argc, char *argv[]) { int i; - int res; - - if (chroot(".")==-1 || - chdir("/")==-1) { - perror("chroot()/chdir()"); + int res = EXIT_SUCCESS; + int idx = 1; + + if (argc==1) { + WRITE_MSG(2, "No files given; use '--help' for more information\n"); return EXIT_FAILURE; } + if (strcmp(argv[1], "--help") ==0) showHelp(1, argv[0], 0); + if (strcmp(argv[1], "--version")==0) showVersion(); + if (strcmp(argv[1], "--")==0) ++idx; - res = EXIT_SUCCESS; - for (i=1; i