From: Jens Axboe Date: Fri, 7 Oct 2005 08:22:41 +0000 (+0200) Subject: [PATCH] blktrace: fix error on stopping live trace and allow trace on CDROM X-Git-Tag: blktrace-0.99~27 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=cf9208eac82ccd06074c026460d9bb256c2ea3a2;p=blktrace.git [PATCH] blktrace: fix error on stopping live trace and allow trace on CDROM We need O_NONBLOCK to trace on an empty CDROM device --- diff --git a/blktrace.c b/blktrace.c index 8d78a9b..48065d1 100644 --- a/blktrace.c +++ b/blktrace.c @@ -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;