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-16824 SMB client connection setup rework
NEX-17232 SMB client reconnect failures
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
and: (improve debug)
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.h
          +++ new/usr/src/uts/common/fs/smbclnt/netsmb/smb_conn.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
  
    | 
      ↓ open down ↓ | 
    25 lines elided | 
    
      ↑ open up ↑ | 
  
  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
  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   * $Id: smb_conn.h,v 1.32.42.1 2005/05/27 02:35:29 lindak Exp $
  33   33   */
  34   34  
  35   35  /*
  36      - * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  37   36   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  38   37   * Use is subject to license terms.
       38 + *
       39 + * Portions Copyright (C) 2001 - 2013 Apple Inc. All rights reserved.
       40 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  39   41   */
  40   42  
  41   43  #ifndef _SMB_CONN_H
  42   44  #define _SMB_CONN_H
  43   45  
  44   46  #include <sys/dditypes.h>
  45   47  #include <sys/t_lock.h>
  46   48  #include <sys/queue.h> /* for SLIST below */
  47   49  #include <sys/uio.h>
  48   50  #include <netsmb/smb_dev.h>
       51 +#include "smb_signing.h"
  49   52  
  50   53  /*
  51   54   * Credentials of user/process for processing in the connection procedures
  52   55   */
  53   56  typedef struct smb_cred {
  54   57          struct cred *scr_cred;
  55   58  } smb_cred_t;
  56   59  
  57   60  /*
  58   61   * Common object flags
  59   62   */
  60   63  #define SMBO_GONE               0x1000000
  61   64  
  62   65  /*
  63   66   * Bits in vc_flags (a.k.a. vc_co.co_flags)
  64      - * Many of these were duplicates of SMBVOPT_ flags
  65      - * and we now keep those too instead of merging
  66      - * them into vc_flags.
       67 + * Note: SMBO_GONE is also in vc_flags
  67   68   */
  68      -
  69      -#define SMBV_WIN95              0x0010  /* used to apply bugfixes for this OS */
  70      -#define SMBV_NT4                0x0020  /* used when NT4 issues invalid resp */
  71   69  #define SMBV_UNICODE            0x0040  /* conn configured to use Unicode */
       70 +#define SMBV_EXT_SEC            0x0080  /* conn to use extended security */
       71 +#define SMBV_SIGNING            0x0100  /* negotiated signing */
       72 +#define SMBV_SMB2               0x0200  /* VC using SMB 2 or 3 */
       73 +#define SMBV_HAS_FILEIDS        0x0400  /* Use File IDs for hash and inode numbers */
       74 +#define SMBV_NO_WRITE_THRU      0x0800  /* Can't use ... */
  72   75  
  73   76  /*
  74   77   * Note: the common "obj" level uses this GONE flag by
  75   78   * the name SMBO_GONE.  Keep this alias as a reminder.
  76   79   */
  77   80  #define SMBV_GONE               SMBO_GONE
  78   81  
  79   82  /*
  80   83   * bits in smb_share ss_flags (a.k.a. ss_co.co_flags)
  81   84   */
  82   85  #define SMBS_RECONNECTING       0x0002
  83   86  #define SMBS_CONNECTED          0x0004
  84   87  #define SMBS_TCON_WAIT          0x0008
  85   88  #define SMBS_FST_FAT            0x0010  /* share FS Type is FAT */
  86   89  /*
  87   90   * Note: the common "obj" level uses this GONE flag by
  88   91   * the name SMBO_GONE.  Keep this alias as a reminder.
  89   92   */
  90   93  #define SMBS_GONE               SMBO_GONE
  91   94  
       95 +/*
       96 + * bits in smb_fh fh_flags (a.k.a. ss_co.co_flags)
       97 + */
       98 +#define SMBFH_VALID             0x0002  /* FID is valid */
       99 +/*
      100 + * Note: the common "obj" level uses this GONE flag by
      101 + * the name SMBO_GONE.  Keep this alias as a reminder.
      102 + */
      103 +#define SMBFH_GONE              SMBO_GONE
      104 +
  92  105  struct smb_rq;
  93  106  /* This declares struct smb_rqhead */
  94  107  TAILQ_HEAD(smb_rqhead, smb_rq);
  95  108  
  96  109  #define SMB_NBTIMO      15
  97  110  #define SMB_DEFRQTIMO   30      /* 30 for oplock revoke/writeback */
  98  111  #define SMBWRTTIMO      60
  99  112  #define SMBSSNSETUPTIMO 60
 100  113  #define SMBNOREPLYWAIT (0)
 101  114  
 102  115  #define SMB_DIALECT(vcp)        ((vcp)->vc_sopt.sv_proto)
 103  116  
 104  117  /*
 105  118   * Connection object
 106  119   */
 107  120  
 108  121  #define SMB_CO_LOCK(cp)         mutex_enter(&(cp)->co_lock)
 109  122  #define SMB_CO_UNLOCK(cp)       mutex_exit(&(cp)->co_lock)
 110  123  
 111  124  /*
 112  125   * Common part of smb_vc, smb_share
 113  126   * Locking: co_lock protects most
 114  127   * fields in this struct, except
 115  128   * as noted below:
 116  129   */
 117  130  struct smb_connobj {
 118  131          kmutex_t                co_lock;
 119  132          int                     co_level;       /* SMBL_ */
 120  133          int                     co_flags;
 121  134          int                     co_usecount;
 122  135  
 123  136          /* Note: must lock co_parent before child. */
 124  137          struct smb_connobj      *co_parent;
 125  138  
 126  139          /* this.co_lock protects the co_children list */
 127  140          SLIST_HEAD(, smb_connobj) co_children;
 128  141  
 129  142          /*
 130  143           * Linkage in parent's list of children.
 131  144           * Must hold parent.co_lock to traverse.
 132  145           */
 133  146          SLIST_ENTRY(smb_connobj) co_next;
  
    | 
      ↓ open down ↓ | 
    32 lines elided | 
    
      ↑ open up ↑ | 
  
 134  147  
 135  148          /* These two are set only at creation. */
 136  149          void (*co_gone)(struct smb_connobj *);
 137  150          void (*co_free)(struct smb_connobj *);
 138  151  };
 139  152  typedef struct smb_connobj smb_connobj_t;
 140  153  
 141  154  /*
 142  155   * "Level" in the connection object hierarchy
 143  156   */
 144      -#define SMBL_SM         0
 145      -#define SMBL_VC         1
 146      -#define SMBL_SHARE      2
      157 +enum smbco_level {
      158 +        SMBL_SM = 0,
      159 +        SMBL_VC = 1,
      160 +        SMBL_SHARE = 2,
      161 +        SMBL_FH = 3
      162 +};
 147  163  
 148  164  /*
      165 + * SMB1 Negotiated protocol parameters
      166 + */
      167 +struct smb_sopt {
      168 +        int16_t         sv_proto;       /* protocol dialect */
      169 +        uchar_t         sv_sm;          /* security mode */
      170 +        int16_t         sv_tz;          /* offset in min relative to UTC */
      171 +        uint16_t        sv_maxmux;      /* max number of outstanding rq's */
      172 +        uint16_t        sv_maxvcs;      /* max number of VCs */
      173 +        uint16_t        sv_rawmode;
      174 +        uint32_t        sv_maxtx;       /* maximum transmit buf size */
      175 +        uint32_t        sv_maxraw;      /* maximum raw-buffer size */
      176 +        uint32_t        sv_skey;        /* session key */
      177 +        uint32_t        sv_caps;        /* capabilites SMB_CAP_ */
      178 +
      179 +        /* SMB2+ fields */
      180 +        uint32_t        sv2_sessflags;  /* final session setup reply flags */
      181 +        uint16_t        sv2_dialect;    /* dialect (non zero for SMB 2/3 */
      182 +        uint32_t        sv2_capabilities;       /* capabilities */
      183 +        uint32_t        sv2_maxtransact;        /* max transact size */
      184 +        uint32_t        sv2_maxread;    /* max read size */
      185 +        uint32_t        sv2_maxwrite;   /* max write size */
      186 +        uint8_t         sv2_guid[16];   /* GUID */
      187 +        uint16_t        sv2_security_mode;      /* security mode */
      188 +};
      189 +typedef struct smb_sopt smb_sopt_t;
      190 +
      191 +/*
      192 + * SMB1 I/O Deamon state
      193 + */
      194 +struct smb_iods {
      195 +        uint8_t         is_hflags;      /* SMB header flags */
      196 +        uint16_t        is_hflags2;     /* SMB header flags2 */
      197 +        uint16_t        is_smbuid;      /* SMB header UID */
      198 +        uint16_t        is_next_mid;    /* SMB header MID */
      199 +        uint32_t        is_txmax;       /* max tx/rx packet size */
      200 +        uint32_t        is_rwmax;       /* max read/write data size */
      201 +        uint32_t        is_rxmax;       /* max readx data size */
      202 +        uint32_t        is_wxmax;       /* max writex data size */
      203 +        /* Signing state */
      204 +        uint32_t        is_next_seq;    /* my next sequence number */
      205 +
      206 +};
      207 +typedef struct smb_iods smb_iods_t;
      208 +
      209 +/*
 149  210   * Virtual Circuit to a server (really connection + session).
 150  211   * Yes, calling this a "Virtual Circuit" is confusining,
 151  212   * because it has nothing to do with the SMB notion of a
 152  213   * "Virtual Circuit".
 153  214   */
 154  215  typedef struct smb_vc {
 155  216          struct smb_connobj      vc_co;  /* keep first! See CPTOVC */
 156  217          enum smbiod_state       vc_state;
 157  218          kcondvar_t              vc_statechg;
 158  219  
 159  220          zoneid_t                vc_zoneid;
 160  221          uid_t                   vc_owner;       /* Unix owner */
 161  222          int                     vc_genid;       /* "generation" ID */
 162  223  
 163      -        int                     vc_mackeylen;   /* length of MAC key */
 164      -        uint8_t                 *vc_mackey;     /* MAC key */
      224 +        int                     vc_mackeylen;   /* MAC key length */
      225 +        int                     vc_ssnkeylen;   /* session key length */
      226 +        uint8_t                 *vc_mackey;     /* MAC key buffer */
      227 +        uint8_t                 *vc_ssnkey;     /* session key buffer */
      228 +        smb_sign_mech_t         vc_signmech;
 165  229  
 166      -        ksema_t                 vc_sendlock;
 167  230          struct smb_tran_desc    *vc_tdesc;      /* transport ops. vector */
 168  231          void                    *vc_tdata;      /* transport control block */
 169  232  
      233 +        /* SMB2+ fields */
      234 +        uint64_t        vc2_oldest_message_id;
      235 +        uint64_t        vc2_next_message_id;
      236 +        uint64_t        vc2_limit_message_id;
      237 +        uint64_t        vc2_session_id;         /* session id */
      238 +        uint64_t        vc2_prev_session_id;    /* for reconnect */
      239 +        uint32_t        vc2_lease_key;          /* lease key gen */
      240 +
 170  241          kcondvar_t              iod_idle;       /* IOD thread idle CV */
 171  242          krwlock_t               iod_rqlock;     /* iod_rqlist */
 172      -        struct smb_rqhead       iod_rqlist;     /* list of outstanding reqs */
      243 +        struct smb_rqhead       iod_rqlist;     /* list of active reqs */
 173  244          struct _kthread         *iod_thr;       /* the IOD (reader) thread */
 174  245          int                     iod_flags;      /* see SMBIOD_* below */
 175      -        int                     iod_newrq;      /* send needed (iod_rqlock) */
 176      -        int                     iod_muxfull;    /* maxmux limit reached */
      246 +        uint_t                  iod_muxcnt;     /* num. active requests */
      247 +        uint_t                  iod_muxwant;    /* waiting to be active */
      248 +        kcondvar_t              iod_muxwait;
      249 +        boolean_t               iod_noresp;     /* Logged "not responding" */
 177  250  
      251 +        smb_iods_t              vc_iods;
      252 +        smb_sopt_t              vc_sopt;
      253 +
 178  254          /* This is copied in/out when IOD enters/returns */
 179  255          smbioc_ssn_work_t       vc_work;
 180  256  
 181  257          /* session identity, etc. */
 182  258          smbioc_ossn_t           vc_ssn;
 183  259  } smb_vc_t;
 184  260  
 185  261  #define vc_lock         vc_co.co_lock
 186  262  #define vc_flags        vc_co.co_flags
 187  263  
 188  264  /* defines for members in vc_ssn */
 189  265  #define vc_owner        vc_ssn.ssn_owner
      266 +#define vc_vopt         vc_ssn.ssn_vopt
      267 +#define vc_minver       vc_ssn.ssn_minver
      268 +#define vc_maxver       vc_ssn.ssn_maxver
 190  269  #define vc_srvname      vc_ssn.ssn_srvname
 191  270  #define vc_srvaddr      vc_ssn.ssn_id.id_srvaddr
 192  271  #define vc_domain       vc_ssn.ssn_id.id_domain
 193  272  #define vc_username     vc_ssn.ssn_id.id_user
 194      -#define vc_vopt         vc_ssn.ssn_vopt
 195  273  
 196  274  /* defines for members in vc_work */
 197      -#define vc_sopt         vc_work.wk_sopt
 198      -#define vc_maxmux       vc_work.wk_sopt.sv_maxmux
 199      -#define vc_tran_fd      vc_work.wk_iods.is_tran_fd
 200      -#define vc_hflags       vc_work.wk_iods.is_hflags
 201      -#define vc_hflags2      vc_work.wk_iods.is_hflags2
 202      -#define vc_smbuid       vc_work.wk_iods.is_smbuid
 203      -#define vc_next_mid     vc_work.wk_iods.is_next_mid
 204      -#define vc_txmax        vc_work.wk_iods.is_txmax
 205      -#define vc_rwmax        vc_work.wk_iods.is_rwmax
 206      -#define vc_rxmax        vc_work.wk_iods.is_rxmax
 207      -#define vc_wxmax        vc_work.wk_iods.is_wxmax
 208      -#define vc_ssn_key      vc_work.wk_iods.is_ssn_key
 209      -#define vc_next_seq     vc_work.wk_iods.is_next_seq
 210      -#define vc_u_mackey     vc_work.wk_iods.is_u_mackey
 211      -#define vc_u_maclen     vc_work.wk_iods.is_u_maclen
      275 +#define vc_cl_guid      vc_work.wk_cl_guid
 212  276  
      277 +/* defines for members in vc_sopt ? */
      278 +#define vc_maxmux       vc_sopt.sv_maxmux
      279 +
      280 +/* defines for members in vc_iods */
      281 +#define vc_hflags       vc_iods.is_hflags
      282 +#define vc_hflags2      vc_iods.is_hflags2
      283 +#define vc_smbuid       vc_iods.is_smbuid
      284 +#define vc_next_mid     vc_iods.is_next_mid
      285 +#define vc_txmax        vc_iods.is_txmax
      286 +#define vc_rwmax        vc_iods.is_rwmax
      287 +#define vc_rxmax        vc_iods.is_rxmax
      288 +#define vc_wxmax        vc_iods.is_wxmax
      289 +#define vc_next_seq     vc_iods.is_next_seq
      290 +
 213  291  #define SMB_VC_LOCK(vcp)        mutex_enter(&(vcp)->vc_lock)
 214  292  #define SMB_VC_UNLOCK(vcp)      mutex_exit(&(vcp)->vc_lock)
 215  293  
 216      -#define SMB_UNICODE_STRINGS(vcp)        ((vcp)->vc_hflags2 & SMB_FLAGS2_UNICODE)
      294 +#define CPTOVC(cp)      ((struct smb_vc *)((void *)(cp)))
      295 +#define VCTOCP(vcp)     (&(vcp)->vc_co)
 217  296  
      297 +#define SMB_UNICODE_STRINGS(vcp) \
      298 +        (((vcp)->vc_flags & SMBV_SMB2) != 0 ||  \
      299 +        ((vcp)->vc_hflags2 & SMB_FLAGS2_UNICODE) != 0)
      300 +
 218  301  /* Bits in iod_flags */
 219  302  #define SMBIOD_RUNNING          0x0001
 220  303  #define SMBIOD_SHUTDOWN         0x0002
 221  304  
 222  305  /*
 223  306   * smb_share structure describes connection to the given SMB share (tree).
 224  307   * Connection to share is always built on top of the VC.
 225  308   */
 226  309  
 227  310  typedef struct smb_share {
 228  311          struct smb_connobj ss_co;       /* keep first! See CPTOSS */
 229  312          kcondvar_t      ss_conn_done;   /* wait for reconnect */
 230  313          int             ss_conn_waiters;
 231  314          int             ss_vcgenid;     /* check VC generation ID */
 232  315          uint16_t        ss_tid;         /* TID */
 233  316          uint16_t        ss_options;     /* option support bits */
      317 +        uint32_t        ss2_tree_id;
      318 +        uint32_t        ss2_share_flags;
      319 +        uint32_t        ss2_share_caps;
 234  320          smbioc_oshare_t ss_ioc;
 235  321  } smb_share_t;
 236  322  
 237  323  #define ss_lock         ss_co.co_lock
 238  324  #define ss_flags        ss_co.co_flags
 239  325  
 240  326  #define ss_use          ss_ioc.sh_use
 241  327  #define ss_type         ss_ioc.sh_type
 242  328  #define ss_name         ss_ioc.sh_name
 243  329  #define ss_pass         ss_ioc.sh_pass
 244  330  
 245  331  #define SMB_SS_LOCK(ssp)        mutex_enter(&(ssp)->ss_lock)
 246  332  #define SMB_SS_UNLOCK(ssp)      mutex_exit(&(ssp)->ss_lock)
 247  333  
 248      -#define CPTOVC(cp)      ((struct smb_vc *)((void *)(cp)))
 249      -#define VCTOCP(vcp)     (&(vcp)->vc_co)
 250      -
 251  334  #define CPTOSS(cp)      ((struct smb_share *)((void *)(cp)))
 252      -#define SSTOVC(ssp)     CPTOVC(((ssp)->ss_co.co_parent))
 253  335  #define SSTOCP(ssp)     (&(ssp)->ss_co)
      336 +#define SSTOVC(ssp)     CPTOVC(((ssp)->ss_co.co_parent))
 254  337  
      338 +typedef struct smb2fid {
      339 +        uint64_t fid_persistent;
      340 +        uint64_t fid_volatile;
      341 +} smb2fid_t;
      342 +
 255  343  /*
      344 + * smb_fh struct describes an open file handle under some share.
      345 + */
      346 +typedef struct smb_fh {
      347 +        struct smb_connobj fh_co;       /* keep first! See CPTOSS */
      348 +        int     fh_vcgenid;             /* check VC generation ID */
      349 +        uint32_t fh_rights;             /* granted access */
      350 +        smb2fid_t fh_fid2;
      351 +        uint16_t fh_fid1;
      352 +} smb_fh_t;
      353 +
      354 +#define fh_lock         fh_co.co_lock
      355 +#define fh_flags        fh_co.co_flags
      356 +
      357 +#define SMB_FH_LOCK(fhp)        mutex_enter(&(fhp)->fh_lock)
      358 +#define SMB_FH_UNLOCK(fhp)      mutex_exit(&(fhp)->fh_lock)
      359 +
      360 +#define CPTOFH(cp)      ((struct smb_fh *)((void *)(cp)))
      361 +#define FHTOCP(fhp)     (&(fhp)->fh_co)
      362 +#define FHTOSS(fhp)     CPTOSS(((fhp)->fh_co.co_parent))
      363 +
      364 +/*
 256  365   * Call-back operations vector, so the netsmb module
 257  366   * can notify smbfs about events affecting mounts.
 258  367   * Installed in netsmb after smbfs loads.
      368 + * Note: smbfs only uses the fscb_discon hook.
 259  369   */
 260  370  typedef struct smb_fscb {
 261  371          /* Called when the VC has disconnected. */
 262  372          void (*fscb_disconn)(smb_share_t *);
 263  373          /* Called when the VC has reconnected. */
 264  374          void (*fscb_connect)(smb_share_t *);
 265      -        /* Called when the server becomes unresponsive. */
 266      -        void (*fscb_down)(smb_share_t *);
 267      -        /* Called when the server is responding again. */
 268      -        void (*fscb_up)(smb_share_t *);
 269  375  } smb_fscb_t;
 270  376  /* Install the above vector, or pass NULL to clear it. */
 271  377  void smb_fscb_set(smb_fscb_t *);
 272  378  
 273  379  /*
 274  380   * The driver per open instance object.
 275  381   * Mostly used in: smb_dev.c, smb_usr.c
 276  382   */
 277  383  typedef struct smb_dev {
 278  384          kmutex_t        sd_lock;
 279  385          struct smb_vc   *sd_vc;         /* Reference to VC */
 280  386          struct smb_share *sd_share;     /* Reference to share if any */
      387 +        struct smb_fh   *sd_fh;         /* Reference to FH, if any */
 281  388          int             sd_level;       /* SMBL_VC, ... */
 282  389          int             sd_vcgenid;     /* Generation of share or VC */
 283  390          int             sd_poll;        /* Future use */
 284  391          int             sd_flags;       /* State of connection */
 285      -#define NSMBFL_OPEN             0x0001
 286      -#define NSMBFL_IOD              0x0002
 287      -#define NSMBFL_IOCTL            0x0004
 288      -        int             sd_smbfid;      /* library read/write */
      392 +#define NSMBFL_OPEN             0x0001  /* Device minor is open */
      393 +#define NSMBFL_IOD              0x0004  /* Open by IOD */
      394 +#define NSMBFL_IOCTL            0x0010  /* Serialize ioctl calls */
 289  395          zoneid_t        zoneid;         /* Zone id */
 290  396  } smb_dev_t;
 291  397  
 292  398  extern const uint32_t nsmb_version;
 293  399  
 294  400  /*
 295  401   * smb_dev.c
 296  402   */
 297  403  int  smb_dev2share(int fd, struct smb_share **sspp);
 298  404  
 299  405  
 300  406  /*
 301  407   * smb_usr.c
 302  408   */
      409 +int smb_usr_ioctl(smb_dev_t *, int, intptr_t, int, cred_t *);
      410 +
 303  411  int smb_usr_get_flags2(smb_dev_t *sdp, intptr_t arg, int flags);
 304  412  int smb_usr_get_ssnkey(smb_dev_t *sdp, intptr_t arg, int flags);
 305  413  int smb_usr_dup_dev(smb_dev_t *sdp, intptr_t arg, int flags);
 306  414  
 307  415  int smb_usr_simplerq(smb_dev_t *sdp, intptr_t arg, int flags, cred_t *cr);
 308  416  int smb_usr_t2request(smb_dev_t *sdp, intptr_t arg, int flags, cred_t *cr);
 309  417  
 310  418  int smb_usr_closefh(smb_dev_t *, cred_t *);
 311  419  int smb_usr_rw(smb_dev_t *sdp, int cmd, intptr_t arg, int flags, cred_t *cr);
 312  420  int smb_usr_ntcreate(smb_dev_t *, intptr_t, int, cred_t *);
 313  421  int smb_usr_printjob(smb_dev_t *, intptr_t, int, cred_t *);
 314  422  
 315  423  int smb_usr_get_ssn(smb_dev_t *, int, intptr_t, int, cred_t *);
 316  424  int smb_usr_drop_ssn(smb_dev_t *sdp, int cmd);
 317  425  
 318  426  int smb_usr_get_tree(smb_dev_t *, int, intptr_t, int, cred_t *);
 319  427  int smb_usr_drop_tree(smb_dev_t *sdp, int cmd);
 320  428  
 321  429  int smb_usr_iod_work(smb_dev_t *sdp, intptr_t arg, int flags, cred_t *cr);
 322      -int smb_usr_iod_ioctl(smb_dev_t *sdp, int cmd, intptr_t arg, int flags);
      430 +int smb_usr_iod_ioctl(smb_dev_t *sdp, int cmd, intptr_t arg, int flags,
      431 +    cred_t *cr);
 323  432  
      433 +int smb_pkey_ioctl(int, intptr_t, int, cred_t *);
 324  434  
      435 +
 325  436  /*
 326  437   * IOD functions
 327  438   */
 328  439  int  smb_iod_create(smb_vc_t *vcp);
 329  440  int  smb_iod_destroy(smb_vc_t *vcp);
 330      -int  smb_iod_connect(smb_vc_t *vcp);
 331  441  void smb_iod_disconnect(smb_vc_t *vcp);
 332      -int  smb_iod_addrq(struct smb_rq *rqp);
 333      -int  smb_iod_multirq(struct smb_rq *rqp);
      442 +int  smb2_iod_addrq(struct smb_rq *rqp);
      443 +int  smb1_iod_addrq(struct smb_rq *rqp);
      444 +int  smb1_iod_multirq(struct smb_rq *rqp);
 334  445  int  smb_iod_waitrq(struct smb_rq *rqp);
      446 +int  smb_iod_waitrq_int(struct smb_rq *rqp);
 335  447  void smb_iod_removerq(struct smb_rq *rqp);
      448 +int  smb_iod_sendrecv(struct smb_rq *, int);
 336  449  void smb_iod_shutdown_share(smb_share_t *ssp);
 337  450  
 338  451  void smb_iod_sendall(smb_vc_t *);
 339      -int smb_iod_recvall(smb_vc_t *);
      452 +int smb_iod_recvall(smb_vc_t *, boolean_t);
 340  453  
 341      -int smb_iod_vc_work(smb_vc_t *, cred_t *);
      454 +int nsmb_iod_connect(smb_vc_t *vcp, cred_t *cr);
      455 +int nsmb_iod_negotiate(smb_vc_t *vcp, cred_t *cr);
      456 +int nsmb_iod_ssnsetup(smb_vc_t *vcp, cred_t *cr);
      457 +int smb_iod_vc_work(smb_vc_t *, int, cred_t *);
 342  458  int smb_iod_vc_idle(smb_vc_t *);
 343  459  int smb_iod_vc_rcfail(smb_vc_t *);
 344  460  int smb_iod_reconnect(smb_vc_t *);
 345  461  
 346  462  /*
 347  463   * Session level functions
 348  464   */
 349  465  int  smb_sm_init(void);
 350  466  int  smb_sm_idle(void);
 351  467  void smb_sm_done(void);
 352  468  
 353  469  /*
 354  470   * VC level functions
 355  471   */
 356  472  void smb_vc_hold(smb_vc_t *vcp);
 357  473  void smb_vc_rele(smb_vc_t *vcp);
 358  474  void smb_vc_kill(smb_vc_t *vcp);
 359  475  
 360  476  int smb_vc_findcreate(smbioc_ossn_t *, smb_cred_t *, smb_vc_t **);
 361  477  int smb_vc_create(smbioc_ossn_t *ossn, smb_cred_t *scred, smb_vc_t **vcpp);
 362  478  
 363  479  const char *smb_vc_getpass(smb_vc_t *vcp);
 364  480  uint16_t smb_vc_nextmid(smb_vc_t *vcp);
 365  481  void *smb_vc_getipaddr(smb_vc_t *vcp, int *ipvers);
 366  482  
 367  483  typedef void (*walk_share_func_t)(smb_share_t *);
 368  484  void smb_vc_walkshares(struct smb_vc *, walk_share_func_t);
 369  485  
 370  486  /*
 371  487   * share level functions
 372  488   */
 373  489  
  
    | 
      ↓ open down ↓ | 
    22 lines elided | 
    
      ↑ open up ↑ | 
  
 374  490  int smb_share_findcreate(smbioc_tcon_t *, smb_vc_t *,
 375  491          smb_share_t **, smb_cred_t *);
 376  492  
 377  493  void smb_share_hold(smb_share_t *ssp);
 378  494  void smb_share_rele(smb_share_t *ssp);
 379  495  void smb_share_kill(smb_share_t *ssp);
 380  496  
 381  497  void smb_share_invalidate(smb_share_t *ssp);
 382  498  int  smb_share_tcon(smb_share_t *, smb_cred_t *);
 383  499  
      500 +/*
      501 + * File handle level functions
      502 + */
      503 +int smb_fh_create(smb_share_t *ssp, struct smb_fh **fhpp);
      504 +void smb_fh_opened(struct smb_fh *fhp);
      505 +void smb_fh_close(struct smb_fh *fhp);
      506 +void smb_fh_hold(struct smb_fh *fhp);
      507 +void smb_fh_rele(struct smb_fh *fhp);
      508 +
 384  509  #endif /* _SMB_CONN_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX