From b628b36da386817dadfabe76536845643150b7f0 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 18 Dec 2013 05:55:31 +0000 Subject: [PATCH] scst: RHEL 5 build fixes Avoid that compilation fails on RHEL 5.9. In the RHEL 5.9 kernel headers neither __printf() nor sg_is_last() has been defined. Additionally, the variable 'fd' in vdisk_unmap_range() is only defined when building against kernel version > 2.6.27. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5146 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 8 ++++++++ scst/src/dev_handlers/scst_vdisk.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 655e155e8..1d7ca69b1 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -92,6 +92,12 @@ typedef _Bool bool; #include "scst_sgv.h" #endif +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20) +#ifndef __printf +#define __printf(a, b) __attribute__((format(printf,a,b))) +#endif +#endif + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20) && !defined(BACKPORT_LINUX_CPUMASK_H) #define nr_cpu_ids NR_CPUS #endif @@ -3787,6 +3793,8 @@ static inline struct scatterlist *sg_chain_ptr(struct scatterlist *sg) return NULL; } +#define sg_is_last(sg) false + #ifndef sg_page static inline struct page *sg_page(struct scatterlist *sg) { diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 6420801d8..5bb919a15 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2134,8 +2134,8 @@ static int vdisk_unmap_range(struct scst_cmd *cmd, (unsigned long long)start_lba, (unsigned long long)blocks); if (virt_dev->blockio) { - struct inode *inode = fd->f_dentry->d_inode; #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27) + struct inode *inode = fd->f_dentry->d_inode; gfp_t gfp = scst_cmd_get_gfp_flags(cmd); #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31) err = blkdev_issue_discard(inode->i_bdev, start_lba, blocks, gfp);