From 86d5bdfef8c319181f775285426df7485b51c282 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 3 Mar 2008 20:30:10 +0000 Subject: [PATCH] Got rid of a cumbersome open-close cycle with burn_read_data() on stdio: --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/drive.c | 3 +++ libburn/libburn.h | 2 +- libburn/read.c | 7 ++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 2a96635..e23e9d5 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2008.02.28.132325" +#define Cdrskin_timestamP "2008.03.03.202930" diff --git a/libburn/drive.c b/libburn/drive.c index 5cd654e..f084f8b 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -439,6 +439,9 @@ int burn_drive_mark_unready(struct burn_drive *d) burn_disc_free(d->disc); d->disc = NULL; } + if (d->stdio_fd >= 0) + close (d->stdio_fd); + d->stdio_fd = -1; return 1; } diff --git a/libburn/libburn.h b/libburn/libburn.h index 1862b4e..b9f60a6 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -642,7 +642,7 @@ struct burn_speed_descriptor { This must be called before using any other functions in the library. It may be called more than once with no effect. It is possible to 'restart' the library by shutting it down and - re-initializing it. This is necessary if you follow the older and + re-initializing it. Once this was necessary if you follow the older and more general way of accessing a drive via burn_drive_scan() and burn_drive_grab(). See burn_drive_scan_and_grab() with its strong urges and its explanations. diff --git a/libburn/read.c b/libburn/read.c index aa1863c..c82b05c 100644 --- a/libburn/read.c +++ b/libburn/read.c @@ -388,7 +388,10 @@ int burn_read_data(struct burn_drive *d, off_t byte_address, #define O_LARGEFILE 0 #endif - fd = open(d->devname, O_RDONLY | O_LARGEFILE); + fd = d->stdio_fd; + if (fd < 0) + d->stdio_fd = fd = + open(d->devname, O_RDONLY | O_LARGEFILE); if (fd == -1) { if (errno != ENOENT || !(flag & 2)) libdax_msgs_submit(libdax_messenger, @@ -478,8 +481,10 @@ int burn_read_data(struct burn_drive *d, off_t byte_address, ret = 1; ex:; +/* <<< let it open until drive is given up or writing shall happen if (fd != -1) close(fd); +*/ d->buffer = NULL; d->busy = BURN_DRIVE_IDLE; return ret;