+static int llog_cancel_parse_optional(int argc, char **argv,
+ struct obd_ioctl_data *data)
+{
+ int cOpt;
+ const char *const short_options = "c:l:i:h";
+ const struct option long_options[] = {
+ {"catalog", required_argument, NULL, 'c'},
+ {"log_id", required_argument, NULL, 'l'},
+ {"log_idx", required_argument, NULL, 'i'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, 0, NULL, 0}
+ };
+
+ /* sanity check */
+ if (!data || argc <= 1) {
+ return -1;
+ }
+
+ /*now process command line arguments*/
+ while ((cOpt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (cOpt) {
+ case 'c':
+ data->ioc_inllen1 = strlen(optarg) + 1;
+ data->ioc_inlbuf1 = optarg;
+ break;
+
+ case 'l':
+ data->ioc_inllen2 = strlen(optarg) + 1;
+ data->ioc_inlbuf2 = optarg;
+ break;
+
+ case 'i':
+ data->ioc_inllen3 = strlen(optarg) + 1;
+ data->ioc_inlbuf3 = optarg;
+ break;
+
+ case 'h':
+ default:
+ return -1;
+ }
+ }
+
+ if ((data->ioc_inlbuf1 == NULL) || (data->ioc_inlbuf3 == NULL)) {
+ /* missing mandatory parameters */
+ return -1;
+ }
+
+ return 0;
+}
+