diff --git a/ctdb/scsi/scsi_io.c b/ctdb/scsi/scsi_io.c index 0d5013dc1e1..730d90ebaf2 100644 --- a/ctdb/scsi/scsi_io.c +++ b/ctdb/scsi/scsi_io.c @@ -26,6 +26,7 @@ #include #include #include +#include "popt.h" #define SCSI_TIMEOUT 5000 /* ms */ @@ -123,11 +124,6 @@ printf("\n"); return 0; } -void usage(void) -{ - printf("Usage: scsi \n"); -} - typedef struct _value_string_t { int value; const char *string; @@ -877,28 +873,95 @@ int open_scsi_device(const char *dev) return fd; } -int main(int argc, char *argv[]) -{ - int fd; +typedef int (*scsi_func_t)(int fd); +typedef struct _cmds_t { + const char *cmd; + scsi_func_t func; + const char *comment; +} cmds_t; +cmds_t cmds[] = { + {"inq", scsi_inquiry, "Standard INQUIRY output"}, + {"vpd", scsi_inquiry_supported_vpd_pages, "Supported VPD Pages"}, + {"usn", scsi_inquiry_unit_serial_number, "Unit serial number"}, + {"readkeys", scsi_persistent_reserve_in_read_keys, "Read SCSI Reservation Keys"}, + {"readrsvr", scsi_persistent_reserve_in_read_reservation, "Read SCSI Reservation Data"}, + {"reportcap", scsi_persistent_reserve_in_report_capabilities, "Report reservation Capabilities"}, +}; - if(argc!=2){ +void usage(void) +{ + int i; + printf("Usage: scsi_io --command --device \n"); + printf("Commands:\n"); + for (i=0;i