summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2005-12-02 08:56:15 +0100
committerJens Axboe <axboe@suse.de>2005-12-02 08:56:15 +0100
commita8638a3c8bb40c73afa080e52f5b16fc4a8cdaad (patch)
tree9c750a1a13cf22b85aefadd08731c4998c3cd4d8
parent40e7bf8033356c07e957b6c47f742a7ea26f3496 (diff)
[PATCH] fio: replace home grown argument parsing with getopt()
-rw-r--r--fio-ini.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/fio-ini.c b/fio-ini.c
index 9817b21..fdeea52 100644
--- a/fio-ini.c
+++ b/fio-ini.c
@@ -725,23 +725,15 @@ static int fill_def_thread(void)
static void parse_cmd_line(int argc, char *argv[])
{
- int i;
+ int c;
- for (i = 1; i < argc; i++) {
- char *parm = argv[i];
-
- if (parm[0] != '-')
- break;
-
- parm++;
- switch (*parm) {
+ while ((c = getopt(argc, argv, "s:b:t:r:R:o:f:lw")) != EOF) {
+ switch (c) {
case 's':
- parm++;
- def_thread.sequential = !!atoi(parm);
+ def_thread.sequential = !!atoi(optarg);
break;
case 'b':
- parm++;
- def_thread.bs = atoi(parm);
+ def_thread.bs = atoi(optarg);
def_thread.bs <<= 10;
if (!def_thread.bs) {
printf("bad block size\n");
@@ -749,28 +741,19 @@ static void parse_cmd_line(int argc, char *argv[])
}
break;
case 't':
- parm++;
- def_thread.timeout = atoi(parm);
+ def_thread.timeout = atoi(optarg);
break;
case 'r':
- parm++;
- repeatable = !!atoi(parm);
+ repeatable = !!atoi(optarg);
break;
case 'R':
- parm++;
- rate_quit = !!atoi(parm);
+ rate_quit = !!atoi(optarg);
break;
case 'o':
- parm++;
- def_thread.odirect = !!atoi(parm);
+ def_thread.odirect = !!atoi(optarg);
break;
case 'f':
- if (i + 1 >= argc) {
- printf("-f needs file as arg\n");
- break;
- }
- ini_file = strdup(argv[i+1]);
- i++;
+ ini_file = strdup(optarg);
break;
case 'l':
write_lat_log = 1;
@@ -778,9 +761,6 @@ static void parse_cmd_line(int argc, char *argv[])
case 'w':
write_bw_log = 1;
break;
- default:
- printf("bad option %s\n", argv[i]);
- break;
}
}
}