mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-01-23 00:07:07 +03:00
bcacheadm: register bcache ioctl already takes an argv, no need to parse it
Change-Id: I0295ebde998c038feb40332ea303935035b8e2bd Signed-off-by: Jacob Malevich <jam@daterainc.com>
This commit is contained in:
parent
34f54790d5
commit
7d34cf342e
24
bcache.c
24
bcache.c
@ -934,39 +934,19 @@ int list_cachesets(char *cset_dir)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parse_array_to_list(char *const *args)
|
||||
{
|
||||
int i, len = 0;
|
||||
char *space = " ";
|
||||
for(i=0; args[i] != NULL; i++) {
|
||||
len+=strlen(args[i]) + 1;
|
||||
}
|
||||
|
||||
char *arg_list = (char*)malloc(sizeof(char)*len);
|
||||
strcpy(arg_list, args[0]);
|
||||
strcat(arg_list, space);
|
||||
|
||||
for(i=1; args[i] != NULL; i++) {
|
||||
strcat(arg_list, args[i]);
|
||||
strcat(arg_list, space);
|
||||
}
|
||||
|
||||
return arg_list;
|
||||
}
|
||||
|
||||
int register_bcache(char *devs)
|
||||
{
|
||||
int ret, bcachefd;
|
||||
|
||||
bcachefd = open("/dev/bcache", O_RDWR);
|
||||
if (bcachefd < 0) {
|
||||
perror("Can't open bcache device");
|
||||
perror("Can't open bcache device\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = ioctl(bcachefd, BCH_IOCTL_REGISTER, devs);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "ioctl register error: %s", strerror(ret));
|
||||
fprintf(stderr, "ioctl register error: %s\n", strerror(ret));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return 0;
|
||||
|
@ -345,13 +345,7 @@ int probe_bcache (NihCommand *command, char *const *args)
|
||||
|
||||
int bcache_register (NihCommand *command, char *const *args)
|
||||
{
|
||||
int ret;
|
||||
char *arg_list = parse_array_to_list(args);
|
||||
|
||||
if(arg_list) {
|
||||
ret = register_bcache(arg_list);
|
||||
free(arg_list);
|
||||
}
|
||||
int ret = register_bcache(args);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user