Print this page
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>
SMB-65 SMB server in non-global zones (use zone_kcred())
SUP-599 smb_oplock_acquire thread deadlock
re #14152 Race between ipmi_submit_driver_request() and kcs_loop() (sync with illumos fix 3902)
SMB-46 File handle leaks exposed by mtime fixes (rm 7815)
re #7815 SMB server delivers old modification time...
re #11215 rb3676 sesctl to SGI JBOD hangs in biowait() with a command stuck in mptsas driver
re #10734 NT Trans. Notify returning too quickly


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 #include <sys/synch.h>
  27 #include <smbsrv/smb_kproto.h>
  28 #include <smbsrv/smb_fsops.h>
  29 #include <sys/nbmlock.h>
  30 
  31 /*
  32  * NT_RENAME InformationLevels:
  33  *
  34  * SMB_NT_RENAME_MOVE_CLUSTER_INFO      Server returns invalid parameter.
  35  * SMB_NT_RENAME_SET_LINK_INFO          Create a hard link to a file.
  36  * SMB_NT_RENAME_RENAME_FILE            In-place rename of a file.
  37  * SMB_NT_RENAME_MOVE_FILE              Move (rename) a file.
  38  */
  39 #define SMB_NT_RENAME_MOVE_CLUSTER_INFO 0x0102
  40 #define SMB_NT_RENAME_SET_LINK_INFO     0x0103
  41 #define SMB_NT_RENAME_RENAME_FILE       0x0104
  42 #define SMB_NT_RENAME_MOVE_FILE         0x0105
  43 


  55  * SearchAttributes indicates the attributes that the target file(s) must
  56  * have. If SearchAttributes is zero then only normal files are renamed.
  57  * If the system file or hidden attributes are specified then the rename
  58  * is inclusive - both the specified type(s) of files and normal files are
  59  * renamed.
  60  */
  61 smb_sdrc_t
  62 smb_pre_rename(smb_request_t *sr)
  63 {
  64         smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
  65         smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
  66         int rc;
  67 
  68         if ((rc = smbsr_decode_vwv(sr, "w", &src_fqi->fq_sattr)) == 0) {
  69                 rc = smbsr_decode_data(sr, "%SS", sr, &src_fqi->fq_path.pn_path,
  70                     &dst_fqi->fq_path.pn_path);
  71 
  72                 dst_fqi->fq_sattr = 0;
  73         }
  74 
  75         DTRACE_SMB_2(op__Rename__start, smb_request_t *, sr,
  76             struct dirop *, &sr->arg.dirop);
  77 
  78         return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  79 }
  80 
  81 void
  82 smb_post_rename(smb_request_t *sr)
  83 {
  84         DTRACE_SMB_1(op__Rename__done, smb_request_t *, sr);
  85 }
  86 
  87 smb_sdrc_t
  88 smb_com_rename(smb_request_t *sr)
  89 {
  90         smb_fqi_t       *src_fqi = &sr->arg.dirop.fqi;
  91         smb_fqi_t       *dst_fqi = &sr->arg.dirop.dst_fqi;
  92         smb_pathname_t  *src_pn = &src_fqi->fq_path;
  93         smb_pathname_t  *dst_pn = &dst_fqi->fq_path;
  94         uint32_t        status;
  95 
  96         if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
  97                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
  98                     ERRDOS, ERROR_ACCESS_DENIED);
  99                 return (SDRC_ERROR);
 100         }
 101 
 102         smb_pathname_init(sr, src_pn, src_pn->pn_path);
 103         smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
 104         if (!smb_pathname_validate(sr, src_pn) ||


 129  * is inclusive - both the specified type(s) of files and normal files are
 130  * renamed.
 131  */
 132 smb_sdrc_t
 133 smb_pre_nt_rename(smb_request_t *sr)
 134 {
 135         smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
 136         smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
 137         uint32_t clusters;
 138         int rc;
 139 
 140         rc = smbsr_decode_vwv(sr, "wwl", &src_fqi->fq_sattr,
 141             &sr->arg.dirop.info_level, &clusters);
 142         if (rc == 0) {
 143                 rc = smbsr_decode_data(sr, "%SS", sr,
 144                     &src_fqi->fq_path.pn_path, &dst_fqi->fq_path.pn_path);
 145 
 146                 dst_fqi->fq_sattr = 0;
 147         }
 148 
 149         DTRACE_SMB_2(op__NtRename__start, smb_request_t *, sr,
 150             struct dirop *, &sr->arg.dirop);
 151 
 152         return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 153 }
 154 
 155 void
 156 smb_post_nt_rename(smb_request_t *sr)
 157 {
 158         DTRACE_SMB_1(op__NtRename__done, smb_request_t *, sr);
 159 }
 160 
 161 smb_sdrc_t
 162 smb_com_nt_rename(smb_request_t *sr)
 163 {
 164         smb_fqi_t       *src_fqi = &sr->arg.dirop.fqi;
 165         smb_fqi_t       *dst_fqi = &sr->arg.dirop.dst_fqi;
 166         smb_pathname_t  *src_pn = &src_fqi->fq_path;
 167         smb_pathname_t  *dst_pn = &dst_fqi->fq_path;
 168         uint32_t        status;
 169 
 170         if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
 171                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
 172                     ERRDOS, ERROR_ACCESS_DENIED);
 173                 return (SDRC_ERROR);
 174         }
 175 
 176         smb_pathname_init(sr, src_pn, src_pn->pn_path);
 177         smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
 178         if (!smb_pathname_validate(sr, src_pn) ||




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 #include <sys/synch.h>
  27 #include <smbsrv/smb_kproto.h>
  28 #include <smbsrv/smb_fsops.h>
  29 #include <sys/nbmlock.h>
  30 
  31 /*
  32  * NT_RENAME InformationLevels:
  33  *
  34  * SMB_NT_RENAME_MOVE_CLUSTER_INFO      Server returns invalid parameter.
  35  * SMB_NT_RENAME_SET_LINK_INFO          Create a hard link to a file.
  36  * SMB_NT_RENAME_RENAME_FILE            In-place rename of a file.
  37  * SMB_NT_RENAME_MOVE_FILE              Move (rename) a file.
  38  */
  39 #define SMB_NT_RENAME_MOVE_CLUSTER_INFO 0x0102
  40 #define SMB_NT_RENAME_SET_LINK_INFO     0x0103
  41 #define SMB_NT_RENAME_RENAME_FILE       0x0104
  42 #define SMB_NT_RENAME_MOVE_FILE         0x0105
  43 


  55  * SearchAttributes indicates the attributes that the target file(s) must
  56  * have. If SearchAttributes is zero then only normal files are renamed.
  57  * If the system file or hidden attributes are specified then the rename
  58  * is inclusive - both the specified type(s) of files and normal files are
  59  * renamed.
  60  */
  61 smb_sdrc_t
  62 smb_pre_rename(smb_request_t *sr)
  63 {
  64         smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
  65         smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
  66         int rc;
  67 
  68         if ((rc = smbsr_decode_vwv(sr, "w", &src_fqi->fq_sattr)) == 0) {
  69                 rc = smbsr_decode_data(sr, "%SS", sr, &src_fqi->fq_path.pn_path,
  70                     &dst_fqi->fq_path.pn_path);
  71 
  72                 dst_fqi->fq_sattr = 0;
  73         }
  74 
  75         DTRACE_SMB_START(op__Rename, smb_request_t *, sr); /* arg.dirop */

  76 
  77         return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  78 }
  79 
  80 void
  81 smb_post_rename(smb_request_t *sr)
  82 {
  83         DTRACE_SMB_DONE(op__Rename, smb_request_t *, sr);
  84 }
  85 
  86 smb_sdrc_t
  87 smb_com_rename(smb_request_t *sr)
  88 {
  89         smb_fqi_t       *src_fqi = &sr->arg.dirop.fqi;
  90         smb_fqi_t       *dst_fqi = &sr->arg.dirop.dst_fqi;
  91         smb_pathname_t  *src_pn = &src_fqi->fq_path;
  92         smb_pathname_t  *dst_pn = &dst_fqi->fq_path;
  93         uint32_t        status;
  94 
  95         if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
  96                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
  97                     ERRDOS, ERROR_ACCESS_DENIED);
  98                 return (SDRC_ERROR);
  99         }
 100 
 101         smb_pathname_init(sr, src_pn, src_pn->pn_path);
 102         smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
 103         if (!smb_pathname_validate(sr, src_pn) ||


 128  * is inclusive - both the specified type(s) of files and normal files are
 129  * renamed.
 130  */
 131 smb_sdrc_t
 132 smb_pre_nt_rename(smb_request_t *sr)
 133 {
 134         smb_fqi_t *src_fqi = &sr->arg.dirop.fqi;
 135         smb_fqi_t *dst_fqi = &sr->arg.dirop.dst_fqi;
 136         uint32_t clusters;
 137         int rc;
 138 
 139         rc = smbsr_decode_vwv(sr, "wwl", &src_fqi->fq_sattr,
 140             &sr->arg.dirop.info_level, &clusters);
 141         if (rc == 0) {
 142                 rc = smbsr_decode_data(sr, "%SS", sr,
 143                     &src_fqi->fq_path.pn_path, &dst_fqi->fq_path.pn_path);
 144 
 145                 dst_fqi->fq_sattr = 0;
 146         }
 147 
 148         DTRACE_SMB_START(op__NtRename, smb_request_t *, sr); /* arg.dirop */

 149 
 150         return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 151 }
 152 
 153 void
 154 smb_post_nt_rename(smb_request_t *sr)
 155 {
 156         DTRACE_SMB_DONE(op__NtRename, smb_request_t *, sr);
 157 }
 158 
 159 smb_sdrc_t
 160 smb_com_nt_rename(smb_request_t *sr)
 161 {
 162         smb_fqi_t       *src_fqi = &sr->arg.dirop.fqi;
 163         smb_fqi_t       *dst_fqi = &sr->arg.dirop.dst_fqi;
 164         smb_pathname_t  *src_pn = &src_fqi->fq_path;
 165         smb_pathname_t  *dst_pn = &dst_fqi->fq_path;
 166         uint32_t        status;
 167 
 168         if (!STYPE_ISDSK(sr->tid_tree->t_res_type)) {
 169                 smbsr_error(sr, NT_STATUS_ACCESS_DENIED,
 170                     ERRDOS, ERROR_ACCESS_DENIED);
 171                 return (SDRC_ERROR);
 172         }
 173 
 174         smb_pathname_init(sr, src_pn, src_pn->pn_path);
 175         smb_pathname_init(sr, dst_pn, dst_pn->pn_path);
 176         if (!smb_pathname_validate(sr, src_pn) ||