For now using CDROM_SIMUL_CHANGE only if -DLibburn_use_linux_ioctl_simul_changE

This commit is contained in:
Thomas Schmitt 2020-09-20 22:46:55 +02:00
parent ab6b1039a4
commit 6b2ae7d141
2 changed files with 33 additions and 20 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2020.09.20.084444" #define Cdrskin_timestamP "2020.09.20.204320"

View File

@ -826,14 +826,14 @@ static int sg_release_siblings(int sibling_fds[],
static int sg_os_revalidate_disc(struct burn_drive *d) static int sg_os_revalidate_disc(struct burn_drive *d)
{ {
/* <<< only for compiler tests */ #ifdef Libburn_use_linux_ioctl_simul_changE
/* # def ine BURN_CDROM_SIMUL_CHANGE 0x5332 */
#ifdef CDROM_SIMUL_CHANGE /* <<< only for compiler tests */
#define BURN_CDROM_SIMUL_CHANGE CDROM_SIMUL_CHANGE #ifndef CDROM_SIMUL_CHANGE
/* # def ine CDROM_SIMUL_CHANGE 0x5332 */
#endif #endif
#ifdef BURN_CDROM_SIMUL_CHANGE #ifdef CDROM_SIMUL_CHANGE
int fd, ret; int fd, ret;
long old_blocks, new_blocks; long old_blocks, new_blocks;
@ -845,18 +845,26 @@ static int sg_os_revalidate_disc(struct burn_drive *d)
if (ret == -1) if (ret == -1)
old_blocks = -1; old_blocks = -1;
/* Schedule a simulated medium change event */ /* Schedule a simulated medium change event.
ioctl(d->fd, BURN_CDROM_SIMUL_CHANGE, 0); Although the implemented ioctl cannot fail, the kernel might be too
old to know it and then throw errors like ENOTTY.
*/
ret = ioctl(d->fd, CDROM_SIMUL_CHANGE, 0);
if (ret == -1) {
libdax_msgs_submit(libdax_messenger, d->global_index,
0x02, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
"ioctl(CDROM_SIMUL_CHANGE) failed", errno, 0);
ret = 0; goto ex;
}
libdax_msgs_submit(libdax_messenger, d->global_index, libdax_msgs_submit(libdax_messenger, d->global_index,
0x00000002, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH, 0x02, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
"Emitted ioctl(CDROM_SIMUL_CHANGE)", 0, 0); "ioctl(CDROM_SIMUL_CHANGE) was performed", 0, 0);
/* Try to trigger actual device assessment by a open(2) call */ /* Try to trigger actual device assessment by a open(2) call */
fd = open(d->devname, O_RDONLY | O_NDELAY); fd = open(d->devname, O_RDONLY | O_NDELAY);
if (fd == -1) { if (fd == -1) {
libdax_msgs_submit(libdax_messenger, d->global_index, libdax_msgs_submit(libdax_messenger, d->global_index,
0x00000002, LIBDAX_MSGS_SEV_DEBUG, 0x02, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
LIBDAX_MSGS_PRIO_HIGH, "Failed to open device file after ioctl(CDROM_SIMUL_CHANGE)",
"Failed to open device file after ioctl(CDROM_SIMUL_CHANGE)",
errno, 0); errno, 0);
ret = 0; goto ex; ret = 0; goto ex;
} }
@ -864,8 +872,7 @@ static int sg_os_revalidate_disc(struct burn_drive *d)
ret = ioctl(d->fd, BLKGETSIZE, &new_blocks); ret = ioctl(d->fd, BLKGETSIZE, &new_blocks);
if (ret == -1) { if (ret == -1) {
libdax_msgs_submit(libdax_messenger, d->global_index, libdax_msgs_submit(libdax_messenger, d->global_index,
0x00000002, LIBDAX_MSGS_SEV_DEBUG, 0x02, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
LIBDAX_MSGS_PRIO_HIGH,
"BLKGETSIZE failed after ioctl(CDROM_SIMUL_CHANGE)", "BLKGETSIZE failed after ioctl(CDROM_SIMUL_CHANGE)",
errno, 0); errno, 0);
} else if (old_blocks != new_blocks) { } else if (old_blocks != new_blocks) {
@ -873,18 +880,24 @@ static int sg_os_revalidate_disc(struct burn_drive *d)
"BLKGETSIZE indicates size change from %ld to %ld blocks", "BLKGETSIZE indicates size change from %ld to %ld blocks",
old_blocks , new_blocks); old_blocks , new_blocks);
libdax_msgs_submit(libdax_messenger, d->global_index, libdax_msgs_submit(libdax_messenger, d->global_index,
0x00000002, LIBDAX_MSGS_SEV_DEBUG, 0x02, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
LIBDAX_MSGS_PRIO_HIGH, msg, 0, 0); msg, 0, 0);
} }
ex: ex:
BURN_FREE_MEM(msg); BURN_FREE_MEM(msg);
return 1; return ret;
#else #else /* CDROM_SIMUL_CHANGE */
return 0; return 0;
#endif /* BURN_CDROM_SIMUL_CHANGE */ #endif /* ! CDROM_SIMUL_CHANGE */
#else /* Libburn_use_linux_ioctl_simul_changE */
return 0;
#endif /* ! Libburn_use_linux_ioctl_simul_changE */
} }