mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
s3: Convert cli_qpathinfo2 to cli_qpathinfo_send
This commit is contained in:
parent
9a2d08bd3c
commit
f62bde93ce
@ -1576,10 +1576,11 @@ static int do_allinfo(const char *name)
|
|||||||
}
|
}
|
||||||
d_printf("altname: %s\n", altname);
|
d_printf("altname: %s\n", altname);
|
||||||
|
|
||||||
if (!cli_qpathinfo2(cli, name, &b_time, &a_time, &m_time, &c_time,
|
status = cli_qpathinfo2(cli, name, &b_time, &a_time, &m_time, &c_time,
|
||||||
&size, &mode, &ino)) {
|
&size, &mode, &ino);
|
||||||
d_printf("%s getting pathinfo for %s\n",
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
cli_errstr(cli),name);
|
d_printf("%s getting pathinfo for %s\n", nt_errstr(status),
|
||||||
|
name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2665,13 +2665,24 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname,
|
|||||||
time_t write_time,
|
time_t write_time,
|
||||||
time_t change_time,
|
time_t change_time,
|
||||||
uint16 mode);
|
uint16 mode);
|
||||||
bool cli_qpathinfo2(struct cli_state *cli, const char *fname,
|
struct tevent_req *cli_qpathinfo2_send(TALLOC_CTX *mem_ctx,
|
||||||
struct timespec *create_time,
|
struct event_context *ev,
|
||||||
struct timespec *access_time,
|
struct cli_state *cli,
|
||||||
struct timespec *write_time,
|
const char *fname);
|
||||||
struct timespec *change_time,
|
NTSTATUS cli_qpathinfo2_recv(struct tevent_req *req,
|
||||||
SMB_OFF_T *size, uint16 *mode,
|
struct timespec *create_time,
|
||||||
SMB_INO_T *ino);
|
struct timespec *access_time,
|
||||||
|
struct timespec *write_time,
|
||||||
|
struct timespec *change_time,
|
||||||
|
SMB_OFF_T *size, uint16 *mode,
|
||||||
|
SMB_INO_T *ino);
|
||||||
|
NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
|
||||||
|
struct timespec *create_time,
|
||||||
|
struct timespec *access_time,
|
||||||
|
struct timespec *write_time,
|
||||||
|
struct timespec *change_time,
|
||||||
|
SMB_OFF_T *size, uint16 *mode,
|
||||||
|
SMB_INO_T *ino);
|
||||||
bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
|
bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
unsigned int *pnum_streams,
|
unsigned int *pnum_streams,
|
||||||
|
@ -768,81 +768,132 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname,
|
|||||||
Send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level.
|
Send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool cli_qpathinfo2(struct cli_state *cli, const char *fname,
|
struct cli_qpathinfo2_state {
|
||||||
struct timespec *create_time,
|
uint32_t num_data;
|
||||||
struct timespec *access_time,
|
uint8_t *data;
|
||||||
struct timespec *write_time,
|
};
|
||||||
struct timespec *change_time,
|
|
||||||
SMB_OFF_T *size, uint16 *mode,
|
static void cli_qpathinfo2_done(struct tevent_req *subreq);
|
||||||
SMB_INO_T *ino)
|
|
||||||
|
struct tevent_req *cli_qpathinfo2_send(TALLOC_CTX *mem_ctx,
|
||||||
|
struct event_context *ev,
|
||||||
|
struct cli_state *cli,
|
||||||
|
const char *fname)
|
||||||
{
|
{
|
||||||
unsigned int data_len = 0;
|
struct tevent_req *req = NULL, *subreq = NULL;
|
||||||
unsigned int param_len = 0;
|
struct cli_qpathinfo2_state *state = NULL;
|
||||||
uint16 setup = TRANSACT2_QPATHINFO;
|
|
||||||
char *param;
|
|
||||||
char *rparam=NULL, *rdata=NULL;
|
|
||||||
char *p;
|
|
||||||
size_t nlen = 2*(strlen(fname)+1);
|
|
||||||
|
|
||||||
param = SMB_MALLOC_ARRAY(char, 6+nlen+2);
|
req = tevent_req_create(mem_ctx, &state, struct cli_qpathinfo2_state);
|
||||||
if (!param) {
|
if (req == NULL) {
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = param;
|
subreq = cli_qpathinfo_send(state, ev, cli, fname,
|
||||||
memset(param, '\0', 6);
|
SMB_QUERY_FILE_ALL_INFO,
|
||||||
SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO);
|
68, cli->max_xmit);
|
||||||
p += 6;
|
if (tevent_req_nomem(subreq, req)) {
|
||||||
p += clistr_push(cli, p, fname, nlen, STR_TERMINATE);
|
return tevent_req_post(req, ev);
|
||||||
|
|
||||||
param_len = PTR_DIFF(p, param);
|
|
||||||
|
|
||||||
if (!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 */
|
|
||||||
)) {
|
|
||||||
SAFE_FREE(param);
|
|
||||||
return False;
|
|
||||||
}
|
}
|
||||||
|
tevent_req_set_callback(subreq, cli_qpathinfo2_done, req);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
SAFE_FREE(param);
|
static void cli_qpathinfo2_done(struct tevent_req *subreq)
|
||||||
if (!cli_receive_trans(cli, SMBtrans2,
|
{
|
||||||
&rparam, ¶m_len,
|
struct tevent_req *req = tevent_req_callback_data(
|
||||||
&rdata, &data_len)) {
|
subreq, struct tevent_req);
|
||||||
return False;
|
struct cli_qpathinfo2_state *state = tevent_req_data(
|
||||||
|
req, struct cli_qpathinfo2_state);
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
status = cli_qpathinfo_recv(subreq, state, &state->data,
|
||||||
|
&state->num_data);
|
||||||
|
TALLOC_FREE(subreq);
|
||||||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
tevent_req_nterror(req, status);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
tevent_req_done(req);
|
||||||
|
}
|
||||||
|
|
||||||
if (!rdata || data_len < 68) {
|
NTSTATUS cli_qpathinfo2_recv(struct tevent_req *req,
|
||||||
return False;
|
struct timespec *create_time,
|
||||||
|
struct timespec *access_time,
|
||||||
|
struct timespec *write_time,
|
||||||
|
struct timespec *change_time,
|
||||||
|
SMB_OFF_T *size, uint16 *mode,
|
||||||
|
SMB_INO_T *ino)
|
||||||
|
{
|
||||||
|
struct cli_qpathinfo2_state *state = tevent_req_data(
|
||||||
|
req, struct cli_qpathinfo2_state);
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
if (tevent_req_is_nterror(req, &status)) {
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (create_time) {
|
if (create_time) {
|
||||||
*create_time = interpret_long_date(rdata+0);
|
*create_time = interpret_long_date((char *)state->data+0);
|
||||||
}
|
}
|
||||||
if (access_time) {
|
if (access_time) {
|
||||||
*access_time = interpret_long_date(rdata+8);
|
*access_time = interpret_long_date((char *)state->data+8);
|
||||||
}
|
}
|
||||||
if (write_time) {
|
if (write_time) {
|
||||||
*write_time = interpret_long_date(rdata+16);
|
*write_time = interpret_long_date((char *)state->data+16);
|
||||||
}
|
}
|
||||||
if (change_time) {
|
if (change_time) {
|
||||||
*change_time = interpret_long_date(rdata+24);
|
*change_time = interpret_long_date((char *)state->data+24);
|
||||||
}
|
}
|
||||||
if (mode) {
|
if (mode) {
|
||||||
*mode = SVAL(rdata, 32);
|
*mode = SVAL(state->data, 32);
|
||||||
}
|
}
|
||||||
if (size) {
|
if (size) {
|
||||||
*size = IVAL2_TO_SMB_BIG_UINT(rdata,48);
|
*size = IVAL2_TO_SMB_BIG_UINT(state->data,48);
|
||||||
}
|
}
|
||||||
if (ino) {
|
if (ino) {
|
||||||
*ino = IVAL(rdata, 64);
|
*ino = IVAL(state->data, 64);
|
||||||
}
|
}
|
||||||
|
return NT_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
SAFE_FREE(rdata);
|
NTSTATUS cli_qpathinfo2(struct cli_state *cli, const char *fname,
|
||||||
SAFE_FREE(rparam);
|
struct timespec *create_time,
|
||||||
return True;
|
struct timespec *access_time,
|
||||||
|
struct timespec *write_time,
|
||||||
|
struct timespec *change_time,
|
||||||
|
SMB_OFF_T *size, uint16 *mode,
|
||||||
|
SMB_INO_T *ino)
|
||||||
|
{
|
||||||
|
TALLOC_CTX *frame = talloc_stackframe();
|
||||||
|
struct event_context *ev;
|
||||||
|
struct tevent_req *req;
|
||||||
|
NTSTATUS status = NT_STATUS_NO_MEMORY;
|
||||||
|
|
||||||
|
if (cli_has_async_calls(cli)) {
|
||||||
|
/*
|
||||||
|
* Can't use sync call while an async call is in flight
|
||||||
|
*/
|
||||||
|
status = NT_STATUS_INVALID_PARAMETER;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
ev = event_context_init(frame);
|
||||||
|
if (ev == NULL) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
req = cli_qpathinfo2_send(frame, ev, cli, fname);
|
||||||
|
if (req == NULL) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
status = cli_qpathinfo2_recv(req, change_time, access_time,
|
||||||
|
write_time, change_time, size, mode, ino);
|
||||||
|
fail:
|
||||||
|
TALLOC_FREE(frame);
|
||||||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
cli_set_error(cli, status);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -531,12 +531,12 @@ SMBC_getatr(SMBCCTX * context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!srv->no_pathinfo2 &&
|
if (!srv->no_pathinfo2 &&
|
||||||
cli_qpathinfo2(targetcli, targetpath,
|
NT_STATUS_IS_OK(cli_qpathinfo2(targetcli, targetpath,
|
||||||
create_time_ts,
|
create_time_ts,
|
||||||
access_time_ts,
|
access_time_ts,
|
||||||
write_time_ts,
|
write_time_ts,
|
||||||
change_time_ts,
|
change_time_ts,
|
||||||
size, mode, ino)) {
|
size, mode, ino))) {
|
||||||
TALLOC_FREE(frame);
|
TALLOC_FREE(frame);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
@ -2896,9 +2896,10 @@ static bool run_trans2test(int dummy)
|
|||||||
cli_open(cli, fname,
|
cli_open(cli, fname,
|
||||||
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
|
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
|
||||||
cli_close(cli, fnum);
|
cli_close(cli, fnum);
|
||||||
if (!cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts,
|
status = cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts,
|
||||||
&m_time_ts, &size, NULL, NULL)) {
|
&m_time_ts, &size, NULL, NULL);
|
||||||
printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status));
|
||||||
correct = False;
|
correct = False;
|
||||||
} else {
|
} else {
|
||||||
if (w_time_ts.tv_sec < 60*60*24*2) {
|
if (w_time_ts.tv_sec < 60*60*24*2) {
|
||||||
@ -2918,9 +2919,10 @@ static bool run_trans2test(int dummy)
|
|||||||
correct = False;
|
correct = False;
|
||||||
}
|
}
|
||||||
sleep(3);
|
sleep(3);
|
||||||
if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts,
|
status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts,
|
||||||
&m_time_ts, &size, NULL, NULL)) {
|
&w_time_ts, &m_time_ts, &size, NULL, NULL);
|
||||||
printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status));
|
||||||
correct = False;
|
correct = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2928,9 +2930,10 @@ static bool run_trans2test(int dummy)
|
|||||||
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
|
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
|
||||||
cli_write(cli, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
|
cli_write(cli, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
|
||||||
cli_close(cli, fnum);
|
cli_close(cli, fnum);
|
||||||
if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts,
|
status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts,
|
||||||
&m_time2_ts, &size, NULL, NULL)) {
|
&w_time_ts, &m_time2_ts, &size, NULL, NULL);
|
||||||
printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status));
|
||||||
correct = False;
|
correct = False;
|
||||||
} else {
|
} else {
|
||||||
if (memcmp(&m_time_ts, &m_time2_ts, sizeof(struct timespec))
|
if (memcmp(&m_time_ts, &m_time2_ts, sizeof(struct timespec))
|
||||||
@ -6408,16 +6411,9 @@ static bool run_dir_createtime(int dummy)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cli_qpathinfo2(cli,
|
status = cli_qpathinfo2(cli, dname, &create_time, NULL, NULL, NULL,
|
||||||
dname,
|
NULL, NULL, NULL);
|
||||||
&create_time,
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL)) {
|
|
||||||
status = cli_nt_error(cli);
|
|
||||||
printf("cli_qpathinfo2 returned %s\n",
|
printf("cli_qpathinfo2 returned %s\n",
|
||||||
nt_errstr(status));
|
nt_errstr(status));
|
||||||
goto out;
|
goto out;
|
||||||
@ -6433,16 +6429,9 @@ static bool run_dir_createtime(int dummy)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cli_qpathinfo2(cli,
|
status = cli_qpathinfo2(cli, dname, &create_time1, NULL, NULL, NULL,
|
||||||
dname,
|
NULL, NULL, NULL);
|
||||||
&create_time1,
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL)) {
|
|
||||||
status = cli_nt_error(cli);
|
|
||||||
printf("cli_qpathinfo2 (2) returned %s\n",
|
printf("cli_qpathinfo2 (2) returned %s\n",
|
||||||
nt_errstr(status));
|
nt_errstr(status));
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user