From 698866015e61cb9723241a63eaec1287a59402d4 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 18 Sep 2007 09:05:05 +0000 Subject: [PATCH] New API function burn_drive_leave_locked() --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/drive.c | 31 ++++++++++++++++++++++++++----- libburn/libburn.h | 14 +++++++++++++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index f4fc8af..7269391 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2007.09.18.072234" +#define Cdrskin_timestamP "2007.09.18.090713" diff --git a/libburn/drive.c b/libburn/drive.c index 812bcb6..b50433e 100644 --- a/libburn/drive.c +++ b/libburn/drive.c @@ -114,6 +114,8 @@ void burn_drive_free_all(void) /* ts A60822 */ int burn_drive_is_open(struct burn_drive *d) { + if (d->drive_role != 1) + return (d->stdio_fd >= 0); /* ts A61021 : moved decision to sg.c */ return d->drive_is_open(d); } @@ -421,7 +423,10 @@ int burn_drive_mark_unready(struct burn_drive *d) } -void burn_drive_release(struct burn_drive *d, int le) +/* ts A70918 : outsourced from burn_drive_release() and enhanced */ +/** @param flag bit0-2 = mode : 0=unlock , 1=unlock+eject , 2=leave locked +*/ +int burn_drive_release_fl(struct burn_drive *d, int flag) { if (d->released) { /* ts A61007 */ @@ -430,7 +435,7 @@ void burn_drive_release(struct burn_drive *d, int le) d->global_index, 0x00020105, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, "Drive is already released", 0, 0); - return; + return 0; } /* ts A61007 */ @@ -441,12 +446,13 @@ void burn_drive_release(struct burn_drive *d, int le) d->global_index, 0x00020106, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, "Drive is busy on attempt to close", 0, 0); - return; + return 0; } if (d->drive_role == 1) { - d->unlock(d); - if (le) + if ((flag & 7) != 2) + d->unlock(d); + if ((flag & 7) == 1) d->eject(d); d->release(d); } @@ -455,9 +461,24 @@ void burn_drive_release(struct burn_drive *d, int le) /* ts A61125 : outsourced model aspects */ burn_drive_mark_unready(d); + return 1; } +/* API */ +void burn_drive_release(struct burn_drive *d, int le) +{ + burn_drive_release_fl(d, !!le); +} + + +/* ts A70918 */ +/* API */ +int burn_drive_leave_locked(struct burn_drive *d, int flag) +{ + return burn_drive_release_fl(d, 2); +} + /* ts A61007 : former void burn_wait_all() */ /* @param flag bit0= demand freed drives (else released drives) */ diff --git a/libburn/libburn.h b/libburn/libburn.h index 0f044d1..84c3121 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -829,13 +829,25 @@ int burn_drive_grab(struct burn_drive *drive, int load); /** Release a drive. This should not be done until the drive is no longer busy (see burn_drive_get_status). - Linux: The drive is unlocked afterwards. (O_EXCL , F_SETLK). + Linux: The drive device file is not reserved afterwards. (O_EXCL, F_SETLK). @param drive The drive to release. @param eject Nonzero to make the drive eject the disc in it. */ void burn_drive_release(struct burn_drive *drive, int eject); +/* ts A70918 */ +/** Like burn_drive_release() but keeping the drive tray closed and its + eject button disabled. This physically locked drive state will last until + the drive is grabbed again and released via burn_drive_release(). + Programs like eject, cdrecord, growisofs will break that ban too. + @param drive The drive to release and leave locked. + @param flag Bitfield for control purposes (unused yet, submit 0) + @return 1 means success, <=0 means failure +*/ +int burn_drive_leave_locked(struct burn_drive *d, int flag); + + /** Returns what kind of disc a drive is holding. This function may need to be called more than once to get a proper status from it. See burn_disc_status for details.