From 59a6730a02b6ad53a88d14ebb664695116c31a7d Mon Sep 17 00:00:00 2001 From: Surbhi Palande Date: Tue, 5 Aug 2014 16:19:48 -0700 Subject: [PATCH] Better usage message. Invoking bcachectl will now show you a help message and a usage indicator. Change-Id: I9f6163b196b32723c21ddbce04d4a20015173a1a Signed-off-by: Surbhi Palande --- bcachectl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bcachectl.c b/bcachectl.c index 2325cb50..19533bea 100644 --- a/bcachectl.c +++ b/bcachectl.c @@ -14,7 +14,6 @@ int bcachefd; static int register_devices(int argc, char *argv[]) { int ret; - ret = ioctl(bcachefd, BCH_IOCTL_REGISTER, argv); if (ret < 0) { fprintf(stderr, "ioctl error %d", ret); @@ -25,21 +24,23 @@ static int register_devices(int argc, char *argv[]) int main(int argc, char *argv[]) { - char *ioctl = argv[2]; + char *ioctl = argv[1]; if (argc < 3) { - fprintf(stderr, "Enter bcache device and an ioctl to issue\n"); + fprintf(stderr, " %s ", argv[0]); + fprintf(stderr, "\n Possible actions are: \n"); + fprintf(stderr, " \t 1. register_devices\n"); exit(EXIT_FAILURE); } - bcachefd = open(argv[1], O_RDWR); + bcachefd = open("/dev/bcache", O_RDWR); if (bcachefd < 0) { perror("Can't open bcache device"); exit(EXIT_FAILURE); } - argc -= 3; - argv += 3; + argc -= 2; + argv += 2; if (!strcmp(ioctl, "register_devices")) return register_devices(argc, argv); @@ -47,5 +48,5 @@ int main(int argc, char *argv[]) fprintf(stderr, "Unknown ioctl\n"); exit(EXIT_FAILURE); } + return 0; } -