Mercurial > illumos > illumos-gate
changeset 2979:6d134878cca1
6477702 DVD-R doesn't get ejected automatically after cdrw finishes
author | zk194757 |
---|---|
date | Tue, 24 Oct 2006 12:56:47 -0700 |
parents | a77a2fdc9d9e |
children | 58e8c2989931 |
files | usr/src/cmd/cdrw/misc_scsi.c usr/src/cmd/cdrw/mmc.c usr/src/cmd/cdrw/mmc.h |
diffstat | 3 files changed, 50 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/cdrw/misc_scsi.c Tue Oct 24 09:55:12 2006 -0700 +++ b/usr/src/cmd/cdrw/misc_scsi.c Tue Oct 24 12:56:47 2006 -0700 @@ -572,6 +572,19 @@ if (vol_running) { /* If there is a media, try using DKIOCEJECT 1st */ if (check_device(dev, CHECK_NO_MEDIA) == 0) { + /* + * The check_device() call will issue + * a TEST UNIT READY (TUR) and retry many + * times when a DVD-R is present. The DKIOCEJECT + * ioctl will subsequently fail causing us to + * issue the LOAD/UNLOAD SCSI command to the device + * with out ejecting the media. Insted of letting + * this happen, issue a reset to the device before + * issuing the DKIOCEJCET ioctl. + */ + if (device_type == DVD_MINUS) + reset_dev(dev->d_fd); + if (ioctl(dev->d_fd, DKIOCEJECT, 0) == 0) { return (1); }
--- a/usr/src/cmd/cdrw/mmc.c Tue Oct 24 09:55:12 2006 -0700 +++ b/usr/src/cmd/cdrw/mmc.c Tue Oct 24 12:56:47 2006 -0700 @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -673,6 +672,38 @@ } /* + * Used to reset the device. Since, sd(7D) requires a + * command to be issued when resetting a device we will + * issue an innocuous command. The command chosen for this + * purpose is the TEST UNIT READY (TUR) command. We also do + * not care about the sucess of the TUR so we will not return + * a value. + */ +void +reset_dev(int fd) +{ + struct uscsi_cmd *scmd; + + /* + * Since a TUR has SCSI operation code of 0, we + * can make use of the fact that get_uscsi_cmd() + * initializes a CDB to all zeros to generate + * the TUR command. + */ + scmd = get_uscsi_cmd(); + + /* Tell sd(7D) to do a silent reset of the device. */ + scmd->uscsi_flags = USCSI_SILENT | USCSI_RESET; + + scmd->uscsi_timeout = DEFAULT_SCSI_TIMEOUT; + scmd->uscsi_cdblen = 6; + + /* Issue the TUR command. */ + uscsi_error = uscsi(fd, scmd); +} + + +/* * Function: ftr_supported * * Description: Check to see if a device supports a Feature
--- a/usr/src/cmd/cdrw/mmc.h Tue Oct 24 09:55:12 2006 -0700 +++ b/usr/src/cmd/cdrw/mmc.h Tue Oct 24 12:56:47 2006 -0700 @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -97,6 +96,7 @@ int set_reservation(int fd, ulong_t size); int format_media(int fd); uint32_t read_format_capacity(int fd, uint_t *bsize); +void reset_dev(int fd); int uscsi_error; /* used for debugging failed uscsi */