From e3249d0196a3bf0c159acf69bb5fb1d0c78d1290 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Sep 2001 04:25:49 +0000 Subject: added cli_qpathinfo_alt_name() for fetching the 8.3 name of a file (This used to be commit b2eb7feb7f5bafe953fdeb92daaf9e4f08e44983) --- source3/libsmb/clirap.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'source3/libsmb') 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, ¶m_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; +} -- cgit