/[debburn]/nonameyet/trunk/libscg/scsi-linux-sg.c
ViewVC logotype

Diff of /nonameyet/trunk/libscg/scsi-linux-sg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 40 by blade, Wed Aug 23 12:39:11 2006 UTC revision 41 by blade, Wed Aug 23 12:50:32 2006 UTC
# Line 65  static char __sccsid[] = Line 65  static char __sccsid[] =
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>
# Line 1258  scgo_send(scgp) Line 1245  scgo_send(scgp)
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;
# Line 1291  static uid_t           cureuid = 0;    /* XXX Hack u Line 1277  static uid_t           cureuid = 0;    /* XXX Hack u
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);
# Line 1322  again: Line 1296  again:
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                  }                  }

Legend:
Removed from v.40  
changed lines
  Added in v.41

  ViewVC Help
Powered by ViewVC 1.1.5