diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-08-13 20:19:23 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-08-13 20:19:23 +0000 |
commit | 0908c05b5c5f7da2c0d8494933eb28e90be66579 (patch) | |
tree | 2aa78ff9888678f83616f2bbb49f1c5f691651b8 /source4/torture/raw | |
parent | 786d9dfe55219fd60c27996808eee3030a3fc37b (diff) | |
download | samba-0908c05b5c5f7da2c0d8494933eb28e90be66579.tar.gz samba-0908c05b5c5f7da2c0d8494933eb28e90be66579.tar.bz2 samba-0908c05b5c5f7da2c0d8494933eb28e90be66579.zip |
- expanded the ntrename test
- expanded seek test - the position information is handle specific!
(This used to be commit 163970bda6dba4a6c98943eee49d6610a156c070)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r-- | source4/torture/raw/rename.c | 53 | ||||
-rw-r--r-- | source4/torture/raw/seek.c | 33 |
2 files changed, 81 insertions, 5 deletions
diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 0e411299d0..1766511ee6 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -133,7 +133,7 @@ static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx) union smb_rename io; NTSTATUS status; BOOL ret = True; - int fnum; + int fnum, i; const char *fname1 = BASEDIR "\\test1.txt"; const char *fname2 = BASEDIR "\\test2.txt"; union smb_fileinfo finfo; @@ -154,7 +154,7 @@ static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx) io.ntrename.in.old_name = fname1; io.ntrename.in.new_name = fname2; io.ntrename.in.attrib = 0; - io.ntrename.in.root_fid = 0; + io.ntrename.in.unknown = 0; io.ntrename.in.flags = RENAME_FLAG_RENAME; status = smb_raw_rename(cli->tree, &io); @@ -275,6 +275,55 @@ static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx) io.ntrename.in.flags = 0x106; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); + + printf("Checking unknown field\n"); + io.ntrename.in.old_name = fname1; + io.ntrename.in.new_name = fname2; + io.ntrename.in.attrib = 0; + io.ntrename.in.flags = RENAME_FLAG_RENAME; + io.ntrename.in.unknown = 0xff; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + fnum = create_directory_handle(cli, BASEDIR "\\testdir"); + printf("Trying flags 0x102 fnum=%d\n", fnum); + + io.ntrename.in.old_name = fname2; + io.ntrename.in.new_name = fname1; + io.ntrename.in.attrib = 0; + io.ntrename.in.flags = 0x102; + io.ntrename.in.unknown = fnum; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); + + for (i=0;i<32;i++) { + io.ntrename.in.unknown = (1<<i); + status = smb_raw_rename(cli->tree, &io); + if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { + printf("i=0x%x status=%s\n", i, nt_errstr(status)); + } + CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER); + } + + printf("Checking other flags\n"); + + for (i=0;i<0xFFF;i++) { + if (i == RENAME_FLAG_RENAME || + i == RENAME_FLAG_HARD_LINK || + i == RENAME_FLAG_COPY) { + continue; + } + + io.ntrename.in.old_name = fname2; + io.ntrename.in.new_name = fname1; + io.ntrename.in.flags = i; + io.ntrename.in.attrib = 0; + io.ntrename.in.unknown = 0; + status = smb_raw_rename(cli->tree, &io); + if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("flags=0x%x status=%s\n", i, nt_errstr(status)); + } + } done: smb_raw_exit(cli->session); diff --git a/source4/torture/raw/seek.c b/source4/torture/raw/seek.c index 9379b676ab..a0980a7aea 100644 --- a/source4/torture/raw/seek.c +++ b/source4/torture/raw/seek.c @@ -31,7 +31,7 @@ #define CHECK_VALUE(v, correct) do { \ if ((v) != (correct)) { \ printf("(%d) Incorrect value %s=%d - should be %d\n", \ - __LINE__, #v, v, correct); \ + __LINE__, #v, (int)v, (int)correct); \ ret = False; \ goto done; \ }} while (0) @@ -45,9 +45,10 @@ static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx) { struct smb_seek io; union smb_fileinfo finfo; + union smb_setfileinfo sfinfo; NTSTATUS status; BOOL ret = True; - int fnum; + int fnum, fnum2; const char *fname = BASEDIR "\\test.txt"; if (cli_deltree(cli, BASEDIR) == -1 || @@ -56,7 +57,7 @@ static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx) return False; } - fnum = create_complex_file(cli, mem_ctx, fname); + fnum = cli_open(cli, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE); if (fnum == -1) { printf("Failed to open test.txt - %s\n", cli_errstr(cli)); ret = False; @@ -120,6 +121,32 @@ static BOOL test_seek(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.out.offset, 999); + printf("Testing position information\n"); + fnum2 = cli_open(cli, fname, O_RDWR, DENY_NONE); + if (fnum2 == -1) { + printf("2nd open failed - %s\n", cli_errstr(cli)); + ret = False; + goto done; + } + sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION; + sfinfo.position_information.file.fnum = fnum2; + sfinfo.position_information.in.position = 25; + status = smb_raw_setfileinfo(cli->tree, &sfinfo); + CHECK_STATUS(status, NT_STATUS_OK); + + finfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; + finfo.position_information.in.fnum = fnum2; + status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.position_information.out.position, 25); + + finfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION; + finfo.position_information.in.fnum = fnum; + status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.position_information.out.position, 0); + + done: smb_raw_exit(cli->session); cli_deltree(cli, BASEDIR); |