From a7947ad9ee47e434a2e0929ee0dca42dfc01bbe1 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 11 Jun 2014 23:52:43 +0000 Subject: [PATCH] Merged revisions 5584 via svnmerge from svn+ssh://vlnb@svn.code.sf.net/p/scst/svn/trunk ........ r5584 | vlnb | 2014-06-11 12:33:18 -0700 (Wed, 11 Jun 2014) | 8 lines scst: RHEL 5 build fix Avoid that building the scst kernel module fails on RHEL 5 due to a missing kvasprintf() implementation. Signed-off-by: Bart Van Assche ........ git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x@5591 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 8 ++++++++ scst/src/scst_lib.c | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/scst/include/scst.h b/scst/include/scst.h index 66cb6d685..57a48d998 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -79,6 +79,14 @@ typedef _Bool bool; #define __aligned __attribute__((aligned)) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) +#define lockdep_assert_held(l) do { (void)(l); } while (0) +#endif + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32) #ifndef O_DSYNC #define O_DSYNC O_SYNC diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index ef3a7c111..369686ae1 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -76,6 +76,27 @@ static int strncasecmp(const char *s1, const char *s2, size_t n) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) +char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) +{ + unsigned int len; + char *p; + va_list aq; + + va_copy(aq, ap); + len = vsnprintf(NULL, 0, fmt, aq); + va_end(aq); + + p = kmalloc_track_caller(len + 1, gfp); + if (!p) + return NULL; + + vsnprintf(p, len + 1, fmt, ap); + + return p; +} +#endif + #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && defined(SCSI_EXEC_REQ_FIFO_DEFINED)) && !defined(HAVE_SG_COPY) static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)