} else {
/* check for dfs */
if (cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetpath)) {
- if (cli_list(targetcli, targetpath, attribute,
- do_list_helper, targetcli) == -1) {
+ NTSTATUS status;
+
+ status = cli_list(targetcli, targetpath, attribute,
+ do_list_helper, targetcli);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("%s listing %s\n",
- cli_errstr(targetcli), targetpath);
+ nt_errstr(status), targetpath);
}
TALLOC_FREE(targetpath);
} else {
struct cli_state *targetcli = NULL;
int i;
struct completion_remote info = { NULL, NULL, 1, 0, NULL, 0 };
+ NTSTATUS status;
/* can't have non-static initialisation on Sun CC, so do it
at run time here */
if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
goto cleanup;
}
- if (cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
- completion_remote_filter, (void *)&info) < 0) {
+ status = cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
+ completion_remote_filter, (void *)&info);
+ if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
}
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);
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
- void (*fn)(const char *, struct file_info *, const char *,
- void *), void *state);
+NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+ void (*fn)(const char *, struct file_info *, const char *,
+ void *), void *state);
/* The following definitions come from libsmb/climessage.c */
static bool gpo_sync_files(struct sync_context *ctx)
{
+ NTSTATUS status;
+
DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask));
- if (cli_list(ctx->cli,
- ctx->mask,
- ctx->attribute,
- gpo_sync_func,
- ctx) == -1) {
- DEBUG(1,("listing [%s] failed with error: %s\n",
- ctx->mask, cli_errstr(ctx->cli)));
+ status = cli_list(ctx->cli, ctx->mask, ctx->attribute, gpo_sync_func,
+ ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("listing [%s] failed with error: %s\n",
+ ctx->mask, nt_errstr(status)));
return false;
}
This auto-switches between old and new style.
****************************************************************************/
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
- void (*fn)(const char *, struct file_info *, const char *,
- void *), void *state)
+NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+ void (*fn)(const char *, struct file_info *, const char *,
+ void *), void *state)
{
- if (cli->protocol <= PROTOCOL_LANMAN1)
- return cli_list_old(cli, Mask, attribute, fn, state);
- return cli_list_new(cli, Mask, attribute, fn, state);
+ int rec;
+
+ if (cli->protocol <= PROTOCOL_LANMAN1) {
+ rec = cli_list_old(cli, Mask, attribute, fn, state);
+ } else {
+ rec = cli_list_new(cli, Mask, attribute, fn, state);
+ }
+ if (rec == -1) {
+ return cli_nt_error(cli);
+ }
+ return NT_STATUS_OK;
}
*/
char *targetpath;
struct cli_state *targetcli;
+ NTSTATUS status;
/* We connect to the server and list the directory */
dir->dir_type = SMBC_FILE_SHARE;
return NULL;
}
- if (cli_list(targetcli, targetpath,
- aDIR | aSYSTEM | aHIDDEN,
- dir_list_fn, (void *)dir) < 0) {
-
+ status = cli_list(targetcli, targetpath,
+ aDIR | aSYSTEM | aHIDDEN,
+ dir_list_fn, (void *)dir);
+ if (!NT_STATUS_IS_OK(status)) {
if (dir) {
SAFE_FREE(dir->fname);
SAFE_FREE(dir);
/* Local storage to avoid buffer overflows */
char *lpath;
bool smbc_rmdir_dirempty = true;
+ NTSTATUS status;
lpath = talloc_asprintf(frame, "%s\\*",
targetpath);
return -1;
}
- if (cli_list(targetcli, lpath,
- aDIR | aSYSTEM | aHIDDEN,
- rmdir_list_fn,
- &smbc_rmdir_dirempty) < 0) {
+ status = cli_list(targetcli, lpath,
+ aDIR | aSYSTEM | aHIDDEN,
+ rmdir_list_fn,
+ &smbc_rmdir_dirempty);
+ if (!NT_STATUS_IS_OK(status)) {
/* Fix errno to ignore latest error ... */
DEBUG(5, ("smbc_rmdir: "
"cli_list returned an error: %d\n",
static void list_fn(const char *mnt, struct file_info *finfo,
const char *name, void *state)
{
-
+ int *matched = (int *)state;
+ if (matched != NULL) {
+ *matched += 1;
+ }
}
/*
uint16_t fnum;
struct timeval core_start;
bool correct = True;
+ int matched;
printf("starting directory test\n");
core_start = timeval_current();
- printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL));
+ matched = 0;
+ cli_list(cli, "a*.*", 0, list_fn, &matched);
+ printf("Matched %d\n", matched);
+
+ matched = 0;
+ cli_list(cli, "b*.*", 0, list_fn, &matched);
+ printf("Matched %d\n", matched);
+
+ matched = 0;
+ cli_list(cli, "xyzabc", 0, list_fn, &matched);
+ printf("Matched %d\n", matched);
printf("dirtest core %g seconds\n", timeval_elapsed(&core_start));
}
struct sn_state {
+ int matched;
int i;
bool val;
};
__location__, finfo->short_name, finfo->name);
s->val = true;
}
+ s->matched += 1;
}
static bool run_shortname_test(int dummy)
goto out;
}
cli_close(cli, fnum);
- if (cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn, &s) != 1) {
+
+ s.matched = 0;
+ cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn,
+ &s);
+ if (s.matched != 1) {
d_printf("(%s) failed to list %s: %s\n",
__location__, fname, cli_errstr(cli));
correct = false;
{
struct cli_state *targetcli;
char *targetpath = NULL;
+ NTSTATUS status;
DEBUG(3,("calling cli_list with mask: %s\n", mask));
return false;
}
- if (cli_list(targetcli, targetpath, cp_clistate->attribute, copy_fn, cp_clistate) == -1) {
+ status = cli_list(targetcli, targetpath, cp_clistate->attribute,
+ copy_fn, cp_clistate);
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("listing %s failed with error: %s\n"),
- mask, cli_errstr(targetcli));
+ mask, nt_errstr(status));
return false;
}