summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-11-21 13:46:52 +0100
committerVolker Lendecke <vl@samba.org>2009-11-21 14:01:56 +0100
commit37e4e387db869600b68d28d4d7b5290fe8b110ae (patch)
tree3770d817f87e7c9d7ec3dbce71d1a43a131b6884 /source3
parent5a1606269aeeeb1b777974d88c33df543d1b6f4d (diff)
downloadsamba-37e4e387db869600b68d28d4d7b5290fe8b110ae.tar.gz
s3: Convert cli_get_fs_attr_info to the async API
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/libsmb/clifsinfo.c123
-rw-r--r--source3/libsmb/libsmb_server.c4
-rw-r--r--source3/libsmb/libsmb_stat.c2
-rw-r--r--source3/torture/torture.c9
-rw-r--r--source3/utils/smbcquotas.c2
6 files changed, 102 insertions, 44 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index feeac590040..92cb99744b6 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2704,7 +2704,11 @@ NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
uint16 major, uint16 minor,
uint32 caplow, uint32 caphigh);
-bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr);
+struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli);
+NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
+NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number);
bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate);
bool cli_get_fs_full_size_info(struct cli_state *cli,
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index 3e9740d1534..ec690b4d823 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -248,58 +248,103 @@ fail:
return status;
}
-bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr)
-{
- bool ret = False;
- uint16 setup;
- char param[2];
- char *rparam=NULL, *rdata=NULL;
- unsigned int rparam_count=0, rdata_count=0;
-
- if (!cli||!fs_attr)
- smb_panic("cli_get_fs_attr_info() called with NULL Pionter!");
+struct cli_get_fs_attr_info_state {
+ uint16_t setup[1];
+ uint8_t param[2];
+ uint32_t fs_attr;
+};
- setup = TRANSACT2_QFSINFO;
+static void cli_get_fs_attr_info_done(struct tevent_req *subreq);
- SSVAL(param,0,SMB_QUERY_FS_ATTRIBUTE_INFO);
+struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli)
+{
+ struct tevent_req *subreq, *req;
+ struct cli_get_fs_attr_info_state *state;
- if (!cli_send_trans(cli, SMBtrans2,
- NULL,
- 0, 0,
- &setup, 1, 0,
- param, 2, 0,
- NULL, 0, 560)) {
- goto cleanup;
+ req = tevent_req_create(mem_ctx, &state,
+ struct cli_get_fs_attr_info_state);
+ if (req == NULL) {
+ return NULL;
}
+ SSVAL(state->setup+0, 0, TRANSACT2_QFSINFO);
+ SSVAL(state->param+0, 0, SMB_QUERY_FS_ATTRIBUTE_INFO);
- if (!cli_receive_trans(cli, SMBtrans2,
- &rparam, &rparam_count,
- &rdata, &rdata_count)) {
- goto cleanup;
+ subreq = cli_trans_send(state, ev, cli, SMBtrans2,
+ NULL, 0, 0, 0,
+ state->setup, 1, 0,
+ state->param, 2, 0,
+ NULL, 0, 560);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
+ tevent_req_set_callback(subreq, cli_get_fs_attr_info_done, req);
+ return req;
+}
- if (cli_is_error(cli)) {
- ret = False;
- goto cleanup;
- } else {
- ret = True;
- }
+static void cli_get_fs_attr_info_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct cli_get_fs_attr_info_state *state = tevent_req_data(
+ req, struct cli_get_fs_attr_info_state);
+ uint8_t *data;
+ uint32_t num_data;
+ NTSTATUS status;
- if (rdata_count < 12) {
- goto cleanup;
+ status = cli_trans_recv(subreq, talloc_tos(), NULL, 0, NULL,
+ NULL, 0, NULL, &data, 12, &num_data);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
}
+ state->fs_attr = IVAL(data, 0);
+ TALLOC_FREE(data);
+ tevent_req_done(req);
+}
- *fs_attr = IVAL(rdata,0);
+NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr)
+{
+ struct cli_get_fs_attr_info_state *state = tevent_req_data(
+ req, struct cli_get_fs_attr_info_state);
+ NTSTATUS status;
- /* todo: but not yet needed
- * return the other stuff
- */
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
+ }
+ *fs_attr = state->fs_attr;
+ return NT_STATUS_OK;
+}
-cleanup:
- SAFE_FREE(rparam);
- SAFE_FREE(rdata);
+NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr)
+{
+ struct tevent_context *ev;
+ struct tevent_req *req;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
- return ret;
+ if (cli_has_async_calls(cli)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ ev = tevent_context_init(talloc_tos());
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_get_fs_attr_info_send(ev, ev, cli);
+ if (req == NULL) {
+ goto fail;
+ }
+ if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+ goto fail;
+ }
+ status = cli_get_fs_attr_info_recv(req, fs_attr);
+fail:
+ TALLOC_FREE(ev);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_set_error(cli, status);
+ }
+ return status;
}
bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number)
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index a572acde960..71cb67c61ba 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -330,7 +330,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
if (is_ipc) {
DEBUG(4,
("IPC$ so ignore case sensitivity\n"));
- } else if (!cli_get_fs_attr_info(c, &fs_attrs)) {
+ } else if (!NT_STATUS_IS_OK(cli_get_fs_attr_info(c, &fs_attrs))) {
DEBUG(4, ("Could not retrieve "
"case sensitivity flag: %s.\n",
cli_errstr(c)));
@@ -563,7 +563,7 @@ again:
/* Determine if this share supports case sensitivity */
if (is_ipc) {
DEBUG(4, ("IPC$ so ignore case sensitivity\n"));
- } else if (!cli_get_fs_attr_info(c, &fs_attrs)) {
+ } else if (!NT_STATUS_IS_OK(cli_get_fs_attr_info(c, &fs_attrs))) {
DEBUG(4, ("Could not retrieve case sensitivity flag: %s.\n",
cli_errstr(c)));
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index 4349b0a7009..95c5c52d6e4 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -454,7 +454,7 @@ SMBC_fstatvfs_ctx(SMBCCTX *context,
}
/* See if the share is case sensitive */
- if (!cli_get_fs_attr_info(cli, &fs_attrs)) {
+ if (!NT_STATUS_IS_OK(cli_get_fs_attr_info(cli, &fs_attrs))) {
/*
* We can't determine the case sensitivity of
* the share. We have no choice but to use the
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 840dc942565..bf89ca35b1c 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -2827,6 +2827,8 @@ static bool run_trans2test(int dummy)
const char *fname2 = "\\trans2\\trans2.tst";
char pname[1024];
bool correct = True;
+ NTSTATUS status;
+ uint32_t fs_attr;
printf("starting trans2 test\n");
@@ -2834,6 +2836,13 @@ static bool run_trans2test(int dummy)
return False;
}
+ status = cli_get_fs_attr_info(cli, &fs_attr);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("ERROR: cli_get_fs_attr_info returned %s\n",
+ nt_errstr(status));
+ correct = false;
+ }
+
cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
cli_open(cli, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c
index a0eed65be36..ef67ad77b42 100644
--- a/source3/utils/smbcquotas.c
+++ b/source3/utils/smbcquotas.c
@@ -235,7 +235,7 @@ static int do_quota(struct cli_state *cli,
SMB_NTQUOTA_STRUCT qt;
ZERO_STRUCT(qt);
- if (!cli_get_fs_attr_info(cli, &fs_attrs)) {
+ if (!NT_STATUS_IS_OK(cli_get_fs_attr_info(cli, &fs_attrs))) {
d_printf("Failed to get the filesystem attributes %s.\n",
cli_errstr(cli));
return -1;