From 2884ccd2e701040723a5e32edfd98bdfb42bcf1b Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 6 Apr 2023 13:28:07 +1000 Subject: nstool: Reverse parameters to nstool Having the "subcommand" first is more conventional and will make it more natural for future extensions I have planned. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- test/nstool.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'test/nstool.c') diff --git a/test/nstool.c b/test/nstool.c index 9d6ee0c..8f66c98 100644 --- a/test/nstool.c +++ b/test/nstool.c @@ -7,17 +7,17 @@ * * Can run in 3 modes: * - * nstool hold + * nstool hold * Designed to be run inside a namespace, opens a Unix domain * control socket at and waits until instructed to stop - * with "nstool stop" - * nstool pid - * Prints the PID of the nstool hold process with control - * socket . This is given in the PID namespace where - * nstool pid is executed, not the one where nstool hold is - * running - * nstool stop - * Instruct the nstool hold with control socket at to exit. + * with "nstool stop " + * nstool pid + * Prints the PID of the nstool hold process with control socket + * . This is given in the PID namespace where nstool pid + * is executed, not the one where nstool hold is running + * nstool stop + * Instruct the nstool hold with control socket at to + * exit. */ #define _GNU_SOURCE @@ -38,7 +38,7 @@ static void usage(void) { - die("Usage: nstool hold|pid\n"); + die("Usage: nstool hold|pid|stop \n"); } static void hold(int fd, const struct sockaddr_un *addr) @@ -119,18 +119,18 @@ int main(int argc, char *argv[]) if (argc != 3) usage(); - sockname = argv[1]; + sockname = argv[2]; strncpy(sockaddr.sun_path, sockname, UNIX_PATH_MAX); fd = socket(AF_UNIX, SOCK_STREAM, PF_UNIX); if (fd < 0) die("socket(): %s\n", strerror(errno)); - if (strcmp(argv[2], "hold") == 0) + if (strcmp(argv[1], "hold") == 0) hold(fd, &sockaddr); - else if (strcmp(argv[2], "pid") == 0) + else if (strcmp(argv[1], "pid") == 0) pid(fd, &sockaddr); - else if (strcmp(argv[2], "stop") == 0) + else if (strcmp(argv[1], "stop") == 0) stop(fd, &sockaddr); else usage(); -- cgit v1.2.3