| 65 |
#if LINUX_VERSION_CODE >= 0x01031a /* <linux/scsi.h> introduced in 1.3.26 */ |
#if LINUX_VERSION_CODE >= 0x01031a /* <linux/scsi.h> introduced in 1.3.26 */ |
| 66 |
#if LINUX_VERSION_CODE >= 0x020000 /* <scsi/scsi.h> introduced somewhere. */ |
#if LINUX_VERSION_CODE >= 0x020000 /* <scsi/scsi.h> introduced somewhere. */ |
| 67 |
/* Need to fine tune the ifdef so we get the transition point right. */ |
/* Need to fine tune the ifdef so we get the transition point right. */ |
|
|
|
|
#if defined(HAVE_BROKEN_SCSI_SCSI_H) || \ |
|
|
defined(HAVE_BROKEN_SRC_SCSI_SCSI_H) |
|
|
/* |
|
|
* Be very careful in case that the Linux Kernel maintainers |
|
|
* unexpectedly fix the bugs in the Linux Lernel include files. |
|
|
* Only introduce the attempt for a workaround in case the include |
|
|
* files are broken anyway. |
|
|
*/ |
|
|
#define __KERNEL__ |
|
|
#include <asm/types.h> |
|
|
#undef __KERNEL__ |
|
|
#endif |
|
| 68 |
#include <scsi/scsi.h> |
#include <scsi/scsi.h> |
| 69 |
#else |
#else |
| 70 |
#include <linux/scsi.h> |
#include <linux/scsi.h> |
| 1245 |
int ret; |
int ret; |
| 1246 |
sg_io_hdr_t sg_io; |
sg_io_hdr_t sg_io; |
| 1247 |
struct timeval to; |
struct timeval to; |
|
static uid_t cureuid = 0; /* XXX Hack until we have uid management */ |
|
| 1248 |
|
|
| 1249 |
if (scgp->fd < 0) { |
if (scgp->fd < 0) { |
| 1250 |
sp->error = SCG_FATAL; |
sp->error = SCG_FATAL; |
| 1277 |
sg_io.timeout = sp->timeout*1000; |
sg_io.timeout = sp->timeout*1000; |
| 1278 |
sg_io.flags |= SG_FLAG_DIRECT_IO; |
sg_io.flags |= SG_FLAG_DIRECT_IO; |
| 1279 |
|
|
|
if (cureuid != 0) |
|
|
seteuid(0); |
|
|
again: |
|
|
errno = 0; |
|
| 1280 |
ret = ioctl(scgp->fd, SG_IO, &sg_io); |
ret = ioctl(scgp->fd, SG_IO, &sg_io); |
|
if (ret < 0 && geterrno() == EPERM) { /* XXX Hack until we have uid management */ |
|
|
cureuid = geteuid(); |
|
|
if (seteuid(0) >= 0) |
|
|
goto again; |
|
|
} |
|
|
if (cureuid != 0) |
|
|
seteuid(cureuid); |
|
|
|
|
| 1281 |
if (scgp->debug > 0) { |
if (scgp->debug > 0) { |
| 1282 |
js_fprintf((FILE *)scgp->errfile, |
js_fprintf((FILE *)scgp->errfile, |
| 1283 |
"ioctl ret: %d\n", ret); |
"ioctl ret: %d\n", ret); |
| 1296 |
scglocal(scgp)->isold = 1; |
scglocal(scgp)->isold = 1; |
| 1297 |
return (sg_rwsend(scgp)); |
return (sg_rwsend(scgp)); |
| 1298 |
} |
} |
| 1299 |
if (sp->ux_errno == ENXIO || sp->ux_errno == EPERM || |
if (sp->ux_errno == ENXIO || |
| 1300 |
sp->ux_errno == EINVAL || sp->ux_errno == EACCES) { |
sp->ux_errno == EINVAL || sp->ux_errno == EACCES) { |
| 1301 |
return (-1); |
return (-1); |
| 1302 |
} |
} |