summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-09-25 04:25:49 +0000
committerAndrew Tridgell <tridge@samba.org>2001-09-25 04:25:49 +0000
commite3249d0196a3bf0c159acf69bb5fb1d0c78d1290 (patch)
tree3af31d35fdbb2e5341da5fadea09e295607985db
parentf3d8f6b198708c9da9f30ff2a3132b7ead96552c (diff)
downloadsamba-e3249d0196a3bf0c159acf69bb5fb1d0c78d1290.tar.gz
samba-e3249d0196a3bf0c159acf69bb5fb1d0c78d1290.tar.bz2
samba-e3249d0196a3bf0c159acf69bb5fb1d0c78d1290.zip
added cli_qpathinfo_alt_name() for fetching the 8.3 name of a file
(This used to be commit b2eb7feb7f5bafe953fdeb92daaf9e4f08e44983)
-rw-r--r--source3/libsmb/clirap.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 90f4d546d1..2136ba118b 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -627,3 +627,68 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdat
SAFE_FREE(rparam);
return True;
}
+
+
+
+/****************************************************************************
+send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
+****************************************************************************/
+NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name)
+{
+ int data_len = 0;
+ int param_len = 0;
+ uint16 setup = TRANSACT2_QPATHINFO;
+ pstring param;
+ char *rparam=NULL, *rdata=NULL;
+ int count=8;
+ char *p;
+ BOOL ret;
+ int len;
+
+ p = param;
+ memset(p, 0, 6);
+ SSVAL(p, 0, SMB_QUERY_FILE_ALT_NAME_INFO);
+ p += 6;
+ p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE);
+
+ param_len = PTR_DIFF(p, param);
+
+ do {
+ ret = (cli_send_trans(cli, SMBtrans2,
+ NULL, /* Name */
+ -1, 0, /* fid, flags */
+ &setup, 1, 0, /* setup, length, max */
+ param, param_len, 10, /* param, length, max */
+ NULL, data_len, cli->max_xmit /* data, length, max */
+ ) &&
+ cli_receive_trans(cli, SMBtrans2,
+ &rparam, &param_len,
+ &rdata, &data_len));
+ if (!ret && cli_is_dos_error(cli)) {
+ /* we need to work around a Win95 bug - sometimes
+ it gives ERRSRV/ERRerror temprarily */
+ uint8 eclass;
+ uint32 ecode;
+ cli_dos_error(cli, &eclass, &ecode);
+ if (eclass != ERRSRV || ecode != ERRerror) break;
+ msleep(100);
+ }
+ } while (count-- && ret==False);
+
+ if (!ret || !rdata || data_len < 4) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ len = IVAL(rdata, 0);
+
+ if (len > data_len - 4) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ clistr_pull(cli, alt_name, rdata+4, sizeof(fstring), len, 0);
+
+ SAFE_FREE(rdata);
+ SAFE_FREE(rparam);
+
+ return NT_STATUS_OK;
+}