mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
s3: async cli_list
This commit is contained in:
@ -2070,6 +2070,8 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
|
||||
uint16_t *pfid);
|
||||
uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
|
||||
size_t str_len, size_t *pconverted_size);
|
||||
uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
|
||||
const uint8_t *bytes, size_t num_bytes);
|
||||
struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev,
|
||||
struct cli_state *cli, const char *fname,
|
||||
@ -2334,12 +2336,22 @@ bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_
|
||||
|
||||
/* The following definitions come from libsmb/clilist.c */
|
||||
|
||||
int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||
void (*fn)(const char *, struct file_info *, const char *,
|
||||
void *), void *state);
|
||||
int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||
void (*fn)(const char *, struct file_info *, const char *,
|
||||
void *), void *state);
|
||||
NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||
void (*fn)(const char *, struct file_info *,
|
||||
const char *, void *), void *state);
|
||||
NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
|
||||
uint16_t attribute, int info_level,
|
||||
void (*fn)(const char *mnt, struct file_info *finfo,
|
||||
const char *mask, void *private_data),
|
||||
void *private_data);
|
||||
struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct cli_state *cli,
|
||||
const char *mask,
|
||||
uint16_t attribute,
|
||||
uint16_t info_level);
|
||||
NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct file_info **finfo, size_t *num_finfo);
|
||||
NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||
void (*fn)(const char *, struct file_info *, const char *,
|
||||
void *), void *state);
|
||||
|
@ -91,6 +91,26 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2,
|
||||
true, pconverted_size);
|
||||
}
|
||||
|
||||
uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
|
||||
const uint8_t *bytes, size_t num_bytes)
|
||||
{
|
||||
size_t buflen;
|
||||
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
buflen = talloc_get_size(buf);
|
||||
|
||||
buf = TALLOC_REALLOC_ARRAY(NULL, buf, uint8_t,
|
||||
buflen + 1 + num_bytes);
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
buf[buflen] = prefix;
|
||||
memcpy(&buf[buflen+1], bytes, num_bytes);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
Same as smb_bytes_push_str(), but without the odd byte
|
||||
align for ucs2 (we're pushing into a param or data block).
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -263,11 +263,16 @@ static struct cli_state *connect_one(char *share)
|
||||
}
|
||||
|
||||
static char *resultp;
|
||||
static struct file_info *f_info;
|
||||
|
||||
struct rn_state {
|
||||
char **pp_long_name;
|
||||
char *short_name;
|
||||
};
|
||||
|
||||
static void listfn(const char *mnt, struct file_info *f, const char *s,
|
||||
void *state)
|
||||
void *private_data)
|
||||
{
|
||||
struct rn_state *state = (struct rn_state *)private_data;
|
||||
if (strcmp(f->name,".") == 0) {
|
||||
resultp[0] = '+';
|
||||
} else if (strcmp(f->name,"..") == 0) {
|
||||
@ -275,28 +280,38 @@ static void listfn(const char *mnt, struct file_info *f, const char *s,
|
||||
} else {
|
||||
resultp[2] = '+';
|
||||
}
|
||||
f_info = f;
|
||||
|
||||
if ((state == NULL) || ISDOT(f->name) || ISDOTDOT(f->name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fstrcpy(state->short_name, f->short_name);
|
||||
strlower_m(state->short_name);
|
||||
*state->pp_long_name = SMB_STRDUP(f->name);
|
||||
if (!*state->pp_long_name) {
|
||||
return;
|
||||
}
|
||||
strlower_m(*state->pp_long_name);
|
||||
}
|
||||
|
||||
static void get_real_name(struct cli_state *cli,
|
||||
char **pp_long_name, fstring short_name)
|
||||
{
|
||||
struct rn_state state;
|
||||
|
||||
state.pp_long_name = pp_long_name;
|
||||
state.short_name = short_name;
|
||||
|
||||
*pp_long_name = NULL;
|
||||
/* nasty hack to force level 260 listings - tridge */
|
||||
cli->capabilities |= CAP_NT_SMBS;
|
||||
if (max_protocol <= PROTOCOL_LANMAN1) {
|
||||
cli_list_new(cli, "\\masktest\\*.*", aHIDDEN | aDIR, listfn, NULL);
|
||||
cli_list_trans(cli, "\\masktest\\*.*", aHIDDEN | aDIR,
|
||||
SMB_FIND_FILE_BOTH_DIRECTORY_INFO, listfn,
|
||||
&state);
|
||||
} else {
|
||||
cli_list_new(cli, "\\masktest\\*", aHIDDEN | aDIR, listfn, NULL);
|
||||
}
|
||||
if (f_info) {
|
||||
fstrcpy(short_name, f_info->short_name);
|
||||
strlower_m(short_name);
|
||||
*pp_long_name = SMB_STRDUP(f_info->name);
|
||||
if (!*pp_long_name) {
|
||||
return;
|
||||
}
|
||||
strlower_m(*pp_long_name);
|
||||
cli_list_trans(cli, "\\masktest\\*", aHIDDEN | aDIR,
|
||||
SMB_FIND_FILE_BOTH_DIRECTORY_INFO,
|
||||
listfn, &state);
|
||||
}
|
||||
|
||||
if (*short_name == 0) {
|
||||
@ -331,12 +346,10 @@ static void testpair(struct cli_state *cli, const char *mask, const char *file)
|
||||
|
||||
resultp = res1;
|
||||
fstrcpy(short_name, "");
|
||||
f_info = NULL;
|
||||
get_real_name(cli, &long_name, short_name);
|
||||
if (!long_name) {
|
||||
return;
|
||||
}
|
||||
f_info = NULL;
|
||||
fstrcpy(res1, "---");
|
||||
cli_list(cli, mask, aHIDDEN | aDIR, listfn, NULL);
|
||||
|
||||
|
@ -5183,7 +5183,8 @@ static bool run_dirtest1(int dummy)
|
||||
}
|
||||
|
||||
/* Now ensure that doing an old list sees both files and directories. */
|
||||
num_seen = cli_list_old(cli, "\\LISTDIR\\*", aDIR, list_fn, NULL);
|
||||
num_seen = 0;
|
||||
cli_list_old(cli, "\\LISTDIR\\*", aDIR, list_fn, &num_seen);
|
||||
printf("num_seen = %d\n", num_seen );
|
||||
/* We should see 100 files + 1000 directories + . and .. */
|
||||
if (num_seen != 2002)
|
||||
@ -5192,12 +5193,14 @@ static bool run_dirtest1(int dummy)
|
||||
/* Ensure if we have the "must have" bits we only see the
|
||||
* relevent entries.
|
||||
*/
|
||||
num_seen = cli_list_old(cli, "\\LISTDIR\\*", (aDIR<<8)|aDIR, list_fn, NULL);
|
||||
num_seen = 0;
|
||||
cli_list_old(cli, "\\LISTDIR\\*", (aDIR<<8)|aDIR, list_fn, &num_seen);
|
||||
printf("num_seen = %d\n", num_seen );
|
||||
if (num_seen != 1002)
|
||||
correct = False;
|
||||
|
||||
num_seen = cli_list_old(cli, "\\LISTDIR\\*", (aARCH<<8)|aDIR, list_fn, NULL);
|
||||
num_seen = 0;
|
||||
cli_list_old(cli, "\\LISTDIR\\*", (aARCH<<8)|aDIR, list_fn, &num_seen);
|
||||
printf("num_seen = %d\n", num_seen );
|
||||
if (num_seen != 1000)
|
||||
correct = False;
|
||||
|
Reference in New Issue
Block a user