- if (*end) {
- fprintf(stderr, "%s: invalid count '%s'\n", argv[0], argv[2]);
- usage(argv[0]);
- }
- if (argc >= 4) {
- if (strchr(argv[3], 'r')) {
- cmd = READ;
- flags = O_RDONLY;
- }
- if (strchr(argv[3], 'w')) {
- cmd |= WRITE;
- flags = O_RDWR | O_CREAT;
- }
- if (strchr(argv[3], 'd')) {
- flags |= O_DIRECT;
- }
- if (!cmd)
- usage(argv[0]);
- } else {
- cmd = READ | WRITE;
- flags = O_RDWR | O_CREAT | O_DIRECT;
- }
-
- if (argc >= 5) {
- pg_vec = strtoul(argv[4], &end, 0);
- if (*end) {
- fprintf(stderr, "%s: invalid pages_per_vec '%s'\n",
- argv[0], argv[4]);
- usage(argv[0]);
- }
- }
- len = pg_vec * BLOCKSIZE;
- last = (long long)count * len;
-
- if (argc >= 6) {
- objid = strtoull(argv[5], &end, 0);
- if (*end) {
- fprintf(stderr, "%s: invalid objid '%s'\n",
- argv[0], argv[5]);
- usage(argv[0]);
- }
- }
-
- printf("%s: %s on %s(objid 0x"LPX64") for "LPU64"x%ld pages \n",
- argv[0], flags & O_DIRECT ? "directio" : "i/o",
- argv[1], objid, count, pg_vec);
+ if (*end) {
+ fprintf(stderr, "%s: invalid count '%s'\n", argv[0], argv[2]);
+ usage(argv[0]);
+ }
+ if (argc >= 4) {
+ if (strchr(argv[3], 'r')) {
+ cmd = READ;
+ flags = O_RDONLY;
+ }
+ if (strchr(argv[3], 'w')) {
+ cmd |= WRITE;
+ flags = O_RDWR | O_CREAT;
+ }
+ if (strchr(argv[3], 'd')) {
+#ifdef O_DIRECT
+ flags |= O_DIRECT;
+#else
+ fprintf(stderr,
+ "%s: O_DIRECT not supported in this build\n",
+ argv[0]);
+ exit(1);
+#endif
+ }
+ if (!cmd)
+ usage(argv[0]);
+ } else {
+ cmd = READ | WRITE;
+ flags = O_RDWR | O_CREAT;
+#ifdef O_DIRECT
+ flags |= O_DIRECT;
+#else
+ fprintf(stderr, "%s: warning: not setting O_DIRECT\n",
+ argv[0]);
+#endif
+ }