diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-04-06 13:28:07 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-04-08 01:11:43 +0200 |
commit | 2884ccd2e701040723a5e32edfd98bdfb42bcf1b (patch) | |
tree | b76f0ef847284de39b9305bda8e28d14c3d2a9ce /test/nstool.c | |
parent | 4914fce77be7764332ca2b56a3496ea73ad2f042 (diff) | |
download | passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.tar passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.tar.gz passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.tar.bz2 passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.tar.lz passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.tar.xz passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.tar.zst passt-2884ccd2e701040723a5e32edfd98bdfb42bcf1b.zip |
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 <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'test/nstool.c')
-rw-r--r-- | test/nstool.c | 28 |
1 files changed, 14 insertions, 14 deletions
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 <path> hold + * nstool hold <path> * Designed to be run inside a namespace, opens a Unix domain * control socket at <path> and waits until instructed to stop - * with "nstool <path> stop" - * nstool <path> pid - * Prints the PID of the nstool hold process with control - * socket <path>. This is given in the PID namespace where - * nstool pid is executed, not the one where nstool hold is - * running - * nstool <path> stop - * Instruct the nstool hold with control socket at <path> to exit. + * with "nstool stop <path>" + * nstool pid <path> + * Prints the PID of the nstool hold process with control socket + * <path>. This is given in the PID namespace where nstool pid + * is executed, not the one where nstool hold is running + * nstool stop <path> + * Instruct the nstool hold with control socket at <path> to + * exit. */ #define _GNU_SOURCE @@ -38,7 +38,7 @@ static void usage(void) { - die("Usage: nstool <socket path> hold|pid\n"); + die("Usage: nstool hold|pid|stop <socket path>\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(); |