1 /* 2 * CDDL HEADER START 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 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #include <smbsrv/smb_incl.h> 27 #include <smbsrv/winioctl.h> 28 #include <smbsrv/ntstatus.h> 29 30 static uint32_t smb_nt_trans_ioctl_invalid_parm(smb_request_t *, 31 smb_xa_t *); 32 33 /* 34 * This table defines the list of IOCTL/FSCTL values for which we'll 35 * call a funtion to return a specific processing. 36 */ 37 static struct { 38 uint32_t fcode; 39 uint32_t (*ioctl_func)(smb_request_t *sr, smb_xa_t *xa); 40 } ioctl_ret_tbl[] = { 41 { FSCTL_GET_OBJECT_ID, smb_nt_trans_ioctl_invalid_parm }, 42 { FSCTL_QUERY_ALLOCATED_RANGES, smb_nt_trans_ioctl_invalid_parm }, 43 { FSCTL_SRV_ENUMERATE_SNAPSHOTS, smb_vss_ioctl_enumerate_snaps } 44 }; 45 46 /* 47 * smb_nt_transact_ioctl 48 * 49 * This command allows device and file system control functions to be 50 * transferred transparently from client to server. This is currently 51 * a stub to work out whether or not we need to return an NT status 52 * code. 53 * 54 * Setup Words Encoding Description 55 * =========================== ========================================= 56 * ULONG FunctionCode; NT device or file system control code 57 * USHORT Fid; Handle for io or fs control. Unless BIT0 58 * of ISFLAGS is set. 59 * BOOLEAN IsFsctl; Indicates whether the command is a device 60 * control (FALSE) or a file system control 61 * (TRUE). 62 * UCHAR IsFlags; BIT0 - command is to be applied to share 63 * root handle. Share must be a DFS share. 64 * 65 * Data Block Encoding Description 66 * =========================== ========================================= 67 * Data[ TotalDataCount ] Passed to the Fsctl or Ioctl 68 * 69 * Server Response Description 70 * =========================== ================================== 71 * SetupCount 1 72 * Setup[0] Length of information returned by 73 * io or fs control. 74 * DataCount Length of information returned by 75 * io or fs control. 76 * Data[ DataCount ] The results of the io or fs control. 77 */ 78 smb_sdrc_t 79 smb_nt_transact_ioctl(smb_request_t *sr, smb_xa_t *xa) 80 { 81 uint32_t status = NT_STATUS_SUCCESS; 82 uint32_t fcode; 83 unsigned short fid; 84 unsigned char is_fsctl; 85 unsigned char is_flags; 86 int i; 87 88 if (smb_mbc_decodef(&xa->req_setup_mb, "lwbb", 89 &fcode, &fid, &is_fsctl, &is_flags) != 0) { 90 smbsr_error(sr, NT_STATUS_INVALID_PARAMETER, 0, 0); 91 return (SDRC_ERROR); 92 } 93 94 for (i = 0; i < sizeof (ioctl_ret_tbl) / sizeof (ioctl_ret_tbl[0]); 95 i++) { 96 if (ioctl_ret_tbl[i].fcode == fcode) { 97 status = ioctl_ret_tbl[i].ioctl_func(sr, xa); 98 break; 99 } 100 } 101 102 if (status != NT_STATUS_SUCCESS) { 103 smbsr_error(sr, status, 0, 0); 104 return (SDRC_ERROR); 105 } 106 107 (void) smb_mbc_encodef(&xa->rep_param_mb, "l", 0); 108 return (SDRC_SUCCESS); 109 } 110 111 /* ARGSUSED */ 112 static uint32_t 113 smb_nt_trans_ioctl_invalid_parm(smb_request_t *sr, smb_xa_t *xa) 114 { 115 return (NT_STATUS_INVALID_PARAMETER); 116 } 117