1*44704f69SBart Van Assche #ifndef SG_LINUX_INC_H 2*44704f69SBart Van Assche #define SG_LINUX_INC_H 3*44704f69SBart Van Assche 4*44704f69SBart Van Assche #ifdef SG_KERNEL_INCLUDES 5*44704f69SBart Van Assche #include <stdint.h> /* C99 header for exact integer types */ 6*44704f69SBart Van Assche #define __user 7*44704f69SBart Van Assche typedef uint8_t u8; 8*44704f69SBart Van Assche #include "/usr/src/linux/include/scsi/sg.h" 9*44704f69SBart Van Assche #include "/usr/src/linux/include/scsi/scsi.h" 10*44704f69SBart Van Assche #else 11*44704f69SBart Van Assche #ifdef SG_TRICK_GNU_INCLUDES 12*44704f69SBart Van Assche #include <linux/../scsi/sg.h> 13*44704f69SBart Van Assche #include <linux/../scsi/scsi.h> 14*44704f69SBart Van Assche #else 15*44704f69SBart Van Assche #define __user 16*44704f69SBart Van Assche #include <scsi/sg.h> 17*44704f69SBart Van Assche #include <scsi/scsi.h> 18*44704f69SBart Van Assche #endif 19*44704f69SBart Van Assche #endif 20*44704f69SBart Van Assche 21*44704f69SBart Van Assche #ifdef BLKGETSIZE64 22*44704f69SBart Van Assche #ifndef u64 23*44704f69SBart Van Assche #include <stdint.h> /* C99 header for exact integer types */ 24*44704f69SBart Van Assche typedef uint64_t u64; /* problems with BLKGETSIZE64 ioctl in lk 2.4 */ 25*44704f69SBart Van Assche #endif 26*44704f69SBart Van Assche #endif 27*44704f69SBart Van Assche 28*44704f69SBart Van Assche /* 29*44704f69SBart Van Assche Getting the correct include files for the sg interface can be an ordeal. 30*44704f69SBart Van Assche In a perfect world, one would just write: 31*44704f69SBart Van Assche #include <scsi/sg.h> 32*44704f69SBart Van Assche #include <scsi/scsi.h> 33*44704f69SBart Van Assche This would include the files found in the /usr/include/scsi directory. 34*44704f69SBart Van Assche Those files are maintained with the GNU library which may or may not 35*44704f69SBart Van Assche agree with the kernel and version of sg driver that is running. Any 36*44704f69SBart Van Assche many cases this will not matter. However in some it might, for example 37*44704f69SBart Van Assche glibc 2.1's include files match the sg driver found in the lk 2.2 38*44704f69SBart Van Assche series. Hence if glibc 2.1 is used with lk 2.4 then the additional 39*44704f69SBart Van Assche sg v3 interface will not be visible. 40*44704f69SBart Van Assche If this is a problem then defining SG_KERNEL_INCLUDES will access the 41*44704f69SBart Van Assche kernel supplied header files (assuming they are in the normal place). 42*44704f69SBart Van Assche The GNU library maintainers and various kernel people don't like 43*44704f69SBart Van Assche this approach (but it does work). 44*44704f69SBart Van Assche The technique selected by defining SG_TRICK_GNU_INCLUDES worked (and 45*44704f69SBart Van Assche was used) prior to glibc 2.2 . Prior to that version /usr/include/linux 46*44704f69SBart Van Assche was a symbolic link to /usr/src/linux/include/linux . 47*44704f69SBart Van Assche 48*44704f69SBart Van Assche There are other approaches if this include "mixup" causes pain. These 49*44704f69SBart Van Assche would involve include files being copied or symbolic links being 50*44704f69SBart Van Assche introduced. 51*44704f69SBart Van Assche 52*44704f69SBart Van Assche Sorry about the inconvenience. Typically neither SG_KERNEL_INCLUDES 53*44704f69SBart Van Assche nor SG_TRICK_GNU_INCLUDES is defined. 54*44704f69SBart Van Assche 55*44704f69SBart Van Assche dpg 20010415, 20030522 56*44704f69SBart Van Assche */ 57*44704f69SBart Van Assche 58*44704f69SBart Van Assche #endif 59