[PATCH] blktrace: fix error on stopping live trace and allow trace on CDROM
authorJens Axboe <axboe@suse.de>
Fri, 7 Oct 2005 08:22:41 +0000 (10:22 +0200)
committerJens Axboe <axboe@suse.de>
Fri, 7 Oct 2005 08:22:41 +0000 (10:22 +0200)
We need O_NONBLOCK to trace on an empty CDROM device

blktrace.c

index 8d78a9bd412d52f6abd1c981721eec6b1dc83969..48065d12d11e084a0aa35bdaa5e629898f33cc15 100644 (file)
@@ -186,10 +186,13 @@ static int start_trace(struct device_information *dip)
 static void stop_trace(struct device_information *dip)
 {
        if (dip->trace_started || kill_running_trace) {
+               dip->trace_started = 0;
+
                if (ioctl(dip->fd, BLKSTOPTRACE) < 0)
                        perror("BLKSTOPTRACE");
+
                close(dip->fd);
-               dip->trace_started = 0;
+               dip->fd = -1;
        }
 }
 
@@ -550,7 +553,7 @@ static int open_devices(void)
        int i;
 
        for (dip = device_information, i = 0; i < ndevs; i++, dip++) {
-               dip->fd = open(dip->path, O_RDONLY);
+               dip->fd = open(dip->path, O_RDONLY | O_NONBLOCK);
                if (dip->fd < 0) {
                        perror(dip->path);
                        return 1;