From ebfa9c37bded4c3dbfa2152b982206e3a86f52f4 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Sat, 15 Mar 2008 16:05:49 +0000 Subject: [PATCH] Add some examples. Disallow combinations that make no sense. Allow defaults to be set. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2703 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- src/vdevmap.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/vdevmap.c b/src/vdevmap.c index fc08edd..88c7266 100644 --- a/src/vdevmap.c +++ b/src/vdevmap.c @@ -65,11 +65,20 @@ showHelp(int fd, char const *cmd) "\n" " --flags Set the specified flags\n" " --open Allow opening of the device\n" - " --create If SECURE_MKNOD is given, allow mknod(2)\n" + " --create If CAP_MKNOD is given, allow mknod(2)\n" " --device Device to apply the command to\n" " --remap Remap the device to the target\n" " --target Target for --remap\n" "\n" + "EXAMPLES\n" + " Remap /dev/hda1 to /dev/vroot1 for xid 42\n" + " vdevmap --xid 42 --set --open --device /dev/hda1 --target /dev/vroot1 --remap\n" + " Let xid 42 create all device nodes\n" + " vdevmap --xid 42 --set --open --create --target /dev/null\n" + " vdevmap --xid 42 --set --open --create --target /dev/root\n" + " Let xid 43 create just /dev/null\n" + " vdevmap --xid 43 --set --open --create --device /dev/null\n" + "\n" "Please report bugs to " PACKAGE_BUGREPORT "\n"); exit(0); @@ -136,12 +145,14 @@ int main(int argc, char *argv[]) if (allow_create) flags |= VC_DATTR_CREATE; if (do_remap) flags |= VC_DATTR_REMAP; - if (target && !do_remap) - WRITE_MSG(2, "Target specified without --remap; try '--help' for more information\n"); + if (!target && do_remap) + WRITE_MSG(2, "Remapping specified without a target; try '--help' for more information\n"); else if (xid==VC_NOCTX) WRITE_MSG(2, "No xid specified; try '--help' for more information\n"); else if (optind!=argc) WRITE_MSG(2, "Unused argument(s); try '--help' for more information\n"); + else if (!device && !target) + WRITE_MSG(2, "Device and target are missing; try '--help' for more information\n"); else if (set && vc_set_mapping(xid, device, target, flags)==-1) perror("vc_set_mapping()"); else if (!set && vc_unset_mapping(xid, device, target, flags)==-1) -- 1.8.1.5