[PATCH] sgioread: fix -s option
authorJens Axboe <axboe@suse.de>
Wed, 23 Nov 2005 11:49:19 +0000 (12:49 +0100)
committerJens Axboe <axboe@suse.de>
Wed, 23 Nov 2005 11:49:19 +0000 (12:49 +0100)
sgioread.c

index f678fd6d63ca8b91af80964da225186f59efd314..2f1e98889756c17f92850a188968cbd3b1d7d6de 100644 (file)
@@ -218,6 +218,7 @@ int main(int argc, char *argv[])
                buffer = ALIGN(ptr);
 
        lba = start_lba;
+       if (!nr_blocks)
                nr_blocks = end_lba - lba + 1;
 
        printf("disk %s: reading LBA %lu -> %lu", device, start_lba, end_lba);
@@ -276,7 +277,7 @@ int main(int argc, char *argv[])
                if (fd_out != -1)
                        write_the_crap(fd_out, buffer, blocks * block_size);
 
-       } while (lba <= end_lba);
+       } while (lba <= end_lba && nr_blocks);
 
        print_datarate(sectors_since_last, time_spent);
        printf("\n");