| @@ -56,47 +56,46 @@ | | | @@ -56,47 +56,46 @@ |
56 | | | 56 | |
57 | #define DMCTL_CMD_REQ_NODEVNAME 0 /* Command do not require device name */ | | 57 | #define DMCTL_CMD_REQ_NODEVNAME 0 /* Command do not require device name */ |
58 | #define DMCTL_CMD_REQ_DEVNAME 1 /* Command require device name to work */ | | 58 | #define DMCTL_CMD_REQ_DEVNAME 1 /* Command require device name to work */ |
59 | #define DMCTL_CMD_REQ_NEWNAME 2 /* Command require device name and | | 59 | #define DMCTL_CMD_REQ_NEWNAME 2 /* Command require device name and |
60 | newname to work */ | | 60 | newname to work */ |
61 | struct command { | | 61 | struct command { |
62 | const char *cmd_name; | | 62 | const char *cmd_name; |
63 | const char *cmd_help; | | 63 | const char *cmd_help; |
64 | const char *ioctl_cmd_name; | | 64 | const char *ioctl_cmd_name; |
65 | int min_args; | | 65 | int min_args; |
66 | int (*cmd_func)(int, char *[], libdm_task_t); | | 66 | int (*cmd_func)(int, char *[], libdm_task_t); |
67 | }; | | 67 | }; |
68 | | | 68 | |
69 | int fd; /* file descriptor for device */ | | 69 | static const char *dvname; /* device name */ |
70 | const char *dvname; /* device name */ | | 70 | static const char *cmdname; /* command user issued */ |
71 | const char *cmdname; /* command user issued */ | | | |
72 | | | 71 | |
73 | static char * parse_stdin(char *); | | 72 | static char * parse_stdin(char *); |
74 | | | 73 | |
75 | static int dmctl_get_version(int, char *[], libdm_task_t); | | 74 | static int dmctl_get_version(int, char *[], libdm_task_t); |
76 | static int dmctl_get_targets(int, char *[], libdm_task_t); | | 75 | static int dmctl_get_targets(int, char *[], libdm_task_t); |
77 | static int dmctl_get_device_info(int, char *[], libdm_task_t); | | 76 | static int dmctl_get_device_info(int, char *[], libdm_task_t); |
78 | static int dmctl_create_dev(int, char *[], libdm_task_t); | | 77 | static int dmctl_create_dev(int, char *[], libdm_task_t); |
79 | static int dmctl_dev_rename(int, char *[], libdm_task_t); | | 78 | static int dmctl_dev_rename(int, char *[], libdm_task_t); |
80 | static int dmctl_dev_remove(int, char *[], libdm_task_t); | | 79 | static int dmctl_dev_remove(int, char *[], libdm_task_t); |
81 | static int dmctl_dev_resume(int, char *[], libdm_task_t); | | 80 | static int dmctl_dev_resume(int, char *[], libdm_task_t); |
82 | static int dmctl_dev_suspend(int, char *[], libdm_task_t); | | 81 | static int dmctl_dev_suspend(int, char *[], libdm_task_t); |
83 | static int dmctl_dev_deps(int, char *[], libdm_task_t); | | 82 | static int dmctl_dev_deps(int, char *[], libdm_task_t); |
84 | static int dmctl_list_devices(int, char *[], libdm_task_t); | | 83 | static int dmctl_list_devices(int, char *[], libdm_task_t); |
85 | static int dmctl_table_reload(int, char *[], libdm_task_t); | | 84 | static int dmctl_table_reload(int, char *[], libdm_task_t); |
86 | static int dmctl_table_status(int, char *[], libdm_task_t); | | 85 | static int dmctl_table_status(int, char *[], libdm_task_t); |
87 | void usage(void); | | 86 | __dead static void usage(void); |
88 | | | 87 | |
89 | struct command commands[] = { | | 88 | static struct command commands[] = { |
90 | { "version", | | 89 | { "version", |
91 | "Print driver and lib version.", | | 90 | "Print driver and lib version.", |
92 | NULL, DMCTL_CMD_REQ_NODEVNAME, | | 91 | NULL, DMCTL_CMD_REQ_NODEVNAME, |
93 | dmctl_get_version }, | | 92 | dmctl_get_version }, |
94 | { "targets", | | 93 | { "targets", |
95 | "List available kernel targets.", | | 94 | "List available kernel targets.", |
96 | NULL, DMCTL_CMD_REQ_NODEVNAME, | | 95 | NULL, DMCTL_CMD_REQ_NODEVNAME, |
97 | dmctl_get_targets }, | | 96 | dmctl_get_targets }, |
98 | { "create", | | 97 | { "create", |
99 | "Create device with [dm device name].", | | 98 | "Create device with [dm device name].", |
100 | NULL, DMCTL_CMD_REQ_DEVNAME, | | 99 | NULL, DMCTL_CMD_REQ_DEVNAME, |
101 | dmctl_create_dev }, | | 100 | dmctl_create_dev }, |
102 | { "ls", | | 101 | { "ls", |
| @@ -527,27 +526,27 @@ dmctl_table_status(int argc __unused, ch | | | @@ -527,27 +526,27 @@ dmctl_table_status(int argc __unused, ch |
527 | libdm_table_get_start(table), | | 526 | libdm_table_get_start(table), |
528 | libdm_table_get_length(table), | | 527 | libdm_table_get_length(table), |
529 | libdm_table_get_target(table)); | | 528 | libdm_table_get_target(table)); |
530 | libdm_table_destroy(table); | | 529 | libdm_table_destroy(table); |
531 | } | | 530 | } |
532 | | | 531 | |
533 | libdm_iter_destroy(iter); | | 532 | libdm_iter_destroy(iter); |
534 | libdm_cmd_destroy(cmd); | | 533 | libdm_cmd_destroy(cmd); |
535 | libdm_task_destroy(task); | | 534 | libdm_task_destroy(task); |
536 | | | 535 | |
537 | return 0; | | 536 | return 0; |
538 | } | | 537 | } |
539 | | | 538 | |
540 | void | | 539 | static void |
541 | usage(void) | | 540 | usage(void) |
542 | { | | 541 | { |
543 | int i; | | 542 | int i; |
544 | | | 543 | |
545 | (void)fprintf(stderr, "usage: %s command [dm device name]\n" | | 544 | (void)fprintf(stderr, "usage: %s command [dm device name]\n" |
546 | "Available commands are:\n ", getprogname()); | | 545 | "Available commands are:\n ", getprogname()); |
547 | for (i = 0; commands[i].cmd_name != NULL; i++) | | 546 | for (i = 0; commands[i].cmd_name != NULL; i++) |
548 | (void)fprintf(stderr, "\t%s\t%s\n", commands[i].cmd_name, commands[i].cmd_help); | | 547 | (void)fprintf(stderr, "\t%s\t%s\n", commands[i].cmd_name, commands[i].cmd_help); |
549 | exit(EXIT_FAILURE); | | 548 | exit(EXIT_FAILURE); |
550 | } | | 549 | } |
551 | | | 550 | |
552 | static char * | | 551 | static char * |
553 | parse_stdin(char *file_path) | | 552 | parse_stdin(char *file_path) |