[SCM] Samba Shared Repository - branch v4-0-test updated -
release-4-0-0alpha3-1862-g791ce0f
Andrew Tridgell
tridge at samba.org
Tue May 27 09:11:14 GMT 2008
The branch, v4-0-test has been updated
via 791ce0fe39a9d9e0d40b9850ff6f0cc9077fe2f1 (commit)
via 318038d6f670efffa96d8b0db63f46b3752e1cd3 (commit)
via 4aeda5c11414a4a7ef44da32be05209cb5caa90c (commit)
via c15b24a2f4346b6f07e1d5fd4f2bef7cd09cf350 (commit)
from 3bec932a89006521ba74bde7943b8cd5b4a660d8 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test
- Log -----------------------------------------------------------------
commit 791ce0fe39a9d9e0d40b9850ff6f0cc9077fe2f1
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue May 27 19:10:35 2008 +1000
fixed file_attributes test
commit 318038d6f670efffa96d8b0db63f46b3752e1cd3
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue May 27 18:20:23 2008 +1000
ensure that we honor SMB2 read min_count properly
commit 4aeda5c11414a4a7ef44da32be05209cb5caa90c
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue May 27 18:20:04 2008 +1000
added a basic SMB2 read test suite
commit c15b24a2f4346b6f07e1d5fd4f2bef7cd09cf350
Author: Andrew Tridgell <tridge at samba.org>
Date: Tue May 27 18:19:22 2008 +1000
re-enable some tests
-----------------------------------------------------------------------
Summary of changes:
source/libcli/raw/interfaces.h | 2 +-
source/ntvfs/ntvfs_generic.c | 12 +---
source/ntvfs/posix/pvfs_read.c | 8 ++
source/torture/smb2/config.mk | 3 +-
source/torture/smb2/create.c | 2 +-
source/torture/smb2/lock.c | 6 +-
source/torture/smb2/read.c | 141 ++++++++++++++++++++++++++++++++++++++++
source/torture/smb2/smb2.c | 1 +
8 files changed, 158 insertions(+), 17 deletions(-)
create mode 100644 source/torture/smb2/read.c
Changeset truncated at 500 lines:
diff --git a/source/libcli/raw/interfaces.h b/source/libcli/raw/interfaces.h
index 68ebc19..17c8513 100644
--- a/source/libcli/raw/interfaces.h
+++ b/source/libcli/raw/interfaces.h
@@ -1647,7 +1647,7 @@ union smb_read {
struct {
union smb_handle file;
uint64_t offset;
- uint16_t mincnt;
+ uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */
uint32_t maxcnt;
uint16_t remaining;
bool read_for_execute;
diff --git a/source/ntvfs/ntvfs_generic.c b/source/ntvfs/ntvfs_generic.c
index 3d92c0b..06d89a7 100644
--- a/source/ntvfs/ntvfs_generic.c
+++ b/source/ntvfs/ntvfs_generic.c
@@ -1295,16 +1295,6 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs,
rd->smb2.out.data.length= rd2->generic.out.nread;
rd->smb2.out.remaining = 0;
rd->smb2.out.reserved = 0;
- if (NT_STATUS_IS_OK(status) &&
- rd->smb2.out.data.length == 0) {
- status = NT_STATUS_END_OF_FILE;
- }
- /* SMB2 does honor the min_count field, SMB does not */
- if (NT_STATUS_IS_OK(status) &&
- rd->smb2.in.min_count > rd->smb2.out.data.length) {
- rd->smb2.out.data.length = 0;
- status = NT_STATUS_END_OF_FILE;
- }
break;
default:
return NT_STATUS_INVALID_LEVEL;
@@ -1396,7 +1386,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs,
case RAW_READ_SMB2:
rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs;
rd2->readx.in.offset = rd->smb2.in.offset;
- rd2->readx.in.mincnt = rd->smb2.in.length;
+ rd2->readx.in.mincnt = rd->smb2.in.min_count;
rd2->readx.in.maxcnt = rd->smb2.in.length;
rd2->readx.in.remaining = 0;
rd2->readx.out.data = rd->smb2.out.data.data;
diff --git a/source/ntvfs/posix/pvfs_read.c b/source/ntvfs/posix/pvfs_read.c
index 418b7e0..a01a8a5 100644
--- a/source/ntvfs/posix/pvfs_read.c
+++ b/source/ntvfs/posix/pvfs_read.c
@@ -93,6 +93,14 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs,
return pvfs_map_errno(pvfs, errno);
}
+ /* only SMB2 honors mincnt */
+ if (req->ctx->protocol == PROTOCOL_SMB2) {
+ if (rd->readx.in.mincnt > ret ||
+ (ret == 0 && maxcnt > 0)) {
+ return NT_STATUS_END_OF_FILE;
+ }
+ }
+
f->handle->position = f->handle->seek_offset = rd->readx.in.offset + ret;
rd->readx.out.nread = ret;
diff --git a/source/torture/smb2/config.mk b/source/torture/smb2/config.mk
index 6c69f30..9785303 100644
--- a/source/torture/smb2/config.mk
+++ b/source/torture/smb2/config.mk
@@ -21,7 +21,8 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix $(torturesrcdir)/smb2/, \
smb2.o \
persistent_handles.o \
oplocks.o \
- create.o)
+ create.o \
+ read.o)
$(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source/torture/smb2/create.c b/source/torture/smb2/create.c
index 9f7ceb2..87a53ed 100644
--- a/source/torture/smb2/create.c
+++ b/source/torture/smb2/create.c
@@ -149,7 +149,7 @@ bool torture_smb2_create_gentest(struct torture_context *torture, struct smb2_tr
}
}
- CHECK_EQUAL(file_attributes, 0xffff87c8);
+ CHECK_EQUAL(file_attributes, 0xffffbd48);
CHECK_EQUAL(denied_mask, 0x4000);
smb2_deltree(tree, FNAME);
diff --git a/source/torture/smb2/lock.c b/source/torture/smb2/lock.c
index c708c9f..4e21045 100644
--- a/source/torture/smb2/lock.c
+++ b/source/torture/smb2/lock.c
@@ -472,9 +472,9 @@ struct torture_suite *torture_smb2_lock_init(void)
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "LOCK");
torture_suite_add_1smb2_test(suite, "VALID-REQUEST", test_valid_request);
-// torture_suite_add_1smb2_test(suite, "RW-NONE", test_lock_rw_none);
-// torture_suite_add_1smb2_test(suite, "RW-SHARED", test_lock_rw_shared);
-// torture_suite_add_1smb2_test(suite, "RW-EXCLUSIV", test_lock_rw_exclusiv);
+ torture_suite_add_1smb2_test(suite, "RW-NONE", test_lock_rw_none);
+ torture_suite_add_1smb2_test(suite, "RW-SHARED", test_lock_rw_shared);
+ torture_suite_add_1smb2_test(suite, "RW-EXCLUSIV", test_lock_rw_exclusiv);
suite->description = talloc_strdup(suite, "SMB2-LOCK tests");
diff --git a/source/torture/smb2/read.c b/source/torture/smb2/read.c
new file mode 100644
index 0000000..3e1d077
--- /dev/null
+++ b/source/torture/smb2/read.c
@@ -0,0 +1,141 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 read test suite
+
+ Copyright (C) Andrew Tridgell 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+
+#include "librpc/gen_ndr/ndr_security.h"
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ printf("(%s) Incorrect status %s - should be %s\n", \
+ __location__, nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+#define CHECK_VALUE(v, correct) do { \
+ if ((v) != (correct)) { \
+ printf("(%s) Incorrect value %s=%d - should be %d\n", \
+ __location__, #v, v, correct); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+static bool test_read(struct torture_context *torture, struct smb2_tree *tree)
+{
+ bool ret = true;
+ NTSTATUS status;
+ struct smb2_handle h;
+ uint8_t buf[70000];
+ struct smb2_read rd;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+
+ ZERO_STRUCT(buf);
+
+ status = torture_smb2_testfile(tree, "lock1.txt", &h);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(rd);
+ rd.in.file.handle = h;
+ rd.in.length = 10;
+ rd.in.offset = 0;
+ rd.in.min_count = 1;
+
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 10);
+
+ rd.in.min_count = 0;
+ rd.in.length = 10;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0;
+ rd.in.length = 0;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 0);
+
+ rd.in.min_count = 1;
+ rd.in.length = 0;
+ rd.in.offset = sizeof(buf);
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0;
+ rd.in.length = 2;
+ rd.in.offset = sizeof(buf) - 1;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VALUE(rd.out.data.length, 1);
+
+ rd.in.min_count = 2;
+ rd.in.length = 1;
+ rd.in.offset = sizeof(buf) - 1;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0x10000;
+ rd.in.length = 1;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 0x10000 - 2;
+ rd.in.length = 1;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+ rd.in.min_count = 10;
+ rd.in.length = 5;
+ rd.in.offset = 0;
+ status = smb2_read(tree, tmp_ctx, &rd);
+ CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+/* basic testing of SMB2 read
+*/
+struct torture_suite *torture_smb2_read_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "READ");
+
+ torture_suite_add_1smb2_test(suite, "READ", test_read);
+
+ suite->description = talloc_strdup(suite, "SMB2-READ tests");
+
+ return suite;
+}
+
diff --git a/source/torture/smb2/smb2.c b/source/torture/smb2/smb2.c
index 852effe..f813148 100644
--- a/source/torture/smb2/smb2.c
+++ b/source/torture/smb2/smb2.c
@@ -137,6 +137,7 @@ NTSTATUS torture_smb2_init(void)
torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
torture_suite_add_simple_test(suite, "CREATE", torture_smb2_create);
torture_suite_add_suite(suite, torture_smb2_lock_init());
+ torture_suite_add_suite(suite, torture_smb2_read_init());
torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);
torture_suite_add_1smb2_test(suite, "OPLOCK-BATCH1", torture_smb2_oplock_batch1);
--
Samba Shared Repository
More information about the samba-cvs
mailing list