camlib.c (f736a45077330caa65c4d986ab03d39e872c6f55) | camlib.c (621a60d46b7d15397933403c138912c7989cb47b) |
---|---|
1/* 2 * Copyright (c) 1997, 1998 Kenneth D. Merry. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * | 1/* 2 * Copyright (c) 1997, 1998 Kenneth D. Merry. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 8 unchanged lines hidden (view full) --- 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * |
25 * $Id$ | 25 * $Id: camlib.c,v 1.1 1998/09/15 06:16:46 gibbs Exp $ |
26 */ 27 28#include <sys/types.h> 29#include <sys/param.h> 30#include <stdio.h> 31#include <stdlib.h> 32#include <string.h> 33#include <fcntl.h> --- 452 unchanged lines hidden (view full) --- 486 487 /* These two are necessary for the GETPASSTHRU ioctl to work. */ 488 strncpy(ccb.cgdl.periph_name, dev_name, DEV_IDLEN - 1); 489 ccb.cgdl.periph_name[DEV_IDLEN - 1] = '\0'; 490 ccb.cgdl.unit_number = unit; 491 492 /* 493 * Attempt to get the passthrough device. This ioctl will fail if | 26 */ 27 28#include <sys/types.h> 29#include <sys/param.h> 30#include <stdio.h> 31#include <stdlib.h> 32#include <string.h> 33#include <fcntl.h> --- 452 unchanged lines hidden (view full) --- 486 487 /* These two are necessary for the GETPASSTHRU ioctl to work. */ 488 strncpy(ccb.cgdl.periph_name, dev_name, DEV_IDLEN - 1); 489 ccb.cgdl.periph_name[DEV_IDLEN - 1] = '\0'; 490 ccb.cgdl.unit_number = unit; 491 492 /* 493 * Attempt to get the passthrough device. This ioctl will fail if |
494 * the device name is null, or if the device doesn't exist. | 494 * the device name is null, if the device doesn't exist, or if the 495 * passthrough driver isn't in the kernel. |
495 */ 496 if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) { | 496 */ 497 if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) { |
497 sprintf(cam_errbuf, "%s: CAMGETPASSTHRU ioctl failed\n" 498 "%s: %s", func_name, func_name, strerror(errno)); | 498 char tmpstr[256]; 499 500 /* 501 * If we get ENOENT from the transport layer version of 502 * the CAMGETPASSTHRU ioctl, it means one of two things: 503 * either the device name/unit number passed in doesn't 504 * exist, or the passthrough driver isn't in the kernel. 505 */ 506 if (errno == ENOENT) { 507 snprintf(tmpstr, sizeof(tmpstr), 508 "\n%s: either the pass driver isn't in " 509 "your kernel\n%s: or %s%d doesn't exist", 510 func_name, func_name, dev_name, unit); 511 } 512 snprintf(cam_errbuf, sizeof(cam_errbuf), 513 "%s: CAMGETPASSTHRU ioctl failed\n" 514 "%s: %s%s", func_name, func_name, strerror(errno), 515 (errno == ENOENT) ? tmpstr : ""); 516 |
499 return(NULL); 500 } 501 502 close(fd); 503 504 /* 505 * If the ioctl returned the right status, but we got an error back 506 * in the ccb, that means that the kernel found the device the user --- 77 unchanged lines hidden (view full) --- 584 ccb.ccb_h.func_code = XPT_GDEVLIST; 585 586 /* 587 * We're only doing this to get some information on the device in 588 * question. Otherwise, we'd have to pass in yet another 589 * parameter: the passthrough driver unit number. 590 */ 591 if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) { | 517 return(NULL); 518 } 519 520 close(fd); 521 522 /* 523 * If the ioctl returned the right status, but we got an error back 524 * in the ccb, that means that the kernel found the device the user --- 77 unchanged lines hidden (view full) --- 602 ccb.ccb_h.func_code = XPT_GDEVLIST; 603 604 /* 605 * We're only doing this to get some information on the device in 606 * question. Otherwise, we'd have to pass in yet another 607 * parameter: the passthrough driver unit number. 608 */ 609 if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) { |
610 /* 611 * At this point we know the passthrough device must exist 612 * because we just opened it above. The only way this 613 * ioctl can fail is if the ccb size is wrong. 614 */ |
|
592 sprintf(cam_errbuf, "%s: CAMGETPASSTHRU ioctl failed\n" 593 "%s: %s", func_name, func_name, strerror(errno)); 594 goto crod_bailout; 595 } 596 597 /* 598 * If the ioctl returned the right status, but we got an error back 599 * in the ccb, that means that the kernel found the device the user --- 158 unchanged lines hidden --- | 615 sprintf(cam_errbuf, "%s: CAMGETPASSTHRU ioctl failed\n" 616 "%s: %s", func_name, func_name, strerror(errno)); 617 goto crod_bailout; 618 } 619 620 /* 621 * If the ioctl returned the right status, but we got an error back 622 * in the ccb, that means that the kernel found the device the user --- 158 unchanged lines hidden --- |