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)
5404 smbfs needs mmap support
Portions contributed by: Gordon Ross <gordon.w.ross@gmail.com>
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
2552 smbfs: add support for NFS-like remove
Portions contributed by: Gordon Ross <gordon.w.ross@gmail.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: C Fraire <cfraire@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_subr.h
          +++ new/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_subr.h
↓ 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: smbfs_subr.h,v 1.25 2005/03/17 01:23:40 lindak Exp $
  33   33   */
  34   34  
  35   35  /*
  36      - * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  37   36   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  38   37   * Use is subject to license terms.
       38 + *
       39 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  39   40   */
  40   41  
  41   42  #ifndef _FS_SMBFS_SMBFS_SUBR_H_
  42   43  #define _FS_SMBFS_SMBFS_SUBR_H_
  43   44  
  44   45  #include <sys/cmn_err.h>
  45   46  #include <netsmb/mchain.h>
  46   47  #include <netsmb/smb_subr.h>
  47   48  #include <smbfs/smbfs_node.h>
  48   49  
↓ open down ↓ 29 lines elided ↑ open up ↑
  78   79  struct smb_vc;
  79   80  struct statvfs;
  80   81  struct timespec;
  81   82  
  82   83  /*
  83   84   * Types of find_first, find_next context objects
  84   85   */
  85   86  typedef enum {
  86   87          ft_LM1 = 1,
  87   88          ft_LM2,
       89 +        ft_SMB2,
  88   90          ft_XA
  89   91  } smbfs_fctx_type_t;
  90   92  
  91   93  /*
  92   94   * Context to perform findfirst/findnext/findclose operations
  93   95   */
  94   96  #define SMBFS_RDD_FINDFIRST     0x01
  95   97  #define SMBFS_RDD_EOF           0x02
  96   98  #define SMBFS_RDD_FINDSINGLE    0x04
  97   99  /* note SMBFS_RDD_USESEARCH     0x08 replaced by smbfs_fctx_type */
↓ open down ↓ 15 lines elided ↑ open up ↑
 113  115           * Return values
 114  116           */
 115  117          struct smbfattr f_attr;         /* current attributes */
 116  118          u_longlong_t    f_inum;         /* current I number */
 117  119          char            *f_name;        /* current file name */
 118  120          int             f_nmlen;        /* name len */
 119  121          int             f_namesz;       /* memory allocated */
 120  122          /*
 121  123           * Internal variables
 122  124           */
      125 +        uint16_t        f_infolevel;
 123  126          uint16_t        f_limit;        /* maximum number of entries */
 124      -        uint16_t        f_attrmask;     /* SMB_FA_ */
      127 +        uint32_t        f_attrmask;     /* SMB_FA_ */
 125  128          int             f_wclen;
 126  129          const char      *f_wildcard;
 127  130          struct smbnode  *f_dnp;
 128  131          struct smb_cred *f_scred;
 129  132          struct smb_share        *f_ssp;
      133 +        struct smb_fh   *f_fhp;
 130  134          union {
 131  135                  struct smb_rq *uf_rq;
 132  136                  struct smb_t2rq *uf_t2;
 133      -        } f_urq;
      137 +        } f_urq;        // XXX remove and use...
      138 +        struct mdchain  f_mdchain;
 134  139          int             f_left;         /* entries left */
 135  140          int             f_ecnt;         /* entries left in current response */
 136  141          int             f_eofs;         /* entry offset in data block */
 137      -        uchar_t         f_skey[SMB_SKEYLEN]; /* server side search context */
      142 +        uchar_t         f_skey[SMB_SKEYLEN]; /* server side search context */
 138  143          uchar_t         f_fname[8 + 1 + 3 + 1]; /* for 8.3 filenames */
 139  144          uint16_t        f_Sid;          /* Search handle (like a FID) */
 140      -        uint16_t        f_infolevel;
 141  145          int             f_rnamelen;
 142  146          char            *f_rname;       /* resume name */
 143  147          int             f_rnameofs;
 144  148          int             f_otws;         /* # over-the-wire ops so far */
 145  149          char            *f_firstnm;     /* first filename we got back */
 146  150          int             f_firstnmlen;
 147      -        int             f_rkey;         /* resume key */
      151 +        uint32_t        f_rkey;         /* resume key */
 148  152  };
 149  153  typedef struct smbfs_fctx smbfs_fctx_t;
 150  154  
 151  155  #define f_rq    f_urq.uf_rq
 152  156  #define f_t2    f_urq.uf_t2
 153  157  
 154  158  /*
 155      - * smb level (smbfs_smb.c)
      159 + * Internal form of FileFsFullSizeInformation
      160 + * [MS-FSCC] 2.5.4 FileFsFullSizeInformation
      161 + * for the _statfs functions.
 156  162   */
      163 +struct smb_fs_size_info {
      164 +        uint64_t total_units;
      165 +        uint64_t caller_avail;
      166 +        uint64_t actual_avail;
      167 +        uint32_t sect_per_unit;
      168 +        uint32_t bytes_per_sect;
      169 +};
      170 +
      171 +/*
      172 + * smb common functions (smbfs_smbx.c)
      173 + */
 157  174  int  smbfs_smb_lock(struct smbnode *np, int op, caddr_t id,
 158  175          offset_t start, uint64_t len,   int largelock,
 159  176          struct smb_cred *scrp, uint32_t timeout);
      177 +int  smbfs_smb_getfattr(struct smbnode *np, smb_fh_t *fhp,
      178 +        struct smbfattr *fap, struct smb_cred *scrp);
      179 +int  smbfs_smb_getpattr(struct smbnode *np, struct smbfattr *fap,
      180 +        struct smb_cred *scrp);
 160  181  int  smbfs_smb_qfsattr(struct smb_share *ssp, struct smb_fs_attr_info *,
 161  182          struct smb_cred *scrp);
 162  183  int  smbfs_smb_statfs(struct smb_share *ssp, statvfs64_t *sbp,
 163  184          struct smb_cred *scrp);
 164      -int  smbfs_smb_setfsize(struct smbnode *np, uint16_t fid, uint64_t newsize,
      185 +int  smbfs_smb_setdisp(struct smb_share *ssp, smb_fh_t *fid, uint8_t newdisp,
 165  186          struct smb_cred *scrp);
 166      -
 167      -int  smbfs_smb_getfattr(struct smbnode *np, struct smbfattr *fap,
      187 +int  smbfs_smb_setfsize(struct smb_share *ssp, smb_fh_t *fid, uint64_t newsize,
 168  188          struct smb_cred *scrp);
 169      -
 170      -int  smbfs_smb_setfattr(struct smbnode *np, int fid,
      189 +int  smbfs_smb_setfattr(struct smb_share *ssp, smb_fh_t *fid,
 171  190          uint32_t attr, struct timespec *mtime, struct timespec *atime,
 172  191          struct smb_cred *scrp);
      192 +int  smbfs_smb_flush(struct smb_share *ssp, smb_fh_t *fid,
      193 +        struct smb_cred *scrp);
 173  194  
      195 +int smbfs_smb_ntcreatex(
      196 +        struct smbnode *np, const char *name, int nmlen, int xattr,
      197 +        uint32_t req_acc, uint32_t efa, uint32_t share_acc,
      198 +        uint32_t disp, uint32_t createopt, struct smb_cred *scrp,
      199 +        smb_fh_t *fhpp, uint32_t *cr_act_p, struct smbfattr *fap);
      200 +
      201 +int  smbfs_smb_tmpopen(struct smbnode *np, uint32_t rights,
      202 +        struct smb_cred *scrp, smb_fh_t **fidpp);
      203 +void smbfs_smb_tmpclose(struct smbnode *ssp, smb_fh_t *fid);
 174  204  int  smbfs_smb_open(struct smbnode *np, const char *name, int nmlen,
 175  205          int xattr, uint32_t rights, struct smb_cred *scrp,
 176      -        uint16_t *fidp, uint32_t *rightsp, struct smbfattr *fap);
 177      -int  smbfs_smb_tmpopen(struct smbnode *np, uint32_t rights,
 178      -        struct smb_cred *scrp, uint16_t *fidp);
 179      -int  smbfs_smb_close(struct smb_share *ssp, uint16_t fid,
 180      -        struct timespec *mtime, struct smb_cred *scrp);
 181      -int  smbfs_smb_tmpclose(struct smbnode *ssp, uint16_t fid,
 182      -        struct smb_cred *scrp);
      206 +        smb_fh_t **fidpp, struct smbfattr *fap);
      207 +void smbfs_smb_close(smb_fh_t *fid);
 183  208  int  smbfs_smb_create(struct smbnode *dnp, const char *name, int nmlen,
 184      -        int xattr, uint32_t disp, struct smb_cred *scrp, uint16_t *fidp);
 185      -int  smbfs_smb_delete(struct smbnode *np, struct smb_cred *scrp,
 186      -        const char *name, int len, int xattr);
 187      -int  smbfs_smb_rename(struct smbnode *src, struct smbnode *tdnp,
 188      -        const char *tname, int tnmlen, struct smb_cred *scrp);
 189      -int  smbfs_smb_t2rename(struct smbnode *np, struct smbnode *tdnp,
 190      -        const char *tname, int tnmlen, struct smb_cred *scrp, int overwrite);
 191      -int  smbfs_smb_move(struct smbnode *src, struct smbnode *tdnp,
 192      -        const char *tname, int tnmlen, uint16_t flags, struct smb_cred *scrp);
      209 +        int xattr, uint32_t disp, struct smb_cred *scrp, smb_fh_t **fidpp);
      210 +int  smbfs_smb_rename(struct smbnode *sdnp, struct smbnode *src,
      211 +        struct smbnode *tdnp, const char *tname, int tnmlen,
      212 +        smb_fh_t *fid, struct smb_cred *scrp);
 193  213  int  smbfs_smb_mkdir(struct smbnode *dnp, const char *name, int len,
 194  214          struct smb_cred *scrp);
 195      -int  smbfs_smb_rmdir(struct smbnode *np, struct smb_cred *scrp);
      215 +
 196  216  int  smbfs_smb_findopen(struct smbnode *dnp, const char *wildcard, int wclen,
 197  217          int attr, struct smb_cred *scrp, struct smbfs_fctx **ctxpp);
 198  218  int  smbfs_smb_findnext(struct smbfs_fctx *ctx, int limit,
 199  219          struct smb_cred *scrp);
 200  220  int  smbfs_smb_findclose(struct smbfs_fctx *ctx, struct smb_cred *scrp);
 201      -int  smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp,
 202      -        struct smbnode *dnp, const char *name, int nmlen, uint8_t sep);
      221 +
 203  222  int  smbfs_smb_lookup(struct smbnode *dnp, const char **namep, int *nmlenp,
 204  223          struct smbfattr *fap, struct smb_cred *scrp);
 205      -int  smbfs_smb_hideit(struct smbnode *np, const char *name, int len,
 206      -        struct smb_cred *scrp);
 207      -int  smbfs_smb_unhideit(struct smbnode *np, const char *name, int len,
 208      -                        struct smb_cred *scrp);
 209      -int smbfs_smb_flush(struct smbnode *np, struct smb_cred *scrp);
 210      -int smbfs_0extend(vnode_t *vp, uint16_t fid, len_t from, len_t to,
 211      -                struct smb_cred *scredp, int timo);
 212  224  
 213  225  /* get/set security descriptor */
 214      -int  smbfs_smb_getsec_m(struct smb_share *ssp, uint16_t fid,
 215      -        struct smb_cred *scrp, uint32_t selector,
 216      -        mblk_t **res, uint32_t *reslen);
 217      -int  smbfs_smb_setsec_m(struct smb_share *ssp, uint16_t fid,
 218      -        struct smb_cred *scrp, uint32_t selector, mblk_t **mp);
      226 +int  smbfs_smb_getsec(struct smb_share *ssp, smb_fh_t *fid,
      227 +        uint32_t selector, mblk_t **res, uint32_t *reslen,
      228 +        struct smb_cred *scrp);
      229 +int  smbfs_smb_setsec(struct smb_share *ssp, smb_fh_t *fid,
      230 +        uint32_t selector, mblk_t **mp, struct smb_cred *scrp);
 219  231  
 220  232  /*
      233 + * SMB1 functions
      234 + */
      235 +int smbfs_smb1_trans2_query(struct smbnode *np, uint16_t fid,
      236 +        struct smbfattr *fap, struct smb_cred *scrp);
      237 +int smbfs_smb1_qfsattr(struct smb_share *ssp, struct smb_fs_attr_info *,
      238 +        struct smb_cred *scrp);
      239 +int smbfs_smb1_statfs(struct smb_share *ssp,
      240 +        struct smb_fs_size_info *info, struct smb_cred *scrp);
      241 +int smbfs_smb1_seteof(struct smb_share *ssp, uint16_t fid, uint64_t newsize,
      242 +        struct smb_cred *scrp);
      243 +int smbfs_smb1_setdisp(struct smb_share *ssp, uint16_t fid, uint8_t newdisp,
      244 +        struct smb_cred *scrp);
      245 +int smbfs_smb1_setfattr(struct smb_share *ssp, uint16_t fid,
      246 +        struct mbchain *, struct smb_cred *);
      247 +int smbfs_smb1_flush(struct smb_share *ssp, uint16_t fid,
      248 +        struct smb_cred *scrp);
      249 +int smbfs_smb1_t2rename(struct smbnode *np, const char *tname, int tnmlen,
      250 +        uint16_t fid, struct smb_cred *scrp);
      251 +int smbfs_smb1_oldrename(struct smbnode *src, struct smbnode *tdnp,
      252 +        const char *tname, int tnmlen, struct smb_cred *scrp);
      253 +
      254 +int smbfs_smb_findopenLM2(struct smbfs_fctx *ctx, struct smbnode *dnp,
      255 +    const char *wildcard, int wclen, uint32_t attr);
      256 +int smbfs_smb_findnextLM2(struct smbfs_fctx *ctx, uint16_t limit);
      257 +int smbfs_smb_findcloseLM2(struct smbfs_fctx *ctx);
      258 +int smbfs_smb1_get_streaminfo(smbnode_t *np, struct mdchain *mdp,
      259 +        struct smb_cred *scrp);
      260 +
      261 +int smbfs_smb1_getsec(struct smb_share *ssp, uint16_t fid,
      262 +        uint32_t selector, mblk_t **res, uint32_t *reslen,
      263 +        struct smb_cred *scrp);
      264 +int smbfs_smb1_setsec(struct smb_share *ssp, uint16_t fid,
      265 +        uint32_t selector, mblk_t **mp,
      266 +        struct smb_cred *scrp);
      267 +
      268 +/*
      269 + * SMB2 functions
      270 + */
      271 +
      272 +int smbfs_smb2_getpattr(struct smbnode *np, struct smbfattr *fap,
      273 +        struct smb_cred *scrp);
      274 +int smbfs_smb2_qfileinfo(struct smb_share *ssp, smb2fid_t *fid,
      275 +        struct smbfattr *fap, struct smb_cred *scrp);
      276 +int smbfs_smb2_qfsattr(struct smb_share *ssp, struct smb_fs_attr_info *,
      277 +        struct smb_cred *scrp);
      278 +int smbfs_smb2_statfs(struct smb_share *ssp,
      279 +        struct smb_fs_size_info *info, struct smb_cred *scrp);
      280 +int smbfs_smb2_seteof(struct smb_share *ssp, smb2fid_t *fid, uint64_t newsize,
      281 +        struct smb_cred *scrp);
      282 +int smbfs_smb2_setdisp(struct smb_share *ssp, smb2fid_t *fid, uint8_t newdisp,
      283 +        struct smb_cred *scrp);
      284 +int smbfs_smb2_flush(struct smb_share *ssp, smb2fid_t *fid,
      285 +        struct smb_cred *scrp);
      286 +int smbfs_smb2_setfattr(struct smb_share *ssp, smb2fid_t *fid,
      287 +        struct mbchain *, struct smb_cred *);
      288 +int smbfs_smb2_rename(struct smbnode *np, struct smbnode *tdnp,
      289 +        const char *tname, int tnlen, int overwrite,
      290 +        smb2fid_t *fid, struct smb_cred *scrp);
      291 +
      292 +int smbfs_smb2_findopen(struct smbfs_fctx *ctx, struct smbnode *dnp,
      293 +    const char *wildcard, int wclen, uint32_t attr);
      294 +int smbfs_smb2_findnext(struct smbfs_fctx *ctx, uint16_t limit);
      295 +int smbfs_smb2_findclose(struct smbfs_fctx *ctx);
      296 +int smbfs_smb2_get_streaminfo(smbnode_t *np, struct mdchain *mdp,
      297 +        struct smb_cred *scrp);
      298 +
      299 +int smbfs_smb2_getsec(struct smb_share *ssp, smb2fid_t *fid,
      300 +        uint32_t selector, mblk_t **res, uint32_t *reslen,
      301 +        struct smb_cred *scrp);
      302 +int smbfs_smb2_setsec(struct smb_share *ssp, smb2fid_t *fid,
      303 +        uint32_t selector, mblk_t **mp,
      304 +        struct smb_cred *scrp);
      305 +
      306 +
      307 +/* smbfs_subr.c */
      308 +
      309 +int  smbfs_fullpath(struct mbchain *mbp, struct smb_vc *vcp,
      310 +        struct smbnode *dnp, const char *name, int nmlen, uint8_t sep);
      311 +int smbfs_decode_dirent(struct smbfs_fctx *ctx);
      312 +int smbfs_decode_file_all_info(struct smb_share *ssp,
      313 +        struct mdchain *mdp, struct smbfattr *fap);
      314 +int smbfs_decode_fs_attr_info(struct smb_share *ssp,
      315 +        struct mdchain *mdp, struct smb_fs_attr_info *fsa);
      316 +
      317 +/*
 221  318   * VFS-level init, fini stuff
 222  319   */
 223  320  
 224  321  int smbfs_vfsinit(void);
 225  322  void smbfs_vfsfini(void);
 226  323  int smbfs_subrinit(void);
 227  324  void smbfs_subrfini(void);
 228  325  int smbfs_clntinit(void);
 229  326  void smbfs_clntfini(void);
 230  327  
 231  328  void smbfs_zonelist_add(smbmntinfo_t *smi);
 232  329  void smbfs_zonelist_remove(smbmntinfo_t *smi);
 233  330  
 234  331  int smbfs_check_table(struct vfs *vfsp, struct smbnode *srp);
 235  332  void smbfs_destroy_table(struct vfs *vfsp);
 236  333  void smbfs_rflush(struct vfs *vfsp, cred_t *cr);
      334 +void smbfs_flushall(cred_t *cr);
 237  335  
      336 +int smbfs_directio(vnode_t *vp, int cmd, cred_t *cr);
      337 +
      338 +uint32_t smbfs_newnum(void);
      339 +int smbfs_newname(char *buf, size_t buflen);
      340 +
 238  341  /*
 239  342   * Function definitions - those having to do with
 240  343   * smbfs nodes, vnodes, etc
 241  344   */
 242  345  
 243  346  void smbfs_attrcache_prune(struct smbnode *np);
 244  347  void smbfs_attrcache_remove(struct smbnode *np);
 245  348  void smbfs_attrcache_rm_locked(struct smbnode *np);
 246  349  #ifndef DEBUG
 247  350  #define smbfs_attrcache_rm_locked(np)   (np)->r_attrtime = gethrtime()
 248  351  #endif
 249  352  void smbfs_attr_touchdir(struct smbnode *dnp);
 250  353  void smbfs_attrcache_fa(vnode_t *vp, struct smbfattr *fap);
 251      -void smbfs_cache_check(struct vnode *vp, struct smbfattr *fap);
 252  354  
      355 +int smbfs_validate_caches(struct vnode *vp, cred_t *cr);
      356 +void smbfs_purge_caches(struct vnode *vp, cred_t *cr);
      357 +
 253  358  void smbfs_addfree(struct smbnode *sp);
 254  359  void smbfs_rmhash(struct smbnode *);
 255  360  
 256  361  /* See avl_create in smbfs_vfsops.c */
 257  362  void smbfs_init_hash_avl(avl_tree_t *);
 258  363  
 259  364  uint32_t smbfs_gethash(const char *rpath, int prlen);
 260  365  uint32_t smbfs_getino(struct smbnode *dnp, const char *name, int nmlen);
 261  366  
 262  367  extern struct smbfattr smbfs_fattr0;
↓ open down ↓ 7 lines elided ↑ open up ↑
 270  375  
 271  376  void smbfs_fname_tolocal(struct smbfs_fctx *ctx);
 272  377  char    *smbfs_name_alloc(const char *name, int nmlen);
 273  378  void    smbfs_name_free(const char *name, int nmlen);
 274  379  
 275  380  int smbfs_readvnode(vnode_t *, uio_t *, cred_t *, struct vattr *);
 276  381  int smbfs_writevnode(vnode_t *vp, uio_t *uiop, cred_t *cr,
 277  382                          int ioflag, int timo);
 278  383  int smbfsgetattr(vnode_t *vp, struct vattr *vap, cred_t *cr);
 279  384  
      385 +void smbfs_invalidate_pages(vnode_t *vp, u_offset_t off, cred_t *cr);
      386 +
 280  387  /* smbfs ACL support */
 281  388  int smbfs_acl_getids(vnode_t *, cred_t *);
 282  389  int smbfs_acl_setids(vnode_t *, vattr_t *, cred_t *);
 283  390  int smbfs_acl_getvsa(vnode_t *, vsecattr_t *, int, cred_t *);
 284  391  int smbfs_acl_setvsa(vnode_t *, vsecattr_t *, int, cred_t *);
 285  392  int smbfs_acl_iocget(vnode_t *, intptr_t, int, cred_t *);
 286  393  int smbfs_acl_iocset(vnode_t *, intptr_t, int, cred_t *);
 287  394  
 288  395  /* smbfs_xattr.c */
 289  396  int smbfs_get_xattrdir(vnode_t *dvp, vnode_t **vpp, cred_t *cr, int);
↓ open down ↓ 18 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX