diff options
author | Tim Potter <tpot@samba.org> | 2004-02-08 00:51:07 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2004-02-08 00:51:07 +0000 |
commit | 4639eb5a58f8c0906afdc8e8f8f67f82e9547f75 (patch) | |
tree | 2115d25166961cea7d49836d53a05e98c796ff8a /source4/torture/raw/open.c | |
parent | f0c9a54b30cfa627b4ddcbc24fe943b21472df34 (diff) | |
download | samba-4639eb5a58f8c0906afdc8e8f8f67f82e9547f75.tar.gz samba-4639eb5a58f8c0906afdc8e8f8f67f82e9547f75.tar.bz2 samba-4639eb5a58f8c0906afdc8e8f8f67f82e9547f75.zip |
Convert libcli routines to use cli_tree instead of cli_state. Port
smbtorture to use the new interface.
Part 2 will be to eliminate cli_state from smbtorture as this is now
the only place where it is used.
(This used to be commit db1cc96af62ea42837d60592877fc3f93cef143b)
Diffstat (limited to 'source4/torture/raw/open.c')
-rw-r--r-- | source4/torture/raw/open.c | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c index 3e28322f37..567940b2e8 100644 --- a/source4/torture/raw/open.c +++ b/source4/torture/raw/open.c @@ -28,11 +28,11 @@ enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR}; /* check if a open file can be read/written */ -static enum rdwr_mode check_rdwr(struct cli_state *cli, int fnum) +static enum rdwr_mode check_rdwr(struct cli_tree *tree, int fnum) { char c = 1; - BOOL can_read = (cli_read(cli, fnum, &c, 0, 1) == 1); - BOOL can_write = (cli_write(cli, fnum, 0, &c, 0, 1) == 1); + BOOL can_read = (cli_read(tree, fnum, &c, 0, 1) == 1); + BOOL can_write = (cli_write(tree, fnum, 0, &c, 0, 1) == 1); if ( can_read && can_write) return RDWR_RDWR; if ( can_read && !can_write) return RDWR_RDONLY; if (!can_read && can_write) return RDWR_WRONLY; @@ -64,13 +64,13 @@ static const char *rdwr_string(enum rdwr_mode m) #define CREATE_FILE do { \ fnum = create_complex_file(cli, mem_ctx, fname); \ if (fnum == -1) { \ - printf("(%d) Failed to create %s - %s\n", __LINE__, fname, cli_errstr(cli)); \ + printf("(%d) Failed to create %s - %s\n", __LINE__, fname, cli_errstr(cli->tree)); \ ret = False; \ goto done; \ }} while (0) #define CHECK_RDWR(fnum, correct) do { \ - enum rdwr_mode m = check_rdwr(cli, fnum); \ + enum rdwr_mode m = check_rdwr(cli->tree, fnum); \ if (m != correct) { \ printf("(%d) Incorrect readwrite mode %s - expected %s\n", \ __LINE__, rdwr_string(m), rdwr_string(correct)); \ @@ -163,9 +163,9 @@ static BOOL test_open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); fnum = io.open.out.fnum; - cli_unlink(cli, fname); + cli_unlink(cli->tree, fname); CREATE_FILE; - cli_close(cli, fnum); + cli_close(cli->tree, fnum); status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -176,8 +176,8 @@ static BOOL test_open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); fnum2 = io.open.out.fnum; CHECK_RDWR(fnum2, RDWR_RDWR); - cli_close(cli, fnum2); - cli_close(cli, fnum); + cli_close(cli->tree, fnum2); + cli_close(cli->tree, fnum); /* check the read/write modes */ io.open.level = RAW_OPEN_OPEN; @@ -189,21 +189,21 @@ static BOOL test_open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); fnum = io.open.out.fnum; CHECK_RDWR(fnum, RDWR_RDONLY); - cli_close(cli, fnum); + cli_close(cli->tree, fnum); io.open.in.flags = OPEN_FLAGS_OPEN_WRITE; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); fnum = io.open.out.fnum; CHECK_RDWR(fnum, RDWR_WRONLY); - cli_close(cli, fnum); + cli_close(cli->tree, fnum); io.open.in.flags = OPEN_FLAGS_OPEN_RDWR; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); fnum = io.open.out.fnum; CHECK_RDWR(fnum, RDWR_RDWR); - cli_close(cli, fnum); + cli_close(cli->tree, fnum); /* check the share modes roughly - not a complete matrix */ io.open.in.flags = OPEN_FLAGS_OPEN_RDWR | OPEN_FLAGS_DENY_WRITE; @@ -226,8 +226,8 @@ static BOOL test_open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); fnum2 = io.open.out.fnum; CHECK_RDWR(fnum2, RDWR_RDONLY); - cli_close(cli, fnum); - cli_close(cli, fnum2); + cli_close(cli->tree, fnum); + cli_close(cli->tree, fnum2); /* check the returned write time */ @@ -245,8 +245,8 @@ static BOOL test_open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_ALL_INFO(io.open.out.attrib, attrib); done: - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); return ret; } @@ -284,7 +284,7 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) }; printf("Checking RAW_OPEN_OPENX\n"); - cli_unlink(cli, fname); + cli_unlink(cli->tree, fname); io.openx.level = RAW_OPEN_OPENX; io.openx.in.fname = fname; @@ -301,11 +301,11 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) if (open_funcs[i].with_file) { fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { - d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli)); + d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli->tree)); ret = False; goto done; } - cli_close(cli, fnum); + cli_close(cli->tree, fnum); } io.openx.in.open_func = open_funcs[i].open_func; status = smb_raw_open(cli->tree, mem_ctx, &io); @@ -316,8 +316,8 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) ret = False; } if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) { - cli_close(cli, io.openx.out.fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, io.openx.out.fnum); + cli_unlink(cli->tree, fname); } } @@ -336,8 +336,8 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_VAL(io.openx.out.ftype, 0); CHECK_VAL(io.openx.out.devstate, 0); CHECK_VAL(io.openx.out.action, OPENX_ACTION_CREATED); - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* check the fields when the file already existed */ fnum2 = create_complex_file(cli, mem_ctx, fname); @@ -345,7 +345,7 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) ret = False; goto done; } - cli_close(cli, fnum2); + cli_close(cli->tree, fnum2); io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN; status = smb_raw_open(cli->tree, mem_ctx, &io); @@ -357,7 +357,7 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_VAL(io.openx.out.action, OPENX_ACTION_EXISTED); CHECK_VAL(io.openx.out.unknown, 0); CHECK_ALL_INFO(io.openx.out.attrib, attrib); - cli_close(cli, fnum); + cli_close(cli->tree, fnum); /* now check the search attrib for hidden files - win2003 ignores this? */ SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN); @@ -366,15 +366,15 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) io.openx.in.search_attrs = FILE_ATTRIBUTE_HIDDEN; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - cli_close(cli, io.openx.out.fnum); + cli_close(cli->tree, io.openx.out.fnum); io.openx.in.search_attrs = 0; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - cli_close(cli, io.openx.out.fnum); + cli_close(cli->tree, io.openx.out.fnum); SET_ATTRIB(FILE_ATTRIBUTE_NORMAL); - cli_unlink(cli, fname); + cli_unlink(cli->tree, fname); /* and check attrib on create */ io.openx.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE; @@ -383,8 +383,8 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE, attrib); - cli_close(cli, io.openx.out.fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, io.openx.out.fnum); + cli_unlink(cli->tree, fname); /* check timeout on create - win2003 ignores the timeout! */ io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE; @@ -404,8 +404,8 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) __LINE__, (int)end_timer()); ret = False; } - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* now this is a really weird one - open for execute implies create?! */ io.openx.in.fname = fname; @@ -419,7 +419,7 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) io.openx.in.timeout = 0; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - cli_close(cli, io.openx.out.fnum); + cli_close(cli->tree, io.openx.out.fnum); /* check the extended return flag */ io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO | OPENX_FLAGS_EXTENDED_RETURN; @@ -427,11 +427,11 @@ static BOOL test_openx(struct cli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(io.openx.out.access_mask, STD_RIGHT_ALL_ACCESS); - cli_close(cli, io.openx.out.fnum); + cli_close(cli->tree, io.openx.out.fnum); done: - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); return ret; } @@ -496,11 +496,11 @@ static BOOL test_t2open(struct cli_state *cli, TALLOC_CTX *mem_ctx) if (open_funcs[i].with_file) { fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { - d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli)); + d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli->tree)); ret = False; goto done; } - cli_close(cli, fnum); + cli_close(cli->tree, fnum); } io.t2open.in.open_func = open_funcs[i].open_func; status = smb_raw_open(cli->tree, mem_ctx, &io); @@ -511,14 +511,14 @@ static BOOL test_t2open(struct cli_state *cli, TALLOC_CTX *mem_ctx) ret = False; } if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) { - cli_close(cli, io.t2open.out.fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, io.t2open.out.fnum); + cli_unlink(cli->tree, fname); } } /* check the basic return fields */ fnum = create_complex_file(cli, mem_ctx, fname); - cli_close(cli, fnum); + cli_close(cli->tree, fnum); io.t2open.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -531,7 +531,7 @@ static BOOL test_t2open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_VAL(io.t2open.out.ftype, 0); CHECK_VAL(io.t2open.out.devstate, 0); CHECK_VAL(io.t2open.out.action, OPENX_ACTION_EXISTED); - cli_close(cli, fnum); + cli_close(cli->tree, fnum); /* now check the search attrib for hidden files - win2003 ignores this? */ SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN); @@ -539,14 +539,14 @@ static BOOL test_t2open(struct cli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - cli_close(cli, io.t2open.out.fnum); + cli_close(cli->tree, io.t2open.out.fnum); status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - cli_close(cli, io.t2open.out.fnum); + cli_close(cli->tree, io.t2open.out.fnum); SET_ATTRIB(FILE_ATTRIBUTE_NORMAL); - cli_unlink(cli, fname); + cli_unlink(cli->tree, fname); /* and check attrib on create */ io.t2open.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE; @@ -562,8 +562,8 @@ static BOOL test_t2open(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); done: - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); return ret; } @@ -622,13 +622,13 @@ static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx) /* test the open disposition */ for (i=0; i<ARRAY_SIZE(open_funcs); i++) { if (open_funcs[i].with_file) { - fnum = cli_open(cli, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE); + fnum = cli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE); if (fnum == -1) { - d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli)); + d_printf("Failed to create file %s - %s\n", fname, cli_errstr(cli->tree)); ret = False; goto done; } - cli_close(cli, fnum); + cli_close(cli->tree, fnum); } io.ntcreatex.in.open_disposition = open_funcs[i].open_disp; status = smb_raw_open(cli->tree, mem_ctx, &io); @@ -639,8 +639,8 @@ static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx) ret = False; } if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) { - cli_close(cli, io.ntcreatex.out.fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, io.ntcreatex.out.fnum); + cli_unlink(cli->tree, fname); } } @@ -664,14 +664,14 @@ static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK); /* check fields when the file already existed */ - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { ret = False; goto done; } - cli_close(cli, fnum); + cli_close(cli->tree, fnum); io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; status = smb_raw_open(cli->tree, mem_ctx, &io); @@ -689,8 +689,8 @@ static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_ALL_INFO(io.ntcreatex.out.size, size); CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory); CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK); - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* create a directory */ @@ -704,8 +704,8 @@ static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx) io.ntcreatex.in.fname = dname; fname = dname; - cli_rmdir(cli, fname); - cli_unlink(cli, fname); + cli_rmdir(cli->tree, fname); + cli_unlink(cli->tree, fname); io.ntcreatex.in.access_mask = SEC_RIGHT_MAXIMUM_ALLOWED; io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; @@ -730,12 +730,12 @@ static BOOL test_ntcreatex(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_VAL(io.ntcreatex.out.size, 0); CHECK_VAL(io.ntcreatex.out.alloc_size, 0); CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK); - cli_unlink(cli, fname); + cli_unlink(cli->tree, fname); done: - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); return ret; } @@ -767,8 +767,8 @@ static BOOL test_mknew(struct cli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* make sure write_time works */ io.mknew.in.write_time = basetime; @@ -777,8 +777,8 @@ static BOOL test_mknew(struct cli_state *cli, TALLOC_CTX *mem_ctx) fnum = io.mknew.out.fnum; CHECK_TIME(basetime, write_time); - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* make sure file_attrs works */ io.mknew.in.attrib = FILE_ATTRIBUTE_HIDDEN; @@ -788,8 +788,8 @@ static BOOL test_mknew(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE, attrib); done: - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); return ret; } @@ -821,9 +821,9 @@ static BOOL test_create(struct cli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - cli_close(cli, io.create.out.fnum); - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, io.create.out.fnum); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* make sure write_time works */ io.create.in.write_time = basetime; @@ -832,8 +832,8 @@ static BOOL test_create(struct cli_state *cli, TALLOC_CTX *mem_ctx) fnum = io.create.out.fnum; CHECK_TIME(basetime, write_time); - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); /* make sure file_attrs works */ io.create.in.attrib = FILE_ATTRIBUTE_HIDDEN; @@ -843,8 +843,8 @@ static BOOL test_create(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE, attrib); done: - cli_close(cli, fnum); - cli_unlink(cli, fname); + cli_close(cli->tree, fnum); + cli_unlink(cli->tree, fname); return ret; } @@ -886,9 +886,9 @@ static BOOL test_ctemp(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_TIME(basetime, write_time); done: - cli_close(cli, fnum); + cli_close(cli->tree, fnum); if (fname) { - cli_unlink(cli, fname); + cli_unlink(cli->tree, fname); } return ret; @@ -908,12 +908,12 @@ BOOL torture_raw_open(int dummy) mem_ctx = talloc_init("torture_raw_open"); - if (cli_deltree(cli, BASEDIR) == -1) { + if (cli_deltree(cli->tree, BASEDIR) == -1) { printf("Failed to clean " BASEDIR "\n"); return False; } - if (!cli_mkdir(cli, BASEDIR)) { - printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli)); + if (!cli_mkdir(cli->tree, BASEDIR)) { + printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree)); return False; } @@ -946,7 +946,7 @@ BOOL torture_raw_open(int dummy) } smb_raw_exit(cli->session); - cli_deltree(cli, BASEDIR); + cli_deltree(cli->tree, BASEDIR); torture_close_connection(cli); talloc_destroy(mem_ctx); |