Don't restart winbind if a corrupted tdb is found during initialization.
[Samba/bb.git] / source3 / libsmb / clifsinfo.c
blob1a75d144b2aa3420aafc0da48600bfe4b2b0bc12
1 /*
2 Unix SMB/CIFS implementation.
3 FS info functions
4 Copyright (C) Stefan (metze) Metzmacher 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
22 /****************************************************************************
23 Get UNIX extensions version info.
24 ****************************************************************************/
26 bool cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor, uint16 *pminor,
27 uint32 *pcaplow, uint32 *pcaphigh)
29 bool ret = False;
30 uint16 setup;
31 char param[2];
32 char *rparam=NULL, *rdata=NULL;
33 unsigned int rparam_count=0, rdata_count=0;
35 setup = TRANSACT2_QFSINFO;
37 SSVAL(param,0,SMB_QUERY_CIFS_UNIX_INFO);
39 if (!cli_send_trans(cli, SMBtrans2,
40 NULL,
41 0, 0,
42 &setup, 1, 0,
43 param, 2, 0,
44 NULL, 0, 560)) {
45 goto cleanup;
48 if (!cli_receive_trans(cli, SMBtrans2,
49 &rparam, &rparam_count,
50 &rdata, &rdata_count)) {
51 goto cleanup;
54 if (cli_is_error(cli)) {
55 ret = False;
56 goto cleanup;
57 } else {
58 ret = True;
61 if (rdata_count < 12) {
62 goto cleanup;
65 *pmajor = SVAL(rdata,0);
66 *pminor = SVAL(rdata,2);
67 cli->posix_capabilities = *pcaplow = IVAL(rdata,4);
68 *pcaphigh = IVAL(rdata,8);
70 /* todo: but not yet needed
71 * return the other stuff
74 cleanup:
75 SAFE_FREE(rparam);
76 SAFE_FREE(rdata);
78 return ret;
81 /****************************************************************************
82 Set UNIX extensions capabilities.
83 ****************************************************************************/
85 bool cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor,
86 uint32 caplow, uint32 caphigh)
88 bool ret = False;
89 uint16 setup;
90 char param[4];
91 char data[12];
92 char *rparam=NULL, *rdata=NULL;
93 unsigned int rparam_count=0, rdata_count=0;
95 setup = TRANSACT2_SETFSINFO;
97 SSVAL(param,0,0);
98 SSVAL(param,2,SMB_SET_CIFS_UNIX_INFO);
100 SSVAL(data,0,major);
101 SSVAL(data,2,minor);
102 SIVAL(data,4,caplow);
103 SIVAL(data,8,caphigh);
105 if (!cli_send_trans(cli, SMBtrans2,
106 NULL,
107 0, 0,
108 &setup, 1, 0,
109 param, 4, 0,
110 data, 12, 560)) {
111 goto cleanup;
114 if (!cli_receive_trans(cli, SMBtrans2,
115 &rparam, &rparam_count,
116 &rdata, &rdata_count)) {
117 goto cleanup;
120 if (cli_is_error(cli)) {
121 ret = False;
122 goto cleanup;
123 } else {
124 ret = True;
127 cleanup:
128 SAFE_FREE(rparam);
129 SAFE_FREE(rdata);
131 return ret;
134 bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr)
136 bool ret = False;
137 uint16 setup;
138 char param[2];
139 char *rparam=NULL, *rdata=NULL;
140 unsigned int rparam_count=0, rdata_count=0;
142 if (!cli||!fs_attr)
143 smb_panic("cli_get_fs_attr_info() called with NULL Pionter!");
145 setup = TRANSACT2_QFSINFO;
147 SSVAL(param,0,SMB_QUERY_FS_ATTRIBUTE_INFO);
149 if (!cli_send_trans(cli, SMBtrans2,
150 NULL,
151 0, 0,
152 &setup, 1, 0,
153 param, 2, 0,
154 NULL, 0, 560)) {
155 goto cleanup;
158 if (!cli_receive_trans(cli, SMBtrans2,
159 &rparam, &rparam_count,
160 &rdata, &rdata_count)) {
161 goto cleanup;
164 if (cli_is_error(cli)) {
165 ret = False;
166 goto cleanup;
167 } else {
168 ret = True;
171 if (rdata_count < 12) {
172 goto cleanup;
175 *fs_attr = IVAL(rdata,0);
177 /* todo: but not yet needed
178 * return the other stuff
181 cleanup:
182 SAFE_FREE(rparam);
183 SAFE_FREE(rdata);
185 return ret;
188 bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number)
190 bool ret = False;
191 uint16 setup;
192 char param[2];
193 char *rparam=NULL, *rdata=NULL;
194 unsigned int rparam_count=0, rdata_count=0;
195 unsigned char nlen;
197 setup = TRANSACT2_QFSINFO;
199 SSVAL(param,0,SMB_INFO_VOLUME);
201 if (!cli_send_trans(cli, SMBtrans2,
202 NULL,
203 0, 0,
204 &setup, 1, 0,
205 param, 2, 0,
206 NULL, 0, 560)) {
207 goto cleanup;
210 if (!cli_receive_trans(cli, SMBtrans2,
211 &rparam, &rparam_count,
212 &rdata, &rdata_count)) {
213 goto cleanup;
216 if (cli_is_error(cli)) {
217 ret = False;
218 goto cleanup;
219 } else {
220 ret = True;
223 if (rdata_count < 5) {
224 goto cleanup;
227 if (pserial_number) {
228 *pserial_number = IVAL(rdata,0);
230 nlen = CVAL(rdata,l2_vol_cch);
231 clistr_pull(cli, volume_name, rdata + l2_vol_szVolLabel, sizeof(fstring), nlen, STR_NOALIGN);
233 /* todo: but not yet needed
234 * return the other stuff
237 cleanup:
238 SAFE_FREE(rparam);
239 SAFE_FREE(rdata);
241 return ret;
244 bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate)
246 bool ret = False;
247 uint16 setup;
248 char param[2];
249 char *rparam=NULL, *rdata=NULL;
250 unsigned int rparam_count=0, rdata_count=0;
251 unsigned int nlen;
253 setup = TRANSACT2_QFSINFO;
255 SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO);
257 if (!cli_send_trans(cli, SMBtrans2,
258 NULL,
259 0, 0,
260 &setup, 1, 0,
261 param, 2, 0,
262 NULL, 0, 560)) {
263 goto cleanup;
266 if (!cli_receive_trans(cli, SMBtrans2,
267 &rparam, &rparam_count,
268 &rdata, &rdata_count)) {
269 goto cleanup;
272 if (cli_is_error(cli)) {
273 ret = False;
274 goto cleanup;
275 } else {
276 ret = True;
279 if (rdata_count < 19) {
280 goto cleanup;
283 if (pdate) {
284 struct timespec ts;
285 ts = interpret_long_date(rdata);
286 *pdate = ts.tv_sec;
288 if (pserial_number) {
289 *pserial_number = IVAL(rdata,8);
291 nlen = IVAL(rdata,12);
292 clistr_pull(cli, volume_name, rdata + 18, sizeof(fstring), nlen, STR_UNICODE);
294 /* todo: but not yet needed
295 * return the other stuff
298 cleanup:
299 SAFE_FREE(rparam);
300 SAFE_FREE(rdata);
302 return ret;