diff options
author | Volker Lendecke <vl@samba.org> | 2010-08-02 19:22:22 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-08-04 20:32:50 +0200 |
commit | 867626abcad88b84684e9d328abf51d4f410a1cb (patch) | |
tree | a15ee1aefc33c3c1278e8ab955dcb8db38ab5463 /source3/libsmb | |
parent | 2ff73f0df3257c27cb3cdae779e679de3170be17 (diff) | |
download | samba-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
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/clilist.c | 20 | ||||
-rw-r--r-- | source3/libsmb/libsmb_dir.c | 19 |
2 files changed, 25 insertions, 14 deletions
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", |