Print this page
    
NEX-14666 Need to provide SMB 2.1 Client
NEX-17187 panic in smbfs_acl_store
NEX-17231 smbfs create xattr files finds wrong file
NEX-17224 smbfs lookup EINVAL should be ENOENT
NEX-17260 SMB1 client fails to list directory after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
and: (cleanup)
NEX-16818 Add fksmbcl development tool
NEX-17264 SMB client test tp_smbutil_013 fails after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (fix ref leaks)
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/netsmb/mchain.h
          +++ new/usr/src/uts/common/netsmb/mchain.h
   1    1  /*
   2    2   * Copyright (c) 2000, 2001 Boris Popov
   3    3   * All rights reserved.
   4    4   *
   5    5   * Redistribution and use in source and binary forms, with or without
   6    6   * modification, are permitted provided that the following conditions
   7    7   * are met:
   8    8   * 1. Redistributions of source code must retain the above copyright
   9    9   *    notice, this list of conditions and the following disclaimer.
  10   10   * 2. Redistributions in binary form must reproduce the above copyright
  11   11   *    notice, this list of conditions and the following disclaimer in the
  12   12   *    documentation and/or other materials provided with the distribution.
  13   13   * 3. All advertising materials mentioning features or use of this software
  14   14   *    must display the following acknowledgement:
  15   15   *    This product includes software developed by Boris Popov.
  16   16   * 4. Neither the name of the author nor the names of any co-contributors
  17   17   *    may be used to endorse or promote products derived from this software
  18   18   *    without specific prior written permission.
  19   19   *
  20   20   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21   21   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22   22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23   23   * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  24   24   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25   25   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26   26   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27   27   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  
    | 
      ↓ open down ↓ | 
    27 lines elided | 
    
      ↑ open up ↑ | 
  
  28   28   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29   29   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30   30   * SUCH DAMAGE.
  31   31   *
  32   32   * $FreeBSD: src/sys/sys/mchain.h,v 1.1 2001/02/24 15:44:30 bp Exp $
  33   33   */
  34   34  
  35   35  /*
  36   36   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  37   37   * Use is subject to license terms.
       38 + *
       39 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  38   40   */
  39   41  
  40   42  #ifndef _MCHAIN_H_
  41   43  #define _MCHAIN_H_
  42   44  
  43   45  #include <sys/types.h>
  44   46  #include <sys/isa_defs.h>
  45   47  #include <sys/byteorder.h>
  46   48  
  47   49  #ifdef _LITTLE_ENDIAN
  48   50  
  49   51  /* little-endian values on little-endian */
  50   52  #define htoles(x)       ((uint16_t)(x))
  51   53  #define letohs(x)       ((uint16_t)(x))
  52   54  #define htolel(x)       ((uint32_t)(x))
  53   55  #define letohl(x)       ((uint32_t)(x))
  54   56  #define htoleq(x)       ((uint64_t)(x))
  55   57  #define letohq(x)       ((uint64_t)(x))
  56   58  
  57   59  /*
  58   60   * big-endian values on little-endian (swap)
  59   61   *
  60   62   * Use the BSWAP macros because they're fastest, and they're
  61   63   * available in all environments where we use this header.
  62   64   */
  63   65  #define htobes(x)       BSWAP_16(x)
  64   66  #define betohs(x)       BSWAP_16(x)
  65   67  #define htobel(x)       BSWAP_32(x)
  66   68  #define betohl(x)       BSWAP_32(x)
  67   69  #define htobeq(x)       BSWAP_64(x)
  68   70  #define betohq(x)       BSWAP_64(x)
  69   71  
  70   72  #else   /* (BYTE_ORDER == LITTLE_ENDIAN) */
  71   73  
  72   74  /* little-endian values on big-endian (swap) */
  73   75  #define letohs(x)       BSWAP_16(x)
  74   76  #define htoles(x)       BSWAP_16(x)
  75   77  #define letohl(x)       BSWAP_32(x)
  76   78  #define htolel(x)       BSWAP_32(x)
  77   79  #define letohq(x)       BSWAP_64(x)
  78   80  #define htoleq(x)       BSWAP_64(x)
  79   81  
  80   82  /* big-endian values on big-endian */
  81   83  #define htobes(x)       ((uint16_t)(x))
  82   84  #define betohs(x)       ((uint16_t)(x))
  83   85  #define htobel(x)       ((uint32_t)(x))
  84   86  #define betohl(x)       ((uint32_t)(x))
  85   87  #define htobeq(x)       ((uint64_t)(x))
  
    | 
      ↓ open down ↓ | 
    38 lines elided | 
    
      ↑ open up ↑ | 
  
  86   88  #define betohq(x)       ((uint64_t)(x))
  87   89  #endif  /* (BYTE_ORDER == LITTLE_ENDIAN) */
  88   90  
  89   91  
  90   92  /*
  91   93   * Additions for Solaris to replace things that came from
  92   94   * <sys/mbuf.h> in the Darwin code.  These are mostly just
  93   95   * wrappers for streams functions.  See: subr_mchain.c
  94   96   */
  95   97  
  96      -#ifdef _KERNEL
       98 +#if defined(_KERNEL) || defined(_FAKE_KERNEL)
  97   99  
  98  100  /*
  99  101   * BSD-style mbuf "shim" for kernel code.  Note, this
 100  102   * does NOT implement BSD mbufs in the kernel.  Rather,
 101  103   * macros and wrapper functions are used so that code
 102  104   * fomerly using mbuf_t now use STREAMS mblk_t instead.
 103  105   */
 104  106  
 105  107  #include <sys/stream.h> /* mblk_t */
      108 +#include <sys/strsun.h> /* MBLKL */
 106  109  typedef mblk_t mbuf_t;
 107  110  
 108  111  /* BEGIN CSTYLED */
 109  112  /*
 110  113   * BSD-style mbufs, vs SysV-style mblks:
 111  114   * One big difference: the mbuf payload is:
 112  115   *   m_data ... (m_data + m_len)
 113  116   * In Unix STREAMS, the mblk payload is:
 114  117   *   b_rptr ... b_wptr
 115  118   * 
 116  119   * Here are some handy conversion notes:
 117  120   * 
 118  121   * struct mbuf                     struct mblk
 119  122   *   m->m_next                       m->b_cont
 120  123   *   m->m_nextpkt                    m->b_next
 121  124   *   m->m_data                       m->b_rptr
 122  125   *   m->m_len                        MBLKL(m)
 123  126   *   m->m_dat[]                      m->b_datap->db_base
 124  127   *   &m->m_dat[MLEN]                 m->b_datap->db_lim
 125  128   *   M_TRAILINGSPACE(m)              MBLKTAIL(m)
 126  129   *   m_freem(m)                      freemsg(m)
 127  130   * 
 128  131   * Note that mbufs chains also have a special "packet" header,
 129  132   * which has the length of the whole message.  In STREAMS one
 130  133   * typically just calls msgdsize(m) to get that.
 131  134   */
 132  135  /* END CSTYLED */
 133  136  
 134  137  #define mtod(m, t) ((t)((m)->b_rptr))
 135  138  
 136  139  /* length arg for m_copym to "copy all" */
 137  140  #define M_COPYALL               -1
 138  141  
 139  142  mblk_t *m_copym(mblk_t *, int, int, int);
 140  143  mblk_t *m_pullup(mblk_t *, int);
 141  144  mblk_t *m_split(mblk_t *, int, int);
 142  145  void m_cat(mblk_t *, mblk_t *);
 143  146  #define m_freem(x)      freemsg(x)
 144  147  mblk_t *m_getblk(int, int);
 145  148  int  m_fixhdr(mblk_t *m);
 146  149  
 147  150  #else   /* _KERNEL */
 148  151  
 149  152  /*
 150  153   * BSD-style mbuf work-alike, for user-level.
 151  154   * See libsmbfs mbuf.c
 152  155   */
 153  156  typedef struct mbuf {
 154  157          int             m_len;
 155  158          int             m_maxlen;
 156  159          char            *m_data;
 157  160          struct mbuf     *m_next;
 158  161  } mbuf_t;
 159  162  
 160  163  #define mtod(m, t)      ((t)(m)->m_data)
 161  164  
 162  165  int m_get(int, mbuf_t **);
 163  166  void m_freem(mbuf_t *);
 164  167  
 165  168  #endif  /* _KERNEL */
 166  169  
 167  170  /*
 168  171   * BSD-style mbchain/mdchain work-alike
 169  172   */
  
    | 
      ↓ open down ↓ | 
    54 lines elided | 
    
      ↑ open up ↑ | 
  
 170  173  
 171  174  /*
 172  175   * Type of copy for mb_{put|get}_mem()
 173  176   */
 174  177  #define MB_MSYSTEM      0               /* use bcopy() */
 175  178  #define MB_MUSER        1               /* use copyin()/copyout() */
 176  179  #define MB_MINLINE      2               /* use an inline copy loop */
 177  180  #define MB_MZERO        3               /* bzero(), mb_put_mem only */
 178  181  #define MB_MCUSTOM      4               /* use an user defined function */
 179  182  
 180      -#ifdef _KERNEL
      183 +#if defined(_KERNEL) || defined(_FAKE_KERNEL)
 181  184  
 182  185  struct mbchain {
 183  186          mblk_t *mb_top;
 184  187          mblk_t *mb_cur;
 185  188          uint_t mb_count;
 186  189  };
 187  190  typedef struct mbchain mbchain_t;
 188  191  
 189  192  struct mdchain {
 190  193          mblk_t *md_top;         /* head of mblk chain */
 191  194          mblk_t *md_cur;         /* current mblk */
 192  195          uchar_t *md_pos;        /* position in md_cur */
 193  196          /* NB: md_pos is same type as mblk_t b_rptr, b_wptr members. */
 194  197  };
 195  198  typedef struct mdchain mdchain_t;
 196  199  
 197  200  mblk_t *mb_detach(mbchain_t *mbp);
 198  201  int  mb_fixhdr(mbchain_t *mbp);
 199  202  int  mb_put_uio(mbchain_t *mbp, uio_t *uiop, size_t size);
 200  203  
 201  204  void md_append_record(mdchain_t *mdp, mblk_t *top);
 202  205  void md_next_record(mdchain_t *mdp);
 203  206  int  md_get_uio(mdchain_t *mdp, uio_t *uiop, size_t size);
 204  207  
 205  208  #else   /* _KERNEL */
 206  209  
 207  210  /*
 208  211   * user-level code uses the same struct for both (MB, MD)
 209  212   */
 210  213  typedef struct mbdata {
 211  214          mbuf_t  *mb_top;        /* head of mbuf chain */
 212  215          mbuf_t  *mb_cur;        /* current mbuf */
 213  216          char    *mb_pos;        /* position in mb_cur (get) */
 214  217          /* NB: mb_pos is same type as mbuf_t m_data member. */
 215  218          int     mb_count;       /* bytes marshalled (put) */
 216  219  } mbdata_t;
  
    | 
      ↓ open down ↓ | 
    26 lines elided | 
    
      ↑ open up ↑ | 
  
 217  220  typedef struct mbdata mbchain_t;
 218  221  typedef struct mbdata mdchain_t;
 219  222  
 220  223  #endif  /* _KERNEL */
 221  224  
 222  225  int  mb_init(mbchain_t *);
 223  226  void mb_initm(mbchain_t *, mbuf_t *);
 224  227  void mb_done(mbchain_t *);
 225  228  void *mb_reserve(mbchain_t *, int size);
 226  229  
      230 +int  mb_put_align8(mbchain_t *mbp);
 227  231  int  mb_put_padbyte(mbchain_t *mbp);
 228  232  int  mb_put_uint8(mbchain_t *, uint8_t);
 229  233  int  mb_put_uint16be(mbchain_t *, uint16_t);
 230  234  int  mb_put_uint16le(mbchain_t *, uint16_t);
 231  235  int  mb_put_uint32be(mbchain_t *, uint32_t);
 232  236  int  mb_put_uint32le(mbchain_t *, uint32_t);
 233  237  int  mb_put_uint64be(mbchain_t *, uint64_t);
 234  238  int  mb_put_uint64le(mbchain_t *, uint64_t);
 235  239  int  mb_put_mem(mbchain_t *, const void *, int, int);
 236  240  int  mb_put_mbuf(mbchain_t *, mbuf_t *);
      241 +int  mb_put_mbchain(mbchain_t *, mbchain_t *);
 237  242  
 238  243  int  md_init(mdchain_t *mdp);
 239  244  void md_initm(mdchain_t *mbp, mbuf_t *m);
 240  245  void md_done(mdchain_t *mdp);
 241  246  
 242  247  int  md_get_uint8(mdchain_t *, uint8_t *);
 243  248  int  md_get_uint16be(mdchain_t *, uint16_t *);
 244  249  int  md_get_uint16le(mdchain_t *, uint16_t *);
 245  250  int  md_get_uint32be(mdchain_t *, uint32_t *);
 246  251  int  md_get_uint32le(mdchain_t *, uint32_t *);
 247  252  int  md_get_uint64be(mdchain_t *, uint64_t *);
 248  253  int  md_get_uint64le(mdchain_t *, uint64_t *);
 249  254  int  md_get_mem(mdchain_t *, void *, int, int);
 250  255  int  md_get_mbuf(mdchain_t *, int, mbuf_t **);
      256 +int  md_seek(mdchain_t *, uint32_t);
      257 +uint32_t md_tell(mdchain_t *);
 251  258  
 252  259  #endif  /* !_MCHAIN_H_ */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX