Print this page
8115 parallel zfs mount

@@ -9,17 +9,19 @@
  * http://www.illumos.org/license/CDDL.
  */
 
 /*
  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2017 RackTop Systems.
  */
 
 #include <sys/kmem.h>
 
 #include <sys/debug.h>
 #include <sys/ksynch.h>
 #include <sys/systm.h>
+#include <sys/cmn_err.h>
 
 #include <umem.h>
 
 void    abort(void) __NORETURN;
 

@@ -63,11 +65,34 @@
 kmem_zalloc(size_t size, int kmflags)
 {
         return (umem_zalloc(size, kmem2umem_flags(kmflags)));
 }
 
+/*
+ * Do not change the length of the returned string; it must be freed
+ * with strfree().
+ */
+char *
+kmem_asprintf(const char *fmt, ...)
+{
+        int size;
+        va_list adx;
+        char *buf;
 
+        va_start(adx, fmt);
+        size = vsnprintf(NULL, 0, fmt, adx) + 1;
+        va_end(adx);
+
+        buf = kmem_alloc(size, KM_SLEEP);
+
+        va_start(adx, fmt);
+        size = vsnprintf(buf, size, fmt, adx);
+        va_end(adx);
+
+        return (buf);
+}
+
 void
 kmem_free(void *buf, size_t size)
 {
         umem_free(buf, size);
 }