Debian Codegraph @

source4/torture/basic/properties.c

raw
1 /*
2 Unix SMB/CIFS implementation.
3
4 show server properties
5
6 Copyright (C) Andrew Tridgell 2004
7
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.
12
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.
17
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/>.
20 */
21
22 #include "includes.h"
23 #include "libcli/libcli.h"
24 #include "torture/util.h"
25 #include "torture/basic/proto.h"
26
27 struct bitmapping {
28 const char *name;
29 uint32_t value;
30 };
31
32 #define BIT_NAME(x) { #x, x }
33
34 const static struct bitmapping fs_attr_bits[] = {
35 BIT_NAME(FS_ATTR_CASE_SENSITIVE_SEARCH),
36 BIT_NAME(FS_ATTR_CASE_PRESERVED_NAMES),
37 BIT_NAME(FS_ATTR_UNICODE_ON_DISK),
38 BIT_NAME(FS_ATTR_PERSISTANT_ACLS),
39 BIT_NAME(FS_ATTR_COMPRESSION),
40 BIT_NAME(FS_ATTR_QUOTAS),
41 BIT_NAME(FS_ATTR_SPARSE_FILES),
42 BIT_NAME(FS_ATTR_REPARSE_POINTS),
43 BIT_NAME(FS_ATTR_REMOTE_STORAGE),
44 BIT_NAME(FS_ATTR_LFN_SUPPORT),
45 BIT_NAME(FS_ATTR_IS_COMPRESSED),
46 BIT_NAME(FS_ATTR_OBJECT_IDS),
47 BIT_NAME(FS_ATTR_ENCRYPTION),
48 BIT_NAME(FS_ATTR_NAMED_STREAMS),
49 { NULL, 0 }
50 };
51
52 const static struct bitmapping capability_bits[] = {
53 BIT_NAME(CAP_RAW_MODE),
54 BIT_NAME(CAP_MPX_MODE),
55 BIT_NAME(CAP_UNICODE),
56 BIT_NAME(CAP_LARGE_FILES),
57 BIT_NAME(CAP_NT_SMBS),
58 BIT_NAME(CAP_RPC_REMOTE_APIS),
59 BIT_NAME(CAP_STATUS32),
60 BIT_NAME(CAP_LEVEL_II_OPLOCKS),
61 BIT_NAME(CAP_LOCK_AND_READ),
62 BIT_NAME(CAP_NT_FIND),
63 BIT_NAME(CAP_DFS),
64 BIT_NAME(CAP_W2K_SMBS),
65 BIT_NAME(CAP_LARGE_READX),
66 BIT_NAME(CAP_LARGE_WRITEX),
67 BIT_NAME(CAP_UNIX),
68 BIT_NAME(CAP_EXTENDED_SECURITY),
69 { NULL, 0 }
70 };
71
72 static void show_bits(const struct bitmapping *bm, uint32_t value)
73 {
74 int i;
75 for (i=0;bm[i].name;i++) {
76 if (value & bm[i].value) {
77 d_printf("\t%s\n", bm[i].name);
78 value &= ~bm[i].value;
79 }
80 }
81 if (value != 0) {
82 d_printf("\tunknown bits: 0x%08x\n", value);
83 }
84 }
85
86
87 /*
88 print out server properties
89 */
90 bool torture_test_properties(struct torture_context *torture,
91 struct smbcli_state *cli)
92 {
93 bool correct = true;
94 union smb_fsinfo fs;
95 NTSTATUS status;
96
97 d_printf("Capabilities: 0x%08x\n", cli->transport->negotiate.capabilities);
98 show_bits(capability_bits, cli->transport->negotiate.capabilities);
99 d_printf("\n");
100
101 fs.attribute_info.level = RAW_QFS_ATTRIBUTE_INFO;
102 status = smb_raw_fsinfo(cli->tree, cli, &fs);
103 if (!NT_STATUS_IS_OK(status)) {
104 d_printf("qfsinfo failed - %s\n", nt_errstr(status));
105 correct = false;
106 } else {
107 d_printf("Filesystem attributes: 0x%08x\n",
108 fs.attribute_info.out.fs_attr);
109 show_bits(fs_attr_bits, fs.attribute_info.out.fs_attr);
110 d_printf("max_file_component_length: %d\n",
111 fs.attribute_info.out.max_file_component_length);
112 d_printf("fstype: %s\n", fs.attribute_info.out.fs_type.s);
113 }
114
115 return correct;
116 }
117
118