1da6c28aaSamw /* 2da6c28aaSamw * CDDL HEADER START 3da6c28aaSamw * 4da6c28aaSamw * The contents of this file are subject to the terms of the 5da6c28aaSamw * Common Development and Distribution License (the "License"). 6da6c28aaSamw * You may not use this file except in compliance with the License. 7da6c28aaSamw * 8da6c28aaSamw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9da6c28aaSamw * or http://www.opensolaris.org/os/licensing. 10da6c28aaSamw * See the License for the specific language governing permissions 11da6c28aaSamw * and limitations under the License. 12da6c28aaSamw * 13da6c28aaSamw * When distributing Covered Code, include this CDDL HEADER in each 14da6c28aaSamw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15da6c28aaSamw * If applicable, add the following below this CDDL HEADER, with the 16da6c28aaSamw * fields enclosed by brackets "[]" replaced with your own identifying 17da6c28aaSamw * information: Portions Copyright [yyyy] [name of copyright owner] 18da6c28aaSamw * 19da6c28aaSamw * CDDL HEADER END 20da6c28aaSamw */ 21da6c28aaSamw /* 22*dc20a302Sas200622 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23da6c28aaSamw * Use is subject to license terms. 24da6c28aaSamw */ 25da6c28aaSamw 26da6c28aaSamw #pragma ident "%Z%%M% %I% %E% SMI" 27da6c28aaSamw 28da6c28aaSamw #include <smbsrv/smb_incl.h> 29da6c28aaSamw #include <smbsrv/winioctl.h> 30da6c28aaSamw #include <smbsrv/ntstatus.h> 31da6c28aaSamw 32da6c28aaSamw 33da6c28aaSamw /* 34da6c28aaSamw * This table defines the list of IOCTL/FSCTL values for which we'll 35da6c28aaSamw * return a specific NT status code, based on observation of NT. 36da6c28aaSamw */ 37da6c28aaSamw static struct { 38da6c28aaSamw uint32_t fcode; 39da6c28aaSamw DWORD status; 40da6c28aaSamw } ioctl_ret_tbl[] = { 41da6c28aaSamw {FSCTL_GET_OBJECT_ID, NT_STATUS_INVALID_PARAMETER}, 42da6c28aaSamw {FSCTL_QUERY_ALLOCATED_RANGES, NT_STATUS_INVALID_PARAMETER} 43da6c28aaSamw }; 44da6c28aaSamw 45da6c28aaSamw 46da6c28aaSamw /* 47da6c28aaSamw * smb_nt_transact_ioctl 48da6c28aaSamw * 49da6c28aaSamw * This command allows device and file system control functions to be 50da6c28aaSamw * transferred transparently from client to server. This is currently 51da6c28aaSamw * a stub to work out whether or not we need to return an NT status 52da6c28aaSamw * code. 53da6c28aaSamw * 54da6c28aaSamw * Setup Words Encoding Description 55da6c28aaSamw * =========================== ========================================= 56da6c28aaSamw * ULONG FunctionCode; NT device or file system control code 57da6c28aaSamw * USHORT Fid; Handle for io or fs control. Unless BIT0 58da6c28aaSamw * of ISFLAGS is set. 59da6c28aaSamw * BOOLEAN IsFsctl; Indicates whether the command is a device 60da6c28aaSamw * control (FALSE) or a file system control 61da6c28aaSamw * (TRUE). 62da6c28aaSamw * UCHAR IsFlags; BIT0 - command is to be applied to share 63da6c28aaSamw * root handle. Share must be a DFS share. 64da6c28aaSamw * 65da6c28aaSamw * Data Block Encoding Description 66da6c28aaSamw * =========================== ========================================= 67da6c28aaSamw * Data[ TotalDataCount ] Passed to the Fsctl or Ioctl 68da6c28aaSamw * 69da6c28aaSamw * Server Response Description 70da6c28aaSamw * =========================== ================================== 71da6c28aaSamw * SetupCount 1 72da6c28aaSamw * Setup[0] Length of information returned by 73da6c28aaSamw * io or fs control. 74da6c28aaSamw * DataCount Length of information returned by 75da6c28aaSamw * io or fs control. 76da6c28aaSamw * Data[ DataCount ] The results of the io or fs control. 77da6c28aaSamw */ 78da6c28aaSamw int 79da6c28aaSamw smb_nt_transact_ioctl(struct smb_request *sr, struct smb_xa *xa) 80da6c28aaSamw { 81da6c28aaSamw DWORD status = NT_STATUS_SUCCESS; 82da6c28aaSamw uint32_t fcode; 83da6c28aaSamw unsigned short fid; 84da6c28aaSamw unsigned char is_fsctl; 85da6c28aaSamw unsigned char is_flags; 86da6c28aaSamw int i; 87da6c28aaSamw 88da6c28aaSamw if (smb_decode_mbc(&xa->req_setup_mb, "lwbb", 89da6c28aaSamw &fcode, 90da6c28aaSamw &fid, 91da6c28aaSamw &is_fsctl, 92da6c28aaSamw &is_flags) != 0) { 93*dc20a302Sas200622 smbsr_error(sr, NT_STATUS_INVALID_PARAMETER, 0, 0); 94da6c28aaSamw } 95da6c28aaSamw 96da6c28aaSamw for (i = 0; 97da6c28aaSamw i < sizeof (ioctl_ret_tbl) / sizeof (ioctl_ret_tbl[0]); 98da6c28aaSamw i++) { 99da6c28aaSamw if (ioctl_ret_tbl[i].fcode == fcode) { 100da6c28aaSamw status = ioctl_ret_tbl[i].status; 101da6c28aaSamw break; 102da6c28aaSamw } 103da6c28aaSamw } 104da6c28aaSamw 105da6c28aaSamw if (status != NT_STATUS_SUCCESS) 106*dc20a302Sas200622 smbsr_error(sr, status, 0, 0); 107da6c28aaSamw 108da6c28aaSamw (void) smb_encode_mbc(&xa->rep_param_mb, "l", 0); 109da6c28aaSamw return (SDRC_NORMAL_REPLY); 110da6c28aaSamw } 111