From cedbecf970f1f683472c337f19c02f3b93b06b52 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Tue, 17 Jun 2008 16:16:47 +0000 Subject: [PATCH] Add operations needed by Fedora 9 tweaks. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2720 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- src/chroot-sh.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/chroot-sh.c b/src/chroot-sh.c index 1dc696a..123ba87 100644 --- a/src/chroot-sh.c +++ b/src/chroot-sh.c @@ -210,6 +210,24 @@ execLink(int argc, char *argv[]) return res; } +static int +execMv(int argc, char *argv[]) +{ + int res = EXIT_SUCCESS; + + if (argc!=3) { + WRITE_MSG(2, "Need exactly two files for 'mv' operation; try '--help' for more information\n"); + return wrapper_exit_code; + } + + if (rename(argv[1], argv[2])==-1) { + PERROR_Q(ENSC_WRAPPERS_PREFIX "mv", argv[1]); + res = EXIT_FAILURE; + } + + return res; +} + static struct Command { char const *cmd; int (*handler)(int argc, char *argv[]); @@ -222,6 +240,7 @@ static struct Command { { "mkdir", execMkdir }, { "chmod", execChmod }, { "link", execLink }, + { "mv", execMv }, { 0,0 } }; @@ -236,16 +255,17 @@ showHelp() "directory, and symlinks can point to files under the current path only.\n" "\n" "The supported commands are:\n" - " cat ... gives out to stdout\n" - " append ... appends stdin to which is created when needed\n" - " truncate ... clear and fill it with stdin; the is\n" + " cat ... gives out to stdout\n" + " append ... appends stdin to which is created when needed\n" + " truncate ... clear and fill it with stdin; the is\n" " created when needed\n" - " rm + ... unlink the given files\n" - " mkdir + ... create the given directories\n" + " rm + ... unlink the given files\n" + " mkdir + ... create the given directories\n" " chmod +\n" - " ... change access permissions of files\n" - " link dst> ... create a symbolic link from to \n\n" - "Please report bugs to " PACKAGE_BUGREPORT "\n"); + " ... change access permissions of files\n" + " link ... create a symbolic link from to \n" + " mv ... rename to \n" + "\nPlease report bugs to " PACKAGE_BUGREPORT "\n"); exit(0); } -- 1.8.1.5