Print this page
8115 parallel zfs mount

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libfakekernel/common/kmem.c
          +++ new/usr/src/lib/libfakekernel/common/kmem.c
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       14 + * Copyright 2017 RackTop Systems.
  14   15   */
  15   16  
  16   17  #include <sys/kmem.h>
  17   18  
  18   19  #include <sys/debug.h>
  19   20  #include <sys/ksynch.h>
  20   21  #include <sys/systm.h>
       22 +#include <sys/cmn_err.h>
  21   23  
  22   24  #include <umem.h>
  23   25  
  24   26  void    abort(void) __NORETURN;
  25   27  
  26   28  static int
  27   29  kmem_failed_cb(void)
  28   30  {
  29   31          abort();
  30   32          return (UMEM_CALLBACK_RETRY);
↓ open down ↓ 27 lines elided ↑ open up ↑
  58   60  {
  59   61          return (umem_alloc(size, kmem2umem_flags(kmflags)));
  60   62  }
  61   63  
  62   64  void *
  63   65  kmem_zalloc(size_t size, int kmflags)
  64   66  {
  65   67          return (umem_zalloc(size, kmem2umem_flags(kmflags)));
  66   68  }
  67   69  
       70 +/*
       71 + * Do not change the length of the returned string; it must be freed
       72 + * with strfree().
       73 + */
       74 +char *
       75 +kmem_asprintf(const char *fmt, ...)
       76 +{
       77 +        int size;
       78 +        va_list adx;
       79 +        char *buf;
  68   80  
       81 +        va_start(adx, fmt);
       82 +        size = vsnprintf(NULL, 0, fmt, adx) + 1;
       83 +        va_end(adx);
       84 +
       85 +        buf = kmem_alloc(size, KM_SLEEP);
       86 +
       87 +        va_start(adx, fmt);
       88 +        size = vsnprintf(buf, size, fmt, adx);
       89 +        va_end(adx);
       90 +
       91 +        return (buf);
       92 +}
       93 +
  69   94  void
  70   95  kmem_free(void *buf, size_t size)
  71   96  {
  72   97          umem_free(buf, size);
  73   98  }
  74   99  
  75  100  /* void *kmem_alloc_tryhard(size_t size, size_t *alloc_size, int kmflags); */
  76  101  
  77  102  kmem_cache_t *
  78  103  kmem_cache_create(
↓ open down ↓ 73 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX