mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-01-23 00:07:07 +03:00
Better usage message.
Invoking bcachectl will now show you a help message and a usage indicator. Change-Id: I9f6163b196b32723c21ddbce04d4a20015173a1a Signed-off-by: Surbhi Palande <sap@daterainc.com>
This commit is contained in:
parent
73ef76c1c0
commit
59a6730a02
15
bcachectl.c
15
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, " <Usage> %s <action> <space separated list of devices>", argv[0]);
|
||||
fprintf(stderr, "\n <Help> 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user