Do not compile scsi ioctl decoding if <scsi/sg.h> is not available

Add a generic test for <scsi/sg.h> availability to fix build with
Bionic libc that does not provide <scsi/sg.h>.

* configure.ac (AC_CHECK_HEADERS): Add scsi/sg.h.
* ioctl.c (ioctl_decode): Do not call scsi_ioctl if !HAVE_SCSI_SG_H.
* scsi.c: Do not compile scsi ioctl decoding if !HAVE_SCSI_SG_H.

Reported-by: Elliott Hughes <enh@google.com>
This commit is contained in:
2014-02-25 23:04:55 +00:00
parent a7c6e5143c
commit fdb896e577
3 changed files with 10 additions and 2 deletions

View File

@ -220,6 +220,7 @@ AC_CHECK_HEADERS(m4_normalize([
mqueue.h
netinet/sctp.h
poll.h
scsi/sg.h
stropts.h
sys/acl.h
sys/asynch.h

View File

@ -86,8 +86,10 @@ ioctl_decode(struct tcb *tcp, long code, long arg)
case 0x03:
case 0x12:
return block_ioctl(tcp, code, arg);
#ifdef HAVE_SCSI_SG_H
case 0x22:
return scsi_ioctl(tcp, code, arg);
#endif
case 'L':
return loop_ioctl(tcp, code, arg);
case 'M':

9
scsi.c
View File

@ -27,8 +27,11 @@
*/
#include "defs.h"
#include <sys/ioctl.h>
#include <scsi/sg.h>
#ifdef HAVE_SCSI_SG_H
# include <sys/ioctl.h>
# include <scsi/sg.h>
static const struct xlat sg_io_dxfer_direction[] = {
XLAT(SG_DXFER_NONE),
@ -137,3 +140,5 @@ scsi_ioctl(struct tcb *tcp, long code, long arg)
}
return 1;
}
#endif /* HAVE_SCSI_SG_H */