[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1320-g370e720

Jeremy Allison jra at samba.org
Thu Apr 30 01:26:51 GMT 2009


The branch, master has been updated
       via  370e7209dbafce147a5e9f283d9dcc53c72bce99 (commit)
      from  edd25980b03c5fac154967e51705ac1cdb8d4091 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 370e7209dbafce147a5e9f283d9dcc53c72bce99
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 29 18:26:02 2009 -0700

    Make cli_unlink async.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source3/client/client.c       |    4 +-
 source3/include/proto.h       |    9 ++-
 source3/libsmb/clifile.c      |  117 +++++++++++++++++++++------
 source3/libsmb/libsmb_dir.c   |    4 +-
 source3/torture/denytest.c    |    8 +-
 source3/torture/locktest.c    |    2 +-
 source3/torture/locktest2.c   |    2 +-
 source3/torture/mangle_test.c |   10 +-
 source3/torture/masktest.c    |    4 +-
 source3/torture/nbio.c        |    2 +-
 source3/torture/scanner.c     |    4 +-
 source3/torture/torture.c     |  176 ++++++++++++++++++++--------------------
 source3/torture/utable.c      |    8 +-
 13 files changed, 210 insertions(+), 140 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index 0271b45..7dda981 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -2115,7 +2115,7 @@ static void do_del(file_info *finfo, const char *dir)
 		return;
 	}
 
-	if (!cli_unlink(finfo->cli, mask)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(finfo->cli, mask, aSYSTEM | aHIDDEN))) {
 		d_printf("%s deleting remote file %s\n",
 				cli_errstr(finfo->cli),mask);
 	}
@@ -2191,7 +2191,7 @@ static int cmd_wdel(void)
 		return 1;
 	}
 
-	if (!cli_unlink_full(targetcli, targetname, attribute)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(targetcli, targetname, attribute))) {
 		d_printf("%s deleting remote files %s\n",cli_errstr(targetcli),targetname);
 	}
 	return 0;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 962215b..11fd45e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2355,8 +2355,13 @@ struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
 NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
 NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
 
-bool cli_unlink_full(struct cli_state *cli, const char *fname, uint16_t attrs);
-bool cli_unlink(struct cli_state *cli, const char *fname);
+struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev,
+                                struct cli_state *cli,
+                                const char *fname,
+                                uint16_t mayhave_attrs);
+NTSTATUS cli_unlink_recv(struct tevent_req *req);
+NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
 
 struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
 				  struct event_context *ev,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index e055a88..54c5947 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -756,46 +756,111 @@ NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const cha
  Delete a file.
 ****************************************************************************/
 
-bool cli_unlink_full(struct cli_state *cli, const char *fname, uint16_t attrs)
-{
-	char *p;
+static void cli_unlink_done(struct tevent_req *subreq);
 
-	memset(cli->outbuf,'\0',smb_size);
-	memset(cli->inbuf,'\0',smb_size);
+struct cli_unlink_state {
+	uint16_t vwv[1];
+};
 
-	cli_set_message(cli->outbuf,1, 0, true);
+struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
+				struct event_context *ev,
+				struct cli_state *cli,
+				const char *fname,
+				uint16_t mayhave_attrs)
+{
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct cli_unlink_state *state = NULL;
+	uint8_t additional_flags = 0;
+	uint8_t *bytes = NULL;
 
-	SCVAL(cli->outbuf,smb_com,SMBunlink);
-	SSVAL(cli->outbuf,smb_tid,cli->cnum);
-	cli_setup_packet(cli);
+	req = tevent_req_create(mem_ctx, &state, struct cli_unlink_state);
+	if (req == NULL) {
+		return NULL;
+	}
 
-	SSVAL(cli->outbuf,smb_vwv0, attrs);
+	SSVAL(state->vwv+0, 0, mayhave_attrs);
 
-	p = smb_buf(cli->outbuf);
-	*p++ = 4;
-	p += clistr_push(cli, p, fname,
-			cli->bufsize - PTR_DIFF(p,cli->outbuf), STR_TERMINATE);
+	bytes = talloc_array(state, uint8_t, 1);
+	if (tevent_req_nomem(bytes, req)) {
+		return tevent_req_post(req, ev);
+	}
+	bytes[0] = 4;
+	bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), fname,
+				   strlen(fname)+1, NULL);
 
-	cli_setup_bcc(cli, p);
-	cli_send_smb(cli);
-	if (!cli_receive_smb(cli)) {
-		return false;
+	if (tevent_req_nomem(bytes, req)) {
+		return tevent_req_post(req, ev);
 	}
 
-	if (cli_is_error(cli)) {
-		return false;
+	subreq = cli_smb_send(state, ev, cli, SMBunlink, additional_flags,
+				1, state->vwv, talloc_get_size(bytes), bytes);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
 	}
+	tevent_req_set_callback(subreq, cli_unlink_done, req);
+	return req;
+}
 
-	return true;
+static void cli_unlink_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	NTSTATUS status;
+
+	status = cli_smb_recv(subreq, 0, NULL, NULL, NULL, NULL);
+	TALLOC_FREE(subreq);
+	if (!NT_STATUS_IS_OK(status)) {
+		tevent_req_nterror(req, status);
+		return;
+	}
+	tevent_req_done(req);
 }
 
-/****************************************************************************
- Delete a file.
-****************************************************************************/
+NTSTATUS cli_unlink_recv(struct tevent_req *req)
+{
+	return tevent_req_simple_recv_ntstatus(req);
+}
 
-bool cli_unlink(struct cli_state *cli, const char *fname)
+NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs)
 {
-	return cli_unlink_full(cli, fname, aSYSTEM | aHIDDEN);
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct event_context *ev;
+	struct tevent_req *req;
+	NTSTATUS status = NT_STATUS_OK;
+
+	if (cli_has_async_calls(cli)) {
+		/*
+		 * Can't use sync call while an async call is in flight
+		 */
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
+	}
+
+	ev = event_context_init(frame);
+	if (ev == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	req = cli_unlink_send(frame, ev, cli, fname, mayhave_attrs);
+	if (req == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	if (!tevent_req_poll(req, ev)) {
+		status = map_nt_error_from_unix(errno);
+		goto fail;
+	}
+
+	status = cli_unlink_recv(req);
+
+ fail:
+	TALLOC_FREE(frame);
+	if (!NT_STATUS_IS_OK(status)) {
+		cli_set_error(cli, status);
+	}
+	return status;
 }
 
 /****************************************************************************
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index bc5e35f..d230275 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -1760,7 +1760,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
 	}
 	/*d_printf(">>>unlink: resolved path as %s\n", targetpath);*/
 
-	if (!cli_unlink(targetcli, targetpath)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(targetcli, targetpath, aSYSTEM | aHIDDEN))) {
 
 		errno = SMBC_errno(context, targetcli);
 
@@ -1966,7 +1966,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
 		int eno = SMBC_errno(ocontext, targetcli1);
 
 		if (eno != EEXIST ||
-		    !cli_unlink(targetcli1, targetpath2) ||
+		    !NT_STATUS_IS_OK(cli_unlink(targetcli1, targetpath2, aSYSTEM | aHIDDEN)) ||
 		    !NT_STATUS_IS_OK(cli_rename(targetcli1, targetpath1, targetpath2))) {
 
 			errno = eno;
diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c
index 9b08552..cbcbf32 100644
--- a/source3/torture/denytest.c
+++ b/source3/torture/denytest.c
@@ -1418,7 +1418,7 @@ bool torture_denytest1(int dummy)
 	printf("starting denytest1\n");
 
 	for (i=0;i<2;i++) {
-		cli_unlink(cli1, fnames[i]);
+		cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
 		fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
 		cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
 		cli_close(cli1, fnum1);
@@ -1474,7 +1474,7 @@ bool torture_denytest1(int dummy)
 	}
 
 	for (i=0;i<2;i++) {
-		cli_unlink(cli1, fnames[i]);
+		cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
 	}
 		
 	if (!torture_close_connection(cli1)) {
@@ -1504,7 +1504,7 @@ bool torture_denytest2(int dummy)
 	printf("starting denytest2\n");
 
 	for (i=0;i<2;i++) {
-		cli_unlink(cli1, fnames[i]);
+		cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
 		fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
 		cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
 		cli_close(cli1, fnum1);
@@ -1558,7 +1558,7 @@ bool torture_denytest2(int dummy)
 	}
 		
 	for (i=0;i<2;i++) {
-		cli_unlink(cli1, fnames[i]);
+		cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
 	}
 
 	if (!torture_close_connection(cli1)) {
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index 4e8dcdd..67c9516 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -398,7 +398,7 @@ static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
 		}
 	}
 	for (server=0;server<NSERVERS;server++) {
-		cli_unlink(cli[server][0], FILENAME);
+		cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
 	}
 }
 
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index 68e1843..10e2cbe 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -317,7 +317,7 @@ static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
 		}
 	}
 	for (server=0;server<NSERVERS;server++) {
-		cli_unlink(cli[server][0], FILENAME);
+		cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
 	}
 }
 
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index 81bdbce..e446894 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/torture/mangle_test.c
@@ -56,7 +56,7 @@ static bool test_one(struct cli_state *cli, const char *name)
 	}
 
 	fstr_sprintf(name2, "\\mangle_test\\%s", shortname);
-	if (!cli_unlink(cli, name2)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(cli, name2, aSYSTEM | aHIDDEN))) {
 		printf("unlink of %s  (%s) failed (%s)\n", 
 		       name2, name, cli_errstr(cli));
 		return False;
@@ -74,11 +74,11 @@ static bool test_one(struct cli_state *cli, const char *name)
 	}
 
 	/* and unlink by long name */
-	if (!cli_unlink(cli, name)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(cli, name, aSYSTEM | aHIDDEN))) {
 		printf("unlink2 of %s  (%s) failed (%s)\n", 
 		       name, name2, cli_errstr(cli));
 		failures++;
-		cli_unlink(cli, name2);
+		cli_unlink(cli, name2, aSYSTEM | aHIDDEN);
 		return True;
 	}
 
@@ -177,7 +177,7 @@ bool torture_mangle(int dummy)
 		return False;
 	}
 
-	cli_unlink(cli, "\\mangle_test\\*");
+	cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);
 	cli_rmdir(cli, "\\mangle_test");
 
 	if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\mangle_test"))) {
@@ -201,7 +201,7 @@ bool torture_mangle(int dummy)
 		}
 	}
 
-	cli_unlink(cli, "\\mangle_test\\*");
+	cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);
 	if (!NT_STATUS_IS_OK(cli_rmdir(cli, "\\mangle_test"))) {
 		printf("ERROR: Failed to remove directory\n");
 		return False;
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index fb562c8..e80f9cd 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -350,7 +350,7 @@ static void testpair(struct cli_state *cli, const char *mask, const char *file)
 		if (die_on_error) exit(1);
 	}
 
-	cli_unlink(cli, file);
+	cli_unlink(cli, file, aSYSTEM | aHIDDEN);
 
 	if (count % 100 == 0) DEBUG(0,("%d\n", count));
 	SAFE_FREE(long_name);
@@ -367,7 +367,7 @@ static void test_mask(int argc, char *argv[],
 
 	cli_mkdir(cli, "\\masktest");
 
-	cli_unlink(cli, "\\masktest\\*");
+	cli_unlink(cli, "\\masktest\\*", aSYSTEM | aHIDDEN);
 
 	if (argc >= 2) {
 		while (argc >= 2) {
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index 7503e59..1542a8f 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -128,7 +128,7 @@ void nb_setup(struct cli_state *cli)
 
 void nb_unlink(const char *fname)
 {
-	if (!cli_unlink(c, fname)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
 #if NBDEBUG
 		printf("(%d) unlink %s failed (%s)\n", 
 		       line_count, fname, cli_errstr(c));
diff --git a/source3/torture/scanner.c b/source3/torture/scanner.c
index 21b32dc..3e9a24f 100644
--- a/source3/torture/scanner.c
+++ b/source3/torture/scanner.c
@@ -170,7 +170,7 @@ static bool scan_trans2(struct cli_state *cli, int op, int level,
 
 	status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len, 
 				&rparam_len, &rdata_len);
-	cli_unlink(cli, "\\newfile.dat");
+	cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);
 	cli_rmdir(cli, "\\newfile.dat");
 	if (NT_STATUS_IS_OK(status)) return True;
 
@@ -372,7 +372,7 @@ static bool scan_nttrans(struct cli_state *cli, int op, int level,
 
 	status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len, 
 				&rparam_len, &rdata_len);
-	cli_unlink(cli, "\\newfile.dat");
+	cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);
 	cli_rmdir(cli, "\\newfile.dat");
 	if (NT_STATUS_IS_OK(status)) return True;
 
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 238a2f3..1f9d5db 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -487,7 +487,7 @@ static bool rw_torture(struct cli_state *c)
 			correct = False;
 		}
 
-		if (!cli_unlink(c, fname)) {
+		if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
 			printf("unlink failed (%s)\n", cli_errstr(c));
 			correct = False;
 		}
@@ -499,7 +499,7 @@ static bool rw_torture(struct cli_state *c)
 	}
 
 	cli_close(c, fnum2);
-	cli_unlink(c, lockfname);
+	cli_unlink(c, lockfname, aSYSTEM | aHIDDEN);
 
 	printf("%d\n", i);
 
@@ -634,7 +634,7 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
 	bool correct = True;
 	ssize_t bytes_read;
 
-	if (!cli_unlink(c1, lockfname)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {
 		printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c1));
 	}
 
@@ -694,7 +694,7 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
 		correct = False;
 	}
 
-	if (!cli_unlink(c1, lockfname)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {
 		printf("unlink failed (%s)\n", cli_errstr(c1));
 		correct = False;
 	}
@@ -772,7 +772,7 @@ static bool run_readwritelarge(int dummy)
 
 	printf("starting readwritelarge\n");
 
-	cli_unlink(cli1, lockfname);
+	cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN);
 
 	fnum1 = cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE);
 	if (fnum1 == -1) {
@@ -801,7 +801,7 @@ static bool run_readwritelarge(int dummy)
 		correct = False;
 	}
 
-	if (!cli_unlink(cli1, lockfname)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN))) {
 		printf("unlink failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 	}
@@ -1002,7 +1002,7 @@ static bool run_locktest1(int dummy)
 
 	printf("starting locktest1\n");
 
-	cli_unlink(cli1, fname);
+	cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
 
 	fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
 	if (fnum1 == -1) {
@@ -1077,7 +1077,7 @@ static bool run_locktest1(int dummy)
 		return False;
 	}
 
-	if (!cli_unlink(cli1, fname)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
 		printf("unlink failed (%s)\n", cli_errstr(cli1));
 		return False;
 	}
@@ -1119,7 +1119,7 @@ static bool run_tcon_test(int dummy)
 
 	printf("starting tcontest\n");
 
-	cli_unlink(cli, fname);
+	cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
 
 	fnum1 = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
 	if (fnum1 == -1) {
@@ -1378,7 +1378,7 @@ static bool run_locktest2(int dummy)
 
 	printf("starting locktest2\n");
 
-	cli_unlink(cli, fname);
+	cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
 
 	cli_setpid(cli, 1);
 
@@ -1517,7 +1517,7 @@ static bool run_locktest3(int dummy)
 
 	printf("starting locktest3\n");
 
-	cli_unlink(cli1, fname);
+	cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
 
 	fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
 	if (fnum1 == -1) {
@@ -1599,7 +1599,7 @@ static bool run_locktest3(int dummy)
 		return False;
 	}
 
-	if (!cli_unlink(cli1, fname)) {
+	if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
 		printf("unlink failed (%s)\n", cli_errstr(cli1));
 		return False;
 	}
@@ -1642,7 +1642,7 @@ static bool run_locktest4(int dummy)
 
 	printf("starting locktest4\n");
 
-	cli_unlink(cli1, fname);
+	cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
 
 	fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
 	fnum2 = cli_open(cli2, fname, O_RDWR, DENY_NONE);
@@ -1784,7 +1784,7 @@ static bool run_locktest4(int dummy)
  fail:
 	cli_close(cli1, fnum1);
 	cli_close(cli2, fnum2);
-	cli_unlink(cli1, fname);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list