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-15577 SMB2 ioct dfs_get_referral returns wrong error
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15577 SMB2 ioct dfs_get_referral returns wrong error
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5844 want SMB2 ioctl FSCTL_SRV_COPYCHUNK
NEX-6124 smb_fsop_read/write should allow file != sr->fid_ofile
NEX-6125 smbtorture invalid response with smb2.ioctl
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)

@@ -20,17 +20,17 @@
  */
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #include <smbsrv/smb_kproto.h>
 #include <smbsrv/smb_dfs.h>
 #include <smbsrv/smb_door.h>
-#include <smbsrv/winioctl.h>
+#include <smb/winioctl.h>
 
 /*
  * Get Referral response header flags
  * For exact meaning refer to MS-DFSC spec.
  *

@@ -82,17 +82,42 @@
     dfs_referral_response_t *);
 static void smb_dfs_referrals_free(dfs_referral_response_t *);
 static uint16_t smb_dfs_referrals_unclen(dfs_info_t *, uint16_t);
 
 /*
+ * Handle device type FILE_DEVICE_DFS
+ * for smb2_ioctl
+ */
+uint32_t
+smb_dfs_fsctl(smb_request_t *sr, smb_fsctl_t *fsctl)
+{
+        uint32_t status;
+
+        if (!STYPE_ISIPC(sr->tid_tree->t_res_type))
+                return (NT_STATUS_INVALID_DEVICE_REQUEST);
+
+        switch (fsctl->CtlCode) {
+        case FSCTL_DFS_GET_REFERRALS:
+                status = smb_dfs_get_referrals(sr, fsctl);
+                break;
+        case FSCTL_DFS_GET_REFERRALS_EX: /* XXX - todo */
+        default:
+                status = NT_STATUS_NOT_SUPPORTED;
+        }
+
+        return (status);
+}
+
+/*
  * Note: SMB1 callers in smb_trans2_dfs.c
  * smb_com_trans2_report_dfs_inconsistency
  * smb_com_trans2_get_dfs_referral
  */
 
 /*
  * See [MS-DFSC] for details about this command
+ * Handles FSCTL_DFS_GET_REFERRALS (only)
  */
 uint32_t
 smb_dfs_get_referrals(smb_request_t *sr, smb_fsctl_t *fsctl)
 {
         dfs_info_t *referrals;

@@ -115,26 +140,19 @@
          * request buffer in our door call, and let that return the
          * response buffer ready to stuff into out_mbc.  That would
          * allow all this decoding/encoding to happen at user-level.
          * (and most of this file would go away. :-)
          */
-        switch (fsctl->CtlCode) {
-        case FSCTL_DFS_GET_REFERRALS:
+
                 /*
                  * Input data is (w) MaxReferralLevel, (U) path
                  */
                 rc = smb_mbc_decodef(fsctl->in_mbc, "%wu",
                     sr, &maxver, &path);
                 if (rc != 0)
                         return (NT_STATUS_INVALID_PARAMETER);
-                break;
 
-        case FSCTL_DFS_GET_REFERRALS_EX: /* XXX - todo */
-        default:
-                return (NT_STATUS_NOT_SUPPORTED);
-        }
-
         reftype = smb_dfs_get_reftype((const char *)path);
         switch (reftype) {
         case DFS_REFERRAL_INVALID:
                 /* Need to check the error for this case */
                 return (NT_STATUS_INVALID_PARAMETER);

@@ -389,12 +407,11 @@
  * For more details, see comments for smb_dfs_encode_refv2() or see
  * MS-DFSC specification.
  */
 static uint32_t
 smb_dfs_encode_refv3x(smb_request_t *sr, mbuf_chain_t *mbc,
-        dfs_info_t *referrals,
-    uint16_t ver)
+        dfs_info_t *referrals, uint16_t ver)
 {
         _NOTE(ARGUNUSED(sr))
         uint16_t entsize, rep_bufsize, hdrsize;
         uint16_t server_type;
         uint16_t flags = 0;

@@ -502,11 +519,11 @@
 
         rc = smb_kdoor_upcall(sr->sr_server, SMB_DR_DFS_GET_REFERRALS,
             &req, dfs_referral_query_xdr, refrsp, dfs_referral_response_xdr);
 
         if (rc != 0 || refrsp->rp_status != ERROR_SUCCESS) {
-                return (NT_STATUS_NO_SUCH_DEVICE);
+                return (NT_STATUS_FS_DRIVER_REQUIRED);
         }
 
         (void) strsubst(refrsp->rp_referrals.i_uncpath, '/', '\\');
         return (NT_STATUS_SUCCESS);
 }