summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-04-29 14:27:45 -0700
committerJeremy Allison <jra@samba.org>2011-04-30 00:33:39 +0200
commit440d71f6c76a4363f69eaf70cada69bdcb98c7bf (patch)
tree9fddab5ade9932d099253b3453147a3b23cc9cb2 /source3/torture
parent76739435fc8abf1f47193ec4db35a567b564c785 (diff)
downloadsamba-440d71f6c76a4363f69eaf70cada69bdcb98c7bf.tar.gz
samba-440d71f6c76a4363f69eaf70cada69bdcb98c7bf.tar.bz2
samba-440d71f6c76a4363f69eaf70cada69bdcb98c7bf.zip
torture test for bug #8111 - CIFS VFS: unexpected error on SMB posix open.
Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Apr 30 00:33:40 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/torture.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 3c5de28ad5..61af2387c0 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5018,6 +5018,61 @@ static bool run_simple_posix_open_test(int dummy)
goto out;
}
+ /* Create again to test open with O_TRUNC. */
+ if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600, &fnum1))) {
+ printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Test ftruncate - set file size. */
+ if (!NT_STATUS_IS_OK(cli_ftruncate(cli1, fnum1, 1000))) {
+ printf("ftruncate failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Ensure st_size == 1000 */
+ if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) {
+ printf("stat failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ if (sbuf.st_ex_size != 1000) {
+ printf("ftruncate - stat size (%u) != 1000\n", (unsigned int)sbuf.st_ex_size);
+ goto out;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
+ printf("close(2) failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Re-open with O_TRUNC. */
+ if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_WRONLY|O_TRUNC, 0600, &fnum1))) {
+ printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
+ /* Ensure st_size == 0 */
+ if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) {
+ printf("stat failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ if (sbuf.st_ex_size != 0) {
+ printf("O_TRUNC - stat size (%u) != 0\n", (unsigned int)sbuf.st_ex_size);
+ goto out;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
+ printf("close failed (%s)\n", cli_errstr(cli1));
+ goto out;
+ }
+
+ if (!NT_STATUS_IS_OK(cli_posix_unlink(cli1, fname))) {
+ printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1));
+ goto out;
+ }
+
/* What happens when we try and POSIX open a directory ? */
if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) {
printf("POSIX open of directory %s succeeded, should have failed.\n", fname);