blkrawverify: warn and return error if no traces are found
authorEric Sandeen <sandeen@redhat.com>
Thu, 7 May 2009 16:08:25 +0000 (11:08 -0500)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 11 May 2009 06:43:44 +0000 (08:43 +0200)
blkrawverify is prints no errors and returns success if the
requested tracefiles aren't found:

# blkrawverify foobar
Verifying foobar
# echo $?
0

With this change it's a bit more informative:

# ./blkrawverify foobar
Verifying foobar
No tracefiles found for foobar
# echo $?
1

Resolves Red Hat Bugzilla #499581

Reported-by: Milos Malik <mmalik@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
blkrawverify.c

index 984dbffcddf66bc191154360fc323f4f2efaadec..e669179a451fa1dd2d106e00ad47d09ad9272b08 100644 (file)
@@ -296,8 +296,14 @@ int main(int argc, char *argv[])
                printf("Verifying %s\n", devname); fflush(stdout);
                for (cpu = 0; ; cpu++) {
                        sprintf(fname, "%s.blktrace.%d", devname, cpu);
-                       if (stat(fname, &st) < 0)
+                       if (stat(fname, &st) < 0) {
+                               if (cpu == 0) {
+                                       fprintf(stderr, "No tracefiles found for %s\n",
+                                               devname);
+                                       rval = 1;
+                               }
                                break;
+                       }
                        printf("    CPU %d ", cpu); fflush(stdout);
                        nbad = process(&ofp, devname, fname, cpu);
                        if (nbad) {