summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-08-02 19:22:22 +0200
committerVolker Lendecke <vl@samba.org>2010-08-04 20:32:50 +0200
commit867626abcad88b84684e9d328abf51d4f410a1cb (patch)
treea15ee1aefc33c3c1278e8ab955dcb8db38ab5463
parent2ff73f0df3257c27cb3cdae779e679de3170be17 (diff)
downloadsamba-867626abcad88b84684e9d328abf51d4f410a1cb.tar.gz
samba-867626abcad88b84684e9d328abf51d4f410a1cb.tar.bz2
samba-867626abcad88b84684e9d328abf51d4f410a1cb.zip
s3: Convert cli_list() to return NTSTATUS
If needed, the callback functions can count themselves
-rw-r--r--source3/client/client.c15
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/libgpo/gpo_filesync.c14
-rw-r--r--source3/libsmb/clilist.c20
-rw-r--r--source3/libsmb/libsmb_dir.c19
-rw-r--r--source3/torture/torture.c28
-rw-r--r--source3/utils/net_rpc.c7
7 files changed, 73 insertions, 36 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 7f804bf809..d4395818a7 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -865,10 +865,13 @@ void do_list(const char *mask,
} 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 {
@@ -4281,6 +4284,7 @@ static char **remote_completion(const char *text, int len)
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 */
@@ -4339,8 +4343,9 @@ static char **remote_completion(const char *text, int len)
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;
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4e3ec7a24f..f9684ad16e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2580,9 +2580,9 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
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 */
diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c
index 461ebb742f..d85df1f7e1 100644
--- a/source3/libgpo/gpo_filesync.c
+++ b/source3/libgpo/gpo_filesync.c
@@ -110,15 +110,15 @@ static NTSTATUS gpo_copy_dir(const char *unix_path)
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;
}
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 99dcc3f9c6..a8e3bd5017 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -677,11 +677,19 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
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;
}
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 1a1ca68a8a..6d3da1cd77 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -748,6 +748,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
*/
char *targetpath;
struct cli_state *targetcli;
+ NTSTATUS status;
/* We connect to the server and list the directory */
dir->dir_type = SMBC_FILE_SHARE;
@@ -791,10 +792,10 @@ SMBC_opendir_ctx(SMBCCTX *context,
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);
@@ -1302,6 +1303,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
/* Local storage to avoid buffer overflows */
char *lpath;
bool smbc_rmdir_dirempty = true;
+ NTSTATUS status;
lpath = talloc_asprintf(frame, "%s\\*",
targetpath);
@@ -1311,11 +1313,12 @@ SMBC_rmdir_ctx(SMBCCTX *context,
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",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index df8adbdfdf..cea7b8a4bf 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4794,7 +4794,10 @@ static bool run_openattrtest(int dummy)
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;
+ }
}
/*
@@ -4807,6 +4810,7 @@ static bool run_dirtest(int dummy)
uint16_t fnum;
struct timeval core_start;
bool correct = True;
+ int matched;
printf("starting directory test\n");
@@ -4829,9 +4833,17 @@ static bool run_dirtest(int dummy)
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));
@@ -6173,6 +6185,7 @@ static void shortname_del_fn(const char *mnt, struct file_info *finfo,
}
struct sn_state {
+ int matched;
int i;
bool val;
};
@@ -6201,6 +6214,7 @@ static void shortname_list_fn(const char *mnt, struct file_info *finfo,
__location__, finfo->short_name, finfo->name);
s->val = true;
}
+ s->matched += 1;
}
static bool run_shortname_test(int dummy)
@@ -6255,7 +6269,11 @@ 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;
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index cafab87a96..d27545d1c6 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -3452,6 +3452,7 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask)
{
struct cli_state *targetcli;
char *targetpath = NULL;
+ NTSTATUS status;
DEBUG(3,("calling cli_list with mask: %s\n", mask));
@@ -3463,9 +3464,11 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *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;
}