From 2060297134f7e3ab82763e14894a1bdd9f084460 Mon Sep 17 00:00:00 2001 From: samm2 <samm2@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sun, 20 Sep 2009 11:51:42 +0000 Subject: [PATCH] fix FTBFS on GNU/kFreeBSD (ticket #10) git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2918 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/CHANGELOG | 2 ++ smartmontools/cciss.cpp | 4 ++++ smartmontools/os_freebsd.cpp | 20 ++++++++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index 95a6e3b86..a3e2727ae 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -43,6 +43,8 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [AS] FreeBSD: fix FTBFS on GNU/kFreeBSD (reported by derevko). + [AS] FreeBSD: Add USB autodetection to smartd DEVICESCAN directive. [CF] Add USB ID of Myson Century CS8818, add some comments. diff --git a/smartmontools/cciss.cpp b/smartmontools/cciss.cpp index 3c3258565..fca75ac20 100644 --- a/smartmontools/cciss.cpp +++ b/smartmontools/cciss.cpp @@ -19,6 +19,10 @@ # include <sys/endian.h> # include <dev/ciss/cissio.h> # define _HAVE_CCISS +#elif defined(__FreeBSD_kernel__) && defined(HAVE_DEV_CISS_CISSIO_H) +# include <endian.h> +# include <dev/ciss/cissio.h> +# define _HAVE_CCISS #endif #ifdef _HAVE_CCISS diff --git a/smartmontools/os_freebsd.cpp b/smartmontools/os_freebsd.cpp index b203a196a..182946a8a 100644 --- a/smartmontools/os_freebsd.cpp +++ b/smartmontools/os_freebsd.cpp @@ -49,7 +49,7 @@ #define USBDEV "/dev/usb" -#if __FreeBSD_version >= 800000 +#if (__FreeBSD_version >= 800000) || (__FreeBSD_kernel_version >= 800000) #include <libusb20_desc.h> #include <libusb20.h> #else @@ -178,6 +178,14 @@ private: const char * m_mode; ///< Mode string for deviceopen(). }; +#ifdef __GLIBC__ +static inline void * reallocf(void *ptr, size_t size) { + void *rv = realloc(ptr, size); + if(rv == NULL) + free(ptr); + return rv; + } +#endif freebsd_smart_device::~freebsd_smart_device() throw() { @@ -745,7 +753,7 @@ int freebsd_ata_device::ata_command_interface(smart_command_set command, int sel #endif return -1; -#if __FreeBSD_version < 502000 +#if (__FreeBSD_version < 502000) && (__FreeBSD_kernel_version < 502000) printwarning(NO_RETURN,NULL); #endif @@ -1357,7 +1365,7 @@ int do_normal_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) if (cam_send_ccb(cam_dev,ccb) < 0) { warn("error sending SCSI ccb"); -#if __FreeBSD_version > 500000 +#if (__FreeBSD_version > 500000) || (__FreeBSD_kernel_version > 500000) cam_error_print(cam_dev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); #endif cam_freeccb(ccb); @@ -1365,7 +1373,7 @@ int do_normal_scsi_cmnd_io(int fd, struct scsi_cmnd_io * iop, int report) } if (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR)) { -#if __FreeBSD_version > 500000 +#if (__FreeBSD_version > 500000) || (__FreeBSD_kernel_version > 500000) cam_error_print(cam_dev,ccb,CAM_ESF_ALL,CAM_EPF_ALL,stderr); #endif cam_freeccb(ccb); @@ -2003,7 +2011,7 @@ bool freebsd_smart_interface::scan_smart_devices(smart_device_list & devlist, } -#if __FreeBSD_version < 800000 // without this build fail on FreeBSD 8 +#if (__FreeBSD_version < 800000) || (__FreeBSD_kernel_version < 800000) // without this build fail on FreeBSD 8 static char done[USB_MAX_DEVICES]; static int usbdevinfo(int f, int a, int rec, int busno, unsigned short & vendor_id, @@ -2059,7 +2067,7 @@ static int usbdevinfo(int f, int a, int rec, int busno, unsigned short & vendor_ static int usbdevlist(int busno,unsigned short & vendor_id, unsigned short & product_id, unsigned short & version) { -#if __FreeBSD_version >= 800000 // libusb2 interface +#if (__FreeBSD_version >= 800000) || (__FreeBSD_kernel_version >= 800000) // libusb2 interface struct libusb20_device *pdev = NULL; struct libusb20_backend *pbe; uint32_t matches = 0; -- GitLab