diff options
author | Brian Behlendorf <[email protected]> | 2010-06-11 14:48:18 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2010-06-11 15:57:25 -0700 |
commit | b868e22f05fd85be16afee800207f72b8e310d32 (patch) | |
tree | da050e86b8d79b4de1eac65640aa1506b06d51ea /module | |
parent | bb1bb2c4c49659b47d65beb8ac24dc2c86989553 (diff) |
Add kmem_asprintf(), strfree(), strdup(), and minor cleanup.
This patch adds three missing Solaris functions: kmem_asprintf(), strfree(),
and strdup(). They are all implemented as a thin layer which just calls
their Linux counterparts. As part of this an autoconf check for kvasprintf
was added because it does not appear in older kernels. If the kernel does
not provide it then spl-generic implements it.
Additionally the dead DEBUG_KMEM_UNIMPLEMENTED code was removed to clean
things up and make the kmem.h a little more readable.
Diffstat (limited to 'module')
-rw-r--r-- | module/spl/spl-kmem.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index 5a421d40e..117959546 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -208,6 +208,52 @@ vmem_size(vmem_t *vmp, int typemask) } EXPORT_SYMBOL(vmem_size); +int +kmem_debugging(void) +{ + return 0; +} +EXPORT_SYMBOL(kmem_debugging); + +#ifndef HAVE_KVASPRINTF +/* Simplified asprintf. */ +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(len+1, gfp); + if (!p) + return NULL; + + vsnprintf(p, len+1, fmt, ap); + + return p; +} +EXPORT_SYMBOL(kvasprintf); +#endif /* HAVE_KVASPRINTF */ + +char * +kmem_asprintf(const char *fmt, ...) +{ + va_list args; + char *ptr; + + va_start(args, fmt); + do { + ptr = kvasprintf(GFP_KERNEL, fmt, args); + } while (ptr == NULL); + va_end(args); + + return ptr; +} +EXPORT_SYMBOL(kmem_asprintf); + /* * Memory allocation interfaces and debugging for basic kmem_* * and vmem_* style memory allocation. When DEBUG_KMEM is enabled |