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