sync to 0.30.213
[util-vserver.git] / src / chroot-sh.c
index f8baac3..4cbca21 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: chroot-sh.c 2407 2006-11-25 19:18:06Z dhozac $    --*- c -*--
+// $Id: chroot-sh.c 2536 2007-04-27 09:01:20Z hollow $    --*- c -*--
 
 // Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
 //  
@@ -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);
 }