From e86a7f98804e6479ab26b88f09ab6e7bbc2be677 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 24 Mar 2011 18:21:31 +0000 Subject: [PATCH] Better handling of read attempt on pseudo-drive without read-permission --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/libburn.h | 7 ++++++- libburn/libdax_msgs.h | 1 + libburn/read.c | 18 ++++++++++++++---- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 4832355..14618b0 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2011.03.22.085956" +#define Cdrskin_timestamP "2011.03.24.182148" diff --git a/libburn/libburn.h b/libburn/libburn.h index 414bb36..91ca263 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -2998,8 +2998,13 @@ int burn_get_read_capacity(struct burn_drive *d, int *capacity, int flag); bit0= - reserved - bit1= do not submit error message if read error bit2= on error do not try to read a second time - with single block steps. @since 0.5.2 + with single block steps. + @since 0.5.2 + bit3= return -2 on permission denied error rather than + issueing a warning message. + @since 1.0.6 @return 1=sucessful , <=0 an error occured + with bit3: -2= permission denied error @since 0.4.0 */ int burn_read_data(struct burn_drive *d, off_t byte_address, diff --git a/libburn/libdax_msgs.h b/libburn/libdax_msgs.h index 9d1a75c..a66d527 100644 --- a/libburn/libdax_msgs.h +++ b/libburn/libdax_msgs.h @@ -568,6 +568,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff 0x00020180 (FAILURE,HIGH) = Premature end of input encountered 0x00020181 (FAILURE,HIGH) = Pseudo-drive is a read-only file. Cannot write. 0x00020182 (FAILURE,HIGH) = Cannot truncate disk file for pseudo blanking + 0x00020183 (WARNING,HIGH) = Failed to open device (a pseudo-drive) for reading libdax_audioxtr: 0x00020200 (SORRY,HIGH) = Cannot open audio source file diff --git a/libburn/read.c b/libburn/read.c index 843b4dd..081d028 100644 --- a/libburn/read.c +++ b/libburn/read.c @@ -423,14 +423,24 @@ int burn_read_data(struct burn_drive *d, off_t byte_address, d->stdio_fd = fd = open(d->devname, O_RDONLY | O_LARGEFILE); if (fd == -1) { - if (errno != ENOENT || !(flag & 2)) + if (errno == EACCES && (flag & 2)) { + if (!(flag & 8)) + libdax_msgs_submit(libdax_messenger, + d->global_index, 0x00020183, + LIBDAX_MSGS_SEV_WARNING, + LIBDAX_MSGS_PRIO_HIGH, + "Failed to open device (a pseudo-drive) for reading", + errno, 0); + } else if (errno!= ENOENT || !(flag & 2)) libdax_msgs_submit(libdax_messenger, - d->global_index, - 0x00020005, + d->global_index, 0x00020005, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, "Failed to open device (a pseudo-drive) for reading", errno, 0); - ret = 0; goto ex; + ret = 0; + if (errno == EACCES && (flag & 8)) + ret= -2; + goto ex; } if (lseek(fd, byte_address, SEEK_SET) == -1) { if (!(flag & 2)) {