librpc: Shorten dcerpc_binding_handle_call a bit
[Samba/gebeck_regimport.git] / source3 / smbd / smb2_ioctl_filesys.c
blobbc2925beb955a4c70efe11c9a2cce6c2e793db23
1 /*
2 Unix SMB/CIFS implementation.
3 Core SMB2 server
5 Copyright (C) Stefan Metzmacher 2009
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "smbd/smbd.h"
23 #include "smbd/globals.h"
24 #include "../libcli/smb/smb_common.h"
25 #include "../lib/util/tevent_ntstatus.h"
26 #include "rpc_server/srv_pipe_hnd.h"
27 #include "include/ntioctl.h"
28 #include "smb2_ioctl_private.h"
30 struct tevent_req *smb2_ioctl_filesys(uint32_t ctl_code,
31 struct tevent_context *ev,
32 struct tevent_req *req,
33 struct smbd_smb2_ioctl_state *state)
35 switch (ctl_code) {
36 /* no filesystem device type ioctls are supported yet */
37 default: {
38 NTSTATUS status;
39 uint8_t *out_data = NULL;
40 uint32_t out_data_len = 0;
42 if (state->fsp == NULL) {
43 status = NT_STATUS_NOT_SUPPORTED;
44 } else {
45 status = SMB_VFS_FSCTL(state->fsp,
46 state,
47 ctl_code,
48 state->smbreq->flags2,
49 state->in_input.data,
50 state->in_input.length,
51 &out_data,
52 state->in_max_output,
53 &out_data_len);
54 state->out_output = data_blob_const(out_data, out_data_len);
55 if (NT_STATUS_IS_OK(status)) {
56 tevent_req_done(req);
57 return tevent_req_post(req, ev);
61 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
62 if (IS_IPC(state->smbreq->conn)) {
63 status = NT_STATUS_FS_DRIVER_REQUIRED;
64 } else {
65 status = NT_STATUS_INVALID_DEVICE_REQUEST;
69 tevent_req_nterror(req, status);
70 return tevent_req_post(req, ev);
71 break;
75 tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
76 return tevent_req_post(req, ev);