s4-torture: add smb2 ioctl test suite
[Samba/gebeck_regimport.git] / source4 / torture / smb2 / ioctl.c
blobbc8a96a58f81871e38b0b414f76bdefc0f9df012
1 /*
2 Unix SMB/CIFS implementation.
4 test suite for SMB2 ioctl operations
6 Copyright (C) David Disseldorp 2011
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "librpc/gen_ndr/security.h"
24 #include "libcli/smb2/smb2.h"
25 #include "libcli/smb2/smb2_calls.h"
26 #include "torture/torture.h"
27 #include "torture/smb2/proto.h"
29 #define FNAME "testfsctl.dat"
32 basic testing of SMB2 shadow copy calls
34 static bool test_ioctl_get_shadow_copy(struct torture_context *torture,
35 struct smb2_tree *tree)
37 struct smb2_handle h;
38 uint8_t buf[100];
39 NTSTATUS status;
40 union smb_ioctl ioctl;
41 TALLOC_CTX *tmp_ctx = talloc_new(tree);
43 smb2_util_unlink(tree, FNAME);
45 status = torture_smb2_testfile(tree, FNAME, &h);
46 if (!NT_STATUS_IS_OK(status)) {
47 printf("create write\n");
48 return false;
51 ZERO_ARRAY(buf);
52 status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
53 if (!NT_STATUS_IS_OK(status)) {
54 printf("failed write\n");
55 return false;
58 ZERO_STRUCT(ioctl);
59 ioctl.smb2.level = RAW_IOCTL_SMB2;
60 ioctl.smb2.in.file.handle = h;
61 ioctl.smb2.in.function = 0x144064; /* FSCTL_GET_SHADOW_COPY_DATA 0x144064 */
62 ioctl.smb2.in.max_response_size = 16;
63 ioctl.smb2.in.flags = 1; /* Is FSCTL */
65 status = smb2_ioctl(tree, tmp_ctx, &ioctl.smb2);
66 if (!NT_STATUS_IS_OK(status)) {
67 printf("FSCTL_GET_SHADOW_COPY_DATA failed\n");
68 return false;
71 return true;
75 basic testing of SMB2 ioctls
77 struct torture_suite *torture_smb2_ioctl_init(void)
79 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ioctl");
81 torture_suite_add_1smb2_test(suite, "shadow_copy", test_ioctl_get_shadow_copy);
83 suite->description = talloc_strdup(suite, "SMB2-IOCTL tests");
85 return suite;