diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-01 12:47:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:19:04 -0500 |
commit | e7c530a9ea47262a6a984b2318317d30c29d4aa5 (patch) | |
tree | f59e05e21f616cd66afbcd3ae0485b312002f47d /source4/torture/raw | |
parent | 6ecc79b8880237653677fcd9fa8b7f384e3a2e63 (diff) | |
download | samba-e7c530a9ea47262a6a984b2318317d30c29d4aa5.tar.gz samba-e7c530a9ea47262a6a984b2318317d30c29d4aa5.tar.bz2 samba-e7c530a9ea47262a6a984b2318317d30c29d4aa5.zip |
r8058: added testing of delete on close for files and directories
(This used to be commit 214e51b3c8021dfe31ad951603bae64fa281b0f8)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r-- | source4/torture/raw/unlink.c | 90 |
1 files changed, 87 insertions, 3 deletions
diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c index 5874da6ef7..e8808957c6 100644 --- a/source4/torture/raw/unlink.c +++ b/source4/torture/raw/unlink.c @@ -164,6 +164,91 @@ done: } +/* + test delete on close +*/ +static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +{ + struct smb_unlink io; + struct smb_rmdir dio; + NTSTATUS status; + BOOL ret = True; + int fnum; + const char *fname = BASEDIR "\\test.txt"; + const char *dname = BASEDIR "\\test.dir"; + union smb_setfileinfo sfinfo; + + if (!torture_setup_dir(cli, BASEDIR)) { + return False; + } + + dio.in.path = dname; + + io.in.pattern = fname; + io.in.attrib = 0; + status = smb_raw_unlink(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + + printf("Testing with delete_on_close 0\n"); + fnum = create_complex_file(cli, mem_ctx, fname); + + sfinfo.disposition_info.level = RAW_SFILEINFO_DISPOSITION_INFORMATION; + sfinfo.disposition_info.file.fnum = fnum; + sfinfo.disposition_info.in.delete_on_close = 0; + status = smb_raw_setfileinfo(cli->tree, &sfinfo); + CHECK_STATUS(status, NT_STATUS_OK); + + smbcli_close(cli->tree, fnum); + + status = smb_raw_unlink(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + printf("Testing with delete_on_close 1\n"); + fnum = create_complex_file(cli, mem_ctx, fname); + sfinfo.disposition_info.file.fnum = fnum; + sfinfo.disposition_info.in.delete_on_close = 1; + status = smb_raw_setfileinfo(cli->tree, &sfinfo); + CHECK_STATUS(status, NT_STATUS_OK); + + smbcli_close(cli->tree, fnum); + + status = smb_raw_unlink(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + + + printf("Testing with directory and delete_on_close 0\n"); + fnum = create_directory_handle(cli->tree, dname); + + sfinfo.disposition_info.level = RAW_SFILEINFO_DISPOSITION_INFORMATION; + sfinfo.disposition_info.file.fnum = fnum; + sfinfo.disposition_info.in.delete_on_close = 0; + status = smb_raw_setfileinfo(cli->tree, &sfinfo); + CHECK_STATUS(status, NT_STATUS_OK); + + smbcli_close(cli->tree, fnum); + + status = smb_raw_rmdir(cli->tree, &dio); + CHECK_STATUS(status, NT_STATUS_OK); + + printf("Testing with directory delete_on_close 1\n"); + fnum = create_directory_handle(cli->tree, dname); + sfinfo.disposition_info.file.fnum = fnum; + sfinfo.disposition_info.in.delete_on_close = 1; + status = smb_raw_setfileinfo(cli->tree, &sfinfo); + CHECK_STATUS(status, NT_STATUS_OK); + + smbcli_close(cli->tree, fnum); + + status = smb_raw_rmdir(cli->tree, &dio); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + +done: + smb_raw_exit(cli->session); + smbcli_deltree(cli->tree, BASEDIR); + return ret; +} + + /* basic testing of unlink calls */ @@ -179,9 +264,8 @@ BOOL torture_raw_unlink(void) mem_ctx = talloc_init("torture_raw_unlink"); - if (!test_unlink(cli, mem_ctx)) { - ret = False; - } + ret &= test_unlink(cli, mem_ctx); + ret &= test_delete_on_close(cli, mem_ctx); torture_close_connection(cli); talloc_free(mem_ctx); |