Add a "dummy light" (actually two dummy lights) to catch people who don't

have the passthrough device configured in their kernel.

This will hopefully reduce the number of people complaining that they can't
get {camcontrol, xmcd, tosha, cdrecord, etc.} to work.

Reviewed by:	gibbs
This commit is contained in:
ken 1998-10-12 21:54:13 +00:00
parent e3811b3bae
commit 9cc9919f68
2 changed files with 45 additions and 5 deletions

View File

@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: camlib.c,v 1.1 1998/09/15 06:16:46 gibbs Exp $
*/
#include <sys/types.h>
@ -491,11 +491,29 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
/*
* Attempt to get the passthrough device. This ioctl will fail if
* the device name is null, or if the device doesn't exist.
* the device name is null, if the device doesn't exist, or if the
* passthrough driver isn't in the kernel.
*/
if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) {
sprintf(cam_errbuf, "%s: CAMGETPASSTHRU ioctl failed\n"
"%s: %s", func_name, func_name, strerror(errno));
char tmpstr[256];
/*
* If we get ENOENT from the transport layer version of
* the CAMGETPASSTHRU ioctl, it means one of two things:
* either the device name/unit number passed in doesn't
* exist, or the passthrough driver isn't in the kernel.
*/
if (errno == ENOENT) {
snprintf(tmpstr, sizeof(tmpstr),
"\n%s: either the pass driver isn't in "
"your kernel\n%s: or %s%d doesn't exist",
func_name, func_name, dev_name, unit);
}
snprintf(cam_errbuf, sizeof(cam_errbuf),
"%s: CAMGETPASSTHRU ioctl failed\n"
"%s: %s%s", func_name, func_name, strerror(errno),
(errno == ENOENT) ? tmpstr : "");
return(NULL);
}
@ -589,6 +607,11 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
* parameter: the passthrough driver unit number.
*/
if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) {
/*
* At this point we know the passthrough device must exist
* because we just opened it above. The only way this
* ioctl can fail is if the ccb size is wrong.
*/
sprintf(cam_errbuf, "%s: CAMGETPASSTHRU ioctl failed\n"
"%s: %s", func_name, func_name, strerror(errno));
goto crod_bailout;

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cam_xpt.c,v 1.17 1998/10/07 03:25:21 gibbs Exp $
* $Id: cam_xpt.c,v 1.18 1998/10/10 21:10:36 gibbs Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
@ -941,6 +941,7 @@ xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
char *name;
int unit;
int cur_generation;
int base_periph_found;
int splbreaknum;
int s;
int i;
@ -959,6 +960,8 @@ xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
ccb = (union ccb *)addr;
base_periph_found = 0;
/*
* Sanity check -- make sure we don't get a null peripheral
* driver name.
@ -1018,6 +1021,7 @@ xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
struct cam_ed *device;
int i;
base_periph_found = 1;
device = periph->path->device;
for (i = 0, periph = device->periphs.slh_first;
periph != NULL;
@ -1077,6 +1081,19 @@ xptioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
*ccb->cgdl.periph_name = '\0';
ccb->cgdl.unit_number = 0;
error = ENOENT;
/*
* It is unfortunate that this is even necessary,
* but there are many, many clueless users out there.
* If this is true, the user is looking for the
* passthrough driver, but doesn't have one in his
* kernel.
*/
if (base_periph_found == 1) {
printf("xptioctl: pass driver is not in the "
"kernel\n");
printf("xptioctl: put \"device pass0\" in "
"your kernel config file\n");
}
}
splx(s);
break;