add link command to chroot-sh
authorBenedikt Boehm <hollow@gentoo.org>
Fri, 27 Apr 2007 09:01:20 +0000 (09:01 +0000)
committerBenedikt Boehm <hollow@gentoo.org>
Fri, 27 Apr 2007 09:01:20 +0000 (09:01 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2536 94cd875c-1c1d-0410-91d2-eb244daf1a30

src/chroot-sh.c

index 0e1ffda..1dc696a 100644 (file)
@@ -192,6 +192,24 @@ execChmod(int argc, char *argv[])
   return res;
 }
 
+static int
+execLink(int argc, char *argv[])
+{
+  int          res = EXIT_SUCCESS;
+
+  if (argc!=3) {
+    WRITE_MSG(2, "Need exactly two files for 'link' operation; try '--help' for more information\n");
+    return wrapper_exit_code;
+  }
+
+  if (symlink(argv[1], argv[2])==-1) {
+    PERROR_Q(ENSC_WRAPPERS_PREFIX "link", argv[1]);
+    res = EXIT_FAILURE;
+  }
+
+  return res;
+}
+
 static struct Command {
     char const         *cmd;
     int                        (*handler)(int argc, char *argv[]);
@@ -203,6 +221,7 @@ static struct Command {
   { "rm",       execRm },
   { "mkdir",    execMkdir },
   { "chmod",    execChmod },
+  { "link",     execLink },
   { 0,0 }
 };
 
@@ -224,7 +243,8 @@ showHelp()
            "  rm <file>+      ...  unlink the given files\n"
            "  mkdir <file>+   ...  create the given directories\n"
            "  chmod <mode> <file>+\n"
-           "                  ...  change access permissions of files\n\n"
+           "                  ...  change access permissions of files\n"
+           "  link <src> dst> ...  create a symbolic link from <src> to <dst>\n\n"
            "Please report bugs to " PACKAGE_BUGREPORT "\n");
   exit(0);
 }