int total_len = 0;
int grp_id;
- if (!cli_message_start(cli, desthost, username, &grp_id)) {
- d_printf("message start: %s\n", cli_errstr(cli));
+ if (!cli_message_start(cli->tree, desthost, username, &grp_id)) {
+ d_printf("message start: %s\n", cli_errstr(cli->tree));
return;
}
msg[l] = c;
}
- if (!cli_message_text(cli, msg, l, grp_id)) {
- d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
+ if (!cli_message_text(cli->tree, msg, l, grp_id)) {
+ d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli->tree));
return;
}
else
d_printf("sent %d bytes\n",total_len);
- if (!cli_message_end(cli, grp_id)) {
- d_printf("SMBsendend failed (%s)\n",cli_errstr(cli));
+ if (!cli_message_end(cli->tree, grp_id)) {
+ d_printf("SMBsendend failed (%s)\n",cli_errstr(cli->tree));
return;
}
}
{
int total, bsize, avail;
- if (!cli_dskattr(cli, &bsize, &total, &avail)) {
- d_printf("Error in dskattr: %s\n",cli_errstr(cli));
+ if (!cli_dskattr(cli->tree, &bsize, &total, &avail)) {
+ d_printf("Error in dskattr: %s\n",cli_errstr(cli->tree));
return 1;
}
dos_clean_name(cur_dir);
if (!strequal(cur_dir,"\\")) {
- if (!cli_chkpath(cli, dname)) {
- d_printf("cd %s: %s\n", dname, cli_errstr(cli));
+ if (!cli_chkpath(cli->tree, dname)) {
+ d_printf("cd %s: %s\n", dname, cli_errstr(cli->tree));
pstrcpy(cur_dir,saved_dir);
}
}
*/
pstring head;
pstrcpy(head, do_list_queue_head());
- cli_list(cli, head, attribute, do_list_helper, NULL);
+ cli_list(cli->tree, head, attribute, do_list_helper, NULL);
remove_do_list_queue_head();
if ((! do_list_queue_empty()) && (fn == display_finfo))
{
}
else
{
- if (cli_list(cli, mask, attribute, do_list_helper, NULL) == -1)
+ if (cli_list(cli->tree, mask, attribute, do_list_helper, NULL) == -1)
{
- d_printf("%s listing %s\n", cli_errstr(cli), mask);
+ d_printf("%s listing %s\n", cli_errstr(cli->tree), mask);
}
}
strlower(lname);
}
- fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
+ fnum = cli_open(cli->tree, rname, O_RDONLY, DENY_NONE);
if (fnum == -1) {
- d_printf("%s opening remote file %s\n",cli_errstr(cli),rname);
+ d_printf("%s opening remote file %s\n",cli_errstr(cli->tree),rname);
return 1;
}
}
- if (!cli_qfileinfo(cli, fnum,
+ if (!cli_qfileinfo(cli->tree, fnum,
&attr, &size, NULL, NULL, NULL, NULL, NULL) &&
- !cli_getattrE(cli, fnum,
+ !cli_getattrE(cli->tree, fnum,
&attr, &size, NULL, NULL, NULL)) {
- d_printf("getattrib: %s\n",cli_errstr(cli));
+ d_printf("getattrib: %s\n",cli_errstr(cli->tree));
return 1;
}
if(!(data = (char *)malloc(read_size))) {
d_printf("malloc fail for size %d\n", read_size);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
return 1;
}
while (1) {
- int n = cli_read(cli, fnum, data, nread + start, read_size);
+ int n = cli_read(cli->tree, fnum, data, nread + start, read_size);
if (n <= 0) break;
SAFE_FREE(data);
- if (!cli_close(cli, fnum)) {
- d_printf("Error %s closing remote file\n",cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum)) {
+ d_printf("Error %s closing remote file\n",cli_errstr(cli->tree));
rc = 1;
}
}
if (archive_level >= 2 && (attr & FILE_ATTRIBUTE_ARCHIVE)) {
- cli_setatr(cli, rname, attr & ~(uint16)FILE_ATTRIBUTE_ARCHIVE, 0);
+ cli_setatr(cli->tree, rname, attr & ~(uint16)FILE_ATTRIBUTE_ARCHIVE, 0);
}
{
****************************************************************************/
static BOOL do_mkdir(char *name)
{
- if (!cli_mkdir(cli, name)) {
+ if (!cli_mkdir(cli->tree, name)) {
d_printf("%s making remote directory %s\n",
- cli_errstr(cli),name);
+ cli_errstr(cli->tree),name);
return(False);
}
static BOOL do_altname(char *name)
{
const char *altname;
- if (!NT_STATUS_IS_OK(cli_qpathinfo_alt_name(cli, name, &altname))) {
+ if (!NT_STATUS_IS_OK(cli_qpathinfo_alt_name(cli->tree, name, &altname))) {
d_printf("%s getting alt name for %s\n",
- cli_errstr(cli),name);
+ cli_errstr(cli->tree),name);
return(False);
}
d_printf("%s\n", altname);
p = strtok(ddir,"/\\");
while (p) {
pstrcat(ddir2,p);
- if (!cli_chkpath(cli, ddir2)) {
+ if (!cli_chkpath(cli->tree, ddir2)) {
do_mkdir(ddir2);
}
pstrcat(ddir2,"\\");
GetTimeOfDay(&tp_start);
if (reput) {
- fnum = cli_open(cli, rname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, rname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum >= 0) {
- if (!cli_qfileinfo(cli, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL) &&
- !cli_getattrE(cli, fnum, NULL, &start, NULL, NULL, NULL)) {
- d_printf("getattrib: %s\n",cli_errstr(cli));
+ if (!cli_qfileinfo(cli->tree, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL) &&
+ !cli_getattrE(cli->tree, fnum, NULL, &start, NULL, NULL, NULL)) {
+ d_printf("getattrib: %s\n",cli_errstr(cli->tree));
return 1;
}
}
} else {
- fnum = cli_open(cli, rname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
+ fnum = cli_open(cli->tree, rname, O_RDWR|O_CREAT|O_TRUNC,
+ DENY_NONE);
}
if (fnum == -1) {
- d_printf("%s opening remote file %s\n",cli_errstr(cli),rname);
+ d_printf("%s opening remote file %s\n",cli_errstr(cli->tree),rname);
return 1;
}
break;
}
- ret = cli_write(cli, fnum, 0, buf, nread + start, n);
+ ret = cli_write(cli->tree, fnum, 0, buf, nread + start, n);
if (n != ret) {
- d_printf("Error writing file: %s\n", cli_errstr(cli));
+ d_printf("Error writing file: %s\n", cli_errstr(cli->tree));
rc = 1;
break;
}
nread += n;
}
- if (!cli_close(cli, fnum)) {
- d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
+ if (!cli_close(cli->tree, fnum)) {
+ d_printf("%s closing remote file %s\n",cli_errstr(cli->tree),rname);
x_fclose(f);
SAFE_FREE(buf);
return 1;
SAFE_FREE(rname);
if(asprintf(&rname, "%s%s", cur_dir, lname) < 0) break;
dos_format(rname);
- if (!cli_chkpath(cli, rname) &&
+ if (!cli_chkpath(cli->tree, rname) &&
!do_mkdir(rname)) {
DEBUG (0, ("Unable to make dir, skipping..."));
/* Skip the directory */
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY)
return;
- if (!cli_unlink(cli, mask)) {
- d_printf("%s deleting remote file %s\n",cli_errstr(cli),mask);
+ if (!cli_unlink(cli->tree, mask)) {
+ d_printf("%s deleting remote file %s\n",cli_errstr(cli->tree),mask);
}
}
}
pstrcat(dname,buf);
- ret = cli_deltree(cli, dname);
+ ret = cli_deltree(cli->tree, dname);
if (ret == -1) {
- printf("Failed to delete tree %s - %s\n", dname, cli_errstr(cli));
+ printf("Failed to delete tree %s - %s\n", dname, cli_errstr(cli->tree));
return -1;
}
}
pstrcat(fname,buf);
- fnum = cli_open(cli, fname, O_RDONLY, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDONLY, DENY_NONE);
if (fnum == -1) {
- d_printf("%s - %s\n", fname, cli_errstr(cli));
+ d_printf("%s - %s\n", fname, cli_errstr(cli->tree));
return -1;
}
}
pstrcat(mask,buf);
- cli_open(cli, mask, O_RDWR, DENY_ALL);
+ cli_open(cli->tree, mask, O_RDWR, DENY_ALL);
return 0;
}
}
pstrcat(mask,buf);
- if (!cli_rmdir(cli, mask)) {
+ if (!cli_rmdir(cli->tree, mask)) {
d_printf("%s removing remote directory file %s\n",
- cli_errstr(cli),mask);
+ cli_errstr(cli->tree),mask);
}
return 0;
pstrcat(src,buf);
pstrcat(dest,buf2);
- if (!cli_unix_hardlink(cli, src, dest)) {
- d_printf("%s linking files (%s -> %s)\n", cli_errstr(cli), src, dest);
+ if (!cli_unix_hardlink(cli->tree, src, dest)) {
+ d_printf("%s linking files (%s -> %s)\n", cli_errstr(cli->tree), src, dest);
return 1;
}
pstrcat(src,buf);
pstrcat(dest,buf2);
- if (!cli_unix_symlink(cli, src, dest)) {
+ if (!cli_unix_symlink(cli->tree, src, dest)) {
d_printf("%s symlinking files (%s -> %s)\n",
- cli_errstr(cli), src, dest);
+ cli_errstr(cli->tree), src, dest);
return 1;
}
mode = (mode_t)strtol(buf, NULL, 8);
pstrcat(src,buf2);
- if (!cli_unix_chmod(cli, src, mode)) {
+ if (!cli_unix_chmod(cli->tree, src, mode)) {
d_printf("%s chmod file %s 0%o\n",
- cli_errstr(cli), src, (unsigned int)mode);
+ cli_errstr(cli->tree), src, (unsigned int)mode);
return 1;
}
gid = (gid_t)atoi(buf2);
pstrcat(src,buf3);
- if (!cli_unix_chown(cli, src, uid, gid)) {
+ if (!cli_unix_chown(cli->tree, src, uid, gid)) {
d_printf("%s chown file %s uid=%d, gid=%d\n",
- cli_errstr(cli), src, (int)uid, (int)gid);
+ cli_errstr(cli->tree), src, (int)uid, (int)gid);
return 1;
}
pstrcat(src,buf);
pstrcat(dest,buf2);
- if (!cli_rename(cli, src, dest)) {
- d_printf("%s renaming files\n",cli_errstr(cli));
+ if (!cli_rename(cli->tree, src, dest)) {
+ d_printf("%s renaming files\n",cli_errstr(cli->tree));
return 1;
}
} else
snprintf(dirmask, sizeof(dirmask), "%s*", cur_dir);
- if (cli_list(cli, dirmask,
+ if (cli_list(cli->tree, dirmask,
FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
completion_remote_filter, &info) < 0)
goto cleanup;
}
if (cli->tree) {
- cli_chkpath(cli, "\\");
+ cli_chkpath(cli->tree, "\\");
}
}
if (!cli_transport_establish(c, &calling, &called)) {
char *p;
d_printf("session request to %s failed (%s)\n",
- called.name, cli_errstr(c));
+ called.name, cli_errstr(c->tree));
cli_shutdown(c);
if ((p=strchr_m(called.name, '.'))) {
*p = 0;
/* if a password was not supplied then try again with a null username */
if (password[0] || !username[0] || use_kerberos ||
!cli_session_setup(c, "", "", lp_workgroup())) {
- d_printf("session setup failed: %s\n", cli_errstr(c));
+ d_printf("session setup failed: %s\n", cli_errstr(c->tree));
cli_shutdown(c);
return NULL;
}
DEBUG(4,(" session setup ok\n"));
if (!cli_send_tconX(c, sharename, "?????", password)) {
- d_printf("tree connect failed: %s\n", cli_errstr(c));
+ d_printf("tree connect failed: %s\n", cli_errstr(c->tree));
cli_shutdown(c);
return NULL;
}
{
safe_strcat(partpath, p, strlen(fname) + 1);
- if (!cli_chkpath(cli, partpath)) {
- if (!cli_mkdir(cli, partpath))
+ if (!cli_chkpath(cli->tree, partpath)) {
+ if (!cli_mkdir(cli->tree, partpath))
{
DEBUG(0, ("Error mkdirhiering\n"));
return False;
{
uint16 oldattr;
- if (!cli_getatr(cli, name, &oldattr, NULL, NULL)) return;
+ if (!cli_getatr(cli->tree, name, &oldattr, NULL, NULL)) return;
if (set == ATTRSET) {
attr |= oldattr;
attr = oldattr & ~attr;
}
- if (!cli_setatr(cli, name, attr, 0)) {
- DEBUG(1,("setatr failed: %s\n", cli_errstr(cli)));
+ if (!cli_setatr(cli->tree, name, attr, 0)) {
+ DEBUG(1,("setatr failed: %s\n", cli_errstr(cli->tree)));
}
}
return;
}
- fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
+ fnum = cli_open(cli->tree, rname, O_RDONLY, DENY_NONE);
dos_clean_name(rname);
if (fnum == -1) {
DEBUG(0,("%s opening remote file %s (%s)\n",
- cli_errstr(cli),rname, cur_dir));
+ cli_errstr(cli->tree),rname, cur_dir));
return;
}
safe_strcpy(finfo.name,rname, strlen(rname));
if (!finfo1) {
size_t size;
- if (!cli_getattrE(cli, fnum, &finfo.mode, &size, NULL, &finfo.atime, &finfo.mtime)) {
- DEBUG(0, ("getattrE: %s\n", cli_errstr(cli)));
+ if (!cli_getattrE(cli->tree, fnum, &finfo.mode, &size, NULL, &finfo.atime, &finfo.mtime)) {
+ DEBUG(0, ("getattrE: %s\n", cli_errstr(cli->tree)));
return;
}
finfo.size = size;
DEBUG(3,("nread=%.0f\n",(double)nread));
- datalen = cli_read(cli, fnum, data, nread, read_size);
+ datalen = cli_read(cli->tree, fnum, data, nread, read_size);
if (datalen == -1) {
- DEBUG(0,("Error reading file %s : %s\n", rname, cli_errstr(cli)));
+ DEBUG(0,("Error reading file %s : %s\n", rname, cli_errstr(cli->tree)));
break;
}
ntarf++;
}
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
if (shallitime)
{
DEBUG(5, ("get_file: file: %s, size %i\n", finfo.name, (int)finfo.size));
if (ensurepath(finfo.name) &&
- (fnum=cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
+ (fnum=cli_open(cli->tree, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) {
DEBUG(0, ("abandoning restore\n"));
return(False);
}
dsize = MIN(dsize, rsize); /* Should be only what is left */
DEBUG(5, ("writing %i bytes, bpos = %i ...\n", dsize, bpos));
- if (cli_write(cli, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) {
+ if (cli_write(cli->tree, fnum, 0, buffer_p + bpos, pos, dsize) != dsize) {
DEBUG(0, ("Error writing remote file\n"));
return 0;
}
/* Now close the file ... */
- if (!cli_close(cli, fnum)) {
+ if (!cli_close(cli->tree, fnum)) {
DEBUG(0, ("Error closing remote file\n"));
return(False);
}
DEBUG(5, ("Updating creation date on %s\n", finfo.name));
- if (!cli_setatr(cli, finfo.name, finfo.mode, finfo.mtime)) {
+ if (!cli_setatr(cli->tree, finfo.name, finfo.mode, finfo.mtime)) {
if (tar_real_noisy) {
DEBUG(0, ("Could not set time on file: %s\n", finfo.name));
/*return(False); */ /* Ignore, as Win95 does not allow changes */
#include "includes.h"
struct delete_state {
- struct cli_state *cli;
+ struct cli_tree *tree;
int total_deleted;
BOOL failed;
};
asprintf(&s, "%s%s", n, finfo->name);
if (finfo->mode & FILE_ATTRIBUTE_READONLY) {
- if (!cli_setatr(dstate->cli, s, 0, 0)) {
+ if (!cli_setatr(dstate->tree, s, 0, 0)) {
DEBUG(2,("Failed to remove READONLY on %s - %s\n",
- s, cli_errstr(dstate->cli)));
+ s, cli_errstr(dstate->tree)));
}
}
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
char *s2;
asprintf(&s2, "%s\\*", s);
- cli_unlink(dstate->cli, s2);
- cli_list(dstate->cli, s2,
+ cli_unlink(dstate->tree, s2);
+ cli_list(dstate->tree, s2,
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
delete_fn, state);
free(s2);
- if (!cli_rmdir(dstate->cli, s)) {
+ if (!cli_rmdir(dstate->tree, s)) {
DEBUG(2,("Failed to delete %s - %s\n",
- s, cli_errstr(dstate->cli)));
+ s, cli_errstr(dstate->tree)));
dstate->failed = True;
}
dstate->total_deleted++;
} else {
- if (!cli_unlink(dstate->cli, s)) {
+ if (!cli_unlink(dstate->tree, s)) {
DEBUG(2,("Failed to delete %s - %s\n",
- s, cli_errstr(dstate->cli)));
+ s, cli_errstr(dstate->tree)));
dstate->failed = True;
}
dstate->total_deleted++;
recursively descend a tree deleting all files
returns the number of files deleted, or -1 on error
*/
-int cli_deltree(struct cli_state *cli, const char *dname)
+int cli_deltree(struct cli_tree *tree, const char *dname)
{
char *mask;
struct delete_state dstate;
- dstate.cli = cli;
+ dstate.tree = tree;
dstate.total_deleted = 0;
dstate.failed = False;
/* it might be a file */
- if (cli_unlink(cli, dname)) {
+ if (cli_unlink(tree, dname)) {
return 1;
}
- if (NT_STATUS_EQUAL(cli_nt_error(cli), NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
- NT_STATUS_EQUAL(cli_nt_error(cli), NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
- NT_STATUS_EQUAL(cli_nt_error(cli), NT_STATUS_NO_SUCH_FILE)) {
+ if (NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
+ NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
+ NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_NO_SUCH_FILE)) {
return 0;
}
asprintf(&mask, "%s\\*", dname);
- cli_unlink(cli, mask);
- cli_list(dstate.cli, mask,
+ cli_unlink(dstate.tree, mask);
+ cli_list(dstate.tree, mask,
FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
delete_fn, &dstate);
free(mask);
- if (!cli_rmdir(dstate.cli, dname)) {
+ if (!cli_rmdir(dstate.tree, dname)) {
DEBUG(2,("Failed to delete %s - %s\n",
- dname, cli_errstr(dstate.cli)));
+ dname, cli_errstr(dstate.tree)));
return -1;
}
dstate.total_deleted++;
Hard/Symlink a file (UNIX extensions).
****************************************************************************/
-static BOOL cli_link_internal(struct cli_state *cli,
+static BOOL cli_link_internal(struct cli_tree *tree,
const char *fname_src,
const char *fname_dst, BOOL hard_link)
{
parms.unix_link.in.link_dest = fname_dst;
}
- status = smb_raw_setpathinfo(cli->tree, &parms);
+ status = smb_raw_setpathinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
/****************************************************************************
Symlink a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_symlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_unix_symlink(struct cli_tree *tree, const char *fname_src,
+ const char *fname_dst)
{
- return cli_link_internal(cli, fname_src, fname_dst, False);
+ return cli_link_internal(tree, fname_src, fname_dst, False);
}
/****************************************************************************
Hard a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_unix_hardlink(struct cli_tree *tree, const char *fname_src,
+ const char *fname_dst)
{
- return cli_link_internal(cli, fname_src, fname_dst, True);
+ return cli_link_internal(tree, fname_src, fname_dst, True);
}
/****************************************************************************
Chmod or chown a file internal (UNIX extensions).
****************************************************************************/
-static BOOL cli_unix_chmod_chown_internal(struct cli_state *cli, const char *fname,
+static BOOL cli_unix_chmod_chown_internal(struct cli_tree *tree,
+ const char *fname,
uint32 mode, uint32 uid, uint32 gid)
{
union smb_setfileinfo parms;
parms.unix_basic.in.gid = gid;
parms.unix_basic.in.mode = mode;
- status = smb_raw_setpathinfo(cli->tree, &parms);
+ status = smb_raw_setpathinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
chmod a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_chmod(struct cli_state *cli, const char *fname, mode_t mode)
+BOOL cli_unix_chmod(struct cli_tree *tree, const char *fname, mode_t mode)
{
- return cli_unix_chmod_chown_internal(cli, fname,
- unix_perms_to_wire(mode), SMB_UID_NO_CHANGE, SMB_GID_NO_CHANGE);
+ return cli_unix_chmod_chown_internal(tree, fname,
+ unix_perms_to_wire(mode),
+ SMB_UID_NO_CHANGE,
+ SMB_GID_NO_CHANGE);
}
/****************************************************************************
chown a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_chown(struct cli_state *cli, const char *fname, uid_t uid, gid_t gid)
+BOOL cli_unix_chown(struct cli_tree *tree, const char *fname, uid_t uid,
+ gid_t gid)
{
- return cli_unix_chmod_chown_internal(cli, fname, SMB_MODE_NO_CHANGE, (uint32)uid, (uint32)gid);
+ return cli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE,
+ (uint32)uid, (uint32)gid);
}
/****************************************************************************
Rename a file.
****************************************************************************/
-BOOL cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_rename(struct cli_tree *tree, const char *fname_src,
+ const char *fname_dst)
{
union smb_rename parms;
parms.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
parms.rename.in.pattern1 = fname_src;
parms.rename.in.pattern2 = fname_dst;
- return NT_STATUS_IS_OK(smb_raw_rename(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_rename(tree, &parms));
}
/****************************************************************************
Delete a file.
****************************************************************************/
-BOOL cli_unlink(struct cli_state *cli, const char *fname)
+BOOL cli_unlink(struct cli_tree *tree, const char *fname)
{
struct smb_unlink parms;
} else {
parms.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
}
- return NT_STATUS_IS_OK(smb_raw_unlink(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_unlink(tree, &parms));
}
/****************************************************************************
Create a directory.
****************************************************************************/
-BOOL cli_mkdir(struct cli_state *cli, const char *dname)
+BOOL cli_mkdir(struct cli_tree *tree, const char *dname)
{
union smb_mkdir parms;
parms.mkdir.level = RAW_MKDIR_MKDIR;
parms.mkdir.in.path = dname;
- return NT_STATUS_IS_OK(smb_raw_mkdir(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_mkdir(tree, &parms));
}
/****************************************************************************
Remove a directory.
****************************************************************************/
-BOOL cli_rmdir(struct cli_state *cli, const char *dname)
+BOOL cli_rmdir(struct cli_tree *tree, const char *dname)
{
struct smb_rmdir parms;
parms.in.path = dname;
- return NT_STATUS_IS_OK(smb_raw_rmdir(cli->tree, &parms));
+ return NT_STATUS_IS_OK(smb_raw_rmdir(tree, &parms));
}
/****************************************************************************
Set or clear the delete on close flag.
****************************************************************************/
-BOOL cli_nt_delete_on_close(struct cli_state *cli, int fnum, BOOL flag)
+BOOL cli_nt_delete_on_close(struct cli_tree *tree, int fnum, BOOL flag)
{
union smb_setfileinfo parms;
NTSTATUS status;
parms.disposition_info.file.fnum = fnum;
parms.disposition_info.in.delete_on_close = flag;
- status = smb_raw_setfileinfo(cli->tree, &parms);
+ status = smb_raw_setfileinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
Create/open a file - exposing the full horror of the NT API :-).
Used in CIFS-on-CIFS NTVFS.
****************************************************************************/
-int cli_nt_create_full(struct cli_state *cli, const char *fname,
- uint32 CreatFlags, uint32 DesiredAccess,
- uint32 FileAttributes, uint32 ShareAccess,
- uint32 CreateDisposition, uint32 CreateOptions,
- uint8 SecurityFlags)
+int cli_nt_create_full(struct cli_tree *tree, const char *fname,
+ uint32 CreatFlags, uint32 DesiredAccess,
+ uint32 FileAttributes, uint32 ShareAccess,
+ uint32 CreateDisposition, uint32 CreateOptions,
+ uint8 SecurityFlags)
{
union smb_open open_parms;
TALLOC_CTX *mem_ctx;
open_parms.ntcreatex.in.security_flags = SecurityFlags;
open_parms.ntcreatex.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &open_parms);
+ status = smb_raw_open(tree, mem_ctx, &open_parms);
talloc_destroy(mem_ctx);
if (NT_STATUS_IS_OK(status)) {
Open a file (using SMBopenx)
WARNING: if you open with O_WRONLY then getattrE won't work!
****************************************************************************/
-int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode)
+int cli_open(struct cli_tree *tree, const char *fname, int flags,
+ int share_mode)
{
union smb_open open_parms;
unsigned openfn=0;
open_parms.openx.in.timeout = 0;
open_parms.openx.in.fname = fname;
- status = smb_raw_open(cli->tree, mem_ctx, &open_parms);
+ status = smb_raw_open(tree, mem_ctx, &open_parms);
talloc_destroy(mem_ctx);
if (NT_STATUS_IS_OK(status)) {
/****************************************************************************
Close a file.
****************************************************************************/
-BOOL cli_close(struct cli_state *cli, int fnum)
+BOOL cli_close(struct cli_tree *tree, int fnum)
{
union smb_close close_parms;
NTSTATUS status;
close_parms.close.level = RAW_CLOSE_CLOSE;
close_parms.close.in.fnum = fnum;
close_parms.close.in.write_time = 0;
- status = smb_raw_close(cli->tree, &close_parms);
+ status = smb_raw_close(tree, &close_parms);
return NT_STATUS_IS_OK(status);
}
send a lock with a specified locktype
this is used for testing LOCKING_ANDX_CANCEL_LOCK
****************************************************************************/
-NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
+NTSTATUS cli_locktype(struct cli_tree *tree, int fnum,
uint32 offset, uint32 len, int timeout, unsigned char locktype)
{
union smb_lock parms;
parms.lockx.in.timeout = timeout;
parms.lockx.in.ulock_cnt = 0;
parms.lockx.in.lock_cnt = 1;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return status;
}
/****************************************************************************
Lock a file.
****************************************************************************/
-BOOL cli_lock(struct cli_state *cli, int fnum,
+BOOL cli_lock(struct cli_tree *tree, int fnum,
uint32 offset, uint32 len, int timeout, enum brl_type lock_type)
{
union smb_lock parms;
parms.lockx.in.timeout = timeout;
parms.lockx.in.ulock_cnt = 0;
parms.lockx.in.lock_cnt = 1;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
/****************************************************************************
Unlock a file.
****************************************************************************/
-BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
+BOOL cli_unlock(struct cli_tree *tree, int fnum, uint32 offset, uint32 len)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
parms.lockx.in.timeout = 0;
parms.lockx.in.ulock_cnt = 1;
parms.lockx.in.lock_cnt = 0;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
/****************************************************************************
Lock a file with 64 bit offsets.
****************************************************************************/
-BOOL cli_lock64(struct cli_state *cli, int fnum,
+BOOL cli_lock64(struct cli_tree *tree, int fnum,
SMB_OFF_T offset, SMB_OFF_T len, int timeout, enum brl_type lock_type)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
NTSTATUS status;
- if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
- return cli_lock(cli, fnum, offset, len, timeout, lock_type);
+ if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+ return cli_lock(tree, fnum, offset, len, timeout, lock_type);
}
parms.lockx.level = RAW_LOCK_LOCKX;
parms.lockx.in.timeout = timeout;
parms.lockx.in.ulock_cnt = 0;
parms.lockx.in.lock_cnt = 1;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
/****************************************************************************
Unlock a file with 64 bit offsets.
****************************************************************************/
-BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_OFF_T offset, SMB_OFF_T len)
+BOOL cli_unlock64(struct cli_tree *tree, int fnum, SMB_OFF_T offset, SMB_OFF_T len)
{
union smb_lock parms;
struct smb_lock_entry lock[1];
NTSTATUS status;
- if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
- return cli_unlock(cli, fnum, offset, len);
+ if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
+ return cli_unlock(tree, fnum, offset, len);
}
parms.lockx.level = RAW_LOCK_LOCKX;
parms.lockx.in.timeout = 0;
parms.lockx.in.ulock_cnt = 1;
parms.lockx.in.lock_cnt = 0;
- lock[0].pid = cli->session->pid;
+ lock[0].pid = tree->session->pid;
lock[0].offset = offset;
lock[0].count = len;
parms.lockx.in.locks = &lock[0];
- status = smb_raw_lock(cli->tree, &parms);
+ status = smb_raw_lock(tree, &parms);
return NT_STATUS_IS_OK(status);
}
/****************************************************************************
Do a SMBgetattrE call.
****************************************************************************/
-BOOL cli_getattrE(struct cli_state *cli, int fd,
- uint16 *attr, size_t *size,
- time_t *c_time, time_t *a_time, time_t *m_time)
+BOOL cli_getattrE(struct cli_tree *tree, int fd,
+ uint16 *attr, size_t *size,
+ time_t *c_time, time_t *a_time, time_t *m_time)
{
union smb_fileinfo parms;
NTSTATUS status;
parms.getattre.level = RAW_FILEINFO_GETATTRE;
parms.getattre.in.fnum = fd;
- status = smb_raw_fileinfo(cli->tree, NULL, &parms);
+ status = smb_raw_fileinfo(tree, NULL, &parms);
if (!NT_STATUS_IS_OK(status))
return False;
/****************************************************************************
Do a SMBgetatr call
****************************************************************************/
-BOOL cli_getatr(struct cli_state *cli, const char *fname,
+BOOL cli_getatr(struct cli_tree *tree, const char *fname,
uint16 *attr, size_t *size, time_t *t)
{
union smb_fileinfo parms;
parms.getattr.level = RAW_FILEINFO_GETATTR;
parms.getattr.in.fname = fname;
- status = smb_raw_pathinfo(cli->tree, NULL, &parms);
+ status = smb_raw_pathinfo(tree, NULL, &parms);
if (!NT_STATUS_IS_OK(status)) {
return False;
/****************************************************************************
Do a SMBsetatr call.
****************************************************************************/
-BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 mode, time_t t)
+BOOL cli_setatr(struct cli_tree *tree, const char *fname, uint16 mode, time_t t)
{
union smb_setfileinfo parms;
NTSTATUS status;
parms.setattr.in.write_time = t;
parms.setattr.file.fname = fname;
- status = smb_raw_setpathinfo(cli->tree, &parms);
+ status = smb_raw_setpathinfo(tree, &parms);
return NT_STATUS_IS_OK(status);
}
/****************************************************************************
Check for existence of a dir.
****************************************************************************/
-BOOL cli_chkpath(struct cli_state *cli, const char *path)
+BOOL cli_chkpath(struct cli_tree *tree, const char *path)
{
struct smb_chkpath parms;
char *path2;
parms.in.path = path2;
- status = smb_raw_chkpath(cli->tree, &parms);
+ status = smb_raw_chkpath(tree, &parms);
free(path2);
/****************************************************************************
Query disk space.
****************************************************************************/
-BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
+BOOL cli_dskattr(struct cli_tree *tree, int *bsize, int *total, int *avail)
{
union smb_fsinfo fsinfo_parms;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("cli_dskattr");
fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR;
- status = smb_raw_fsinfo(cli->tree, mem_ctx, &fsinfo_parms);
+ status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms);
if (NT_STATUS_IS_OK(status)) {
*bsize = fsinfo_parms.dskattr.out.block_size;
*total = fsinfo_parms.dskattr.out.units_total;
/****************************************************************************
Create and open a temporary file.
****************************************************************************/
-int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
+int cli_ctemp(struct cli_tree *tree, const char *path, char **tmp_path)
{
union smb_open open_parms;
TALLOC_CTX *mem_ctx;
open_parms.ctemp.in.attrib = 0;
open_parms.ctemp.in.directory = path;
- status = smb_raw_open(cli->tree, mem_ctx, &open_parms);
+ status = smb_raw_open(tree, mem_ctx, &open_parms);
if (tmp_path) {
*tmp_path = strdup(open_parms.ctemp.out.name);
}
return True;
}
-int cli_list_new(struct cli_state *cli, const char *Mask, uint16 attribute,
- void (*fn)(file_info *, const char *, void *), void *caller_state)
+int cli_list_new(struct cli_tree *tree, const char *Mask, uint16 attribute,
+ void (*fn)(file_info *, const char *, void *),
+ void *caller_state)
{
union smb_search_first first_parms;
union smb_search_next next_parms;
mask = talloc_strdup(state.mem_ctx, Mask);
- if (cli->transport->negotiate.capabilities & CAP_NT_SMBS) {
+ if (tree->session->transport->negotiate.capabilities & CAP_NT_SMBS) {
level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
} else {
level = RAW_SEARCH_STANDARD;
first_parms.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE_IF_END;
first_parms.t2ffirst.in.storage_type = 0;
- status = smb_raw_search_first(cli->tree,
+ status = smb_raw_search_first(tree,
state.mem_ctx, &first_parms,
(void*)&state, cli_list_new_callback);
if (!NT_STATUS_IS_OK(status)) {
next_parms.t2fnext.in.resume_key = 0;
next_parms.t2fnext.in.flags = FLAG_TRANS2_FIND_CONTINUE | FLAG_TRANS2_FIND_CLOSE_IF_END;
- status = smb_raw_search_next(cli->tree,
+ status = smb_raw_search_next(tree,
state.mem_ctx,
&next_parms,
(void*)&state,
return True;
}
-int cli_list_old(struct cli_state *cli, const char *Mask, uint16 attribute,
- void (*fn)(file_info *, const char *, void *), void *caller_state)
+int cli_list_old(struct cli_tree *tree, const char *Mask, uint16 attribute,
+ void (*fn)(file_info *, const char *, void *),
+ void *caller_state)
{
union smb_search_first first_parms;
union smb_search_next next_parms;
first_parms.search_first.in.search_attrib = attribute;
first_parms.search_first.in.pattern = mask;
- status = smb_raw_search_first(cli->tree, state.mem_ctx,
- &first_parms,
- (void*)&state,
- cli_list_old_callback);
+ status = smb_raw_search_first(tree, state.mem_ctx,
+ &first_parms,
+ (void*)&state,
+ cli_list_old_callback);
+
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
return -1;
next_parms.search_next.in.search_attrib = attribute;
next_parms.search_next.in.search_id = state.status;
- status = smb_raw_search_next(cli->tree, state.mem_ctx,
- &next_parms,
- (void*)&state,
- cli_list_old_callback);
+ status = smb_raw_search_next(tree, state.mem_ctx,
+ &next_parms,
+ (void*)&state,
+ cli_list_old_callback);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(state.mem_ctx);
This auto-switches between old and new style.
****************************************************************************/
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+int cli_list(struct cli_tree *tree, const char *Mask,uint16 attribute,
void (*fn)(file_info *, const char *, void *), void *state)
{
- if (cli->transport->negotiate.protocol <= PROTOCOL_LANMAN1)
- return cli_list_old(cli, Mask, attribute, fn, state);
- return cli_list_new(cli, Mask, attribute, fn, state);
+ if (tree->session->transport->negotiate.protocol <= PROTOCOL_LANMAN1)
+ return cli_list_old(tree, Mask, attribute, fn, state);
+ return cli_list_new(tree, Mask, attribute, fn, state);
}
/****************************************************************************
start a message sequence
****************************************************************************/
-BOOL cli_message_start(struct cli_state *cli, char *host, char *username,
- int *grp)
+BOOL cli_message_start(struct cli_tree *tree, char *host, char *username,
+ int *grp)
{
struct cli_request *req;
- req = cli_request_setup(cli->tree, SMBsendstrt, 0, 0);
+ req = cli_request_setup(tree, SMBsendstrt, 0, 0);
cli_req_append_string(req, username, STR_TERMINATE);
cli_req_append_string(req, host, STR_TERMINATE);
if (!cli_request_send(req) ||
!cli_request_receive(req) ||
- cli_is_error(cli)) {
+ cli_is_error(tree)) {
cli_request_destroy(req);
return False;
}
/****************************************************************************
send a message
****************************************************************************/
-BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp)
+BOOL cli_message_text(struct cli_tree *tree, char *msg, int len, int grp)
{
struct cli_request *req;
- req = cli_request_setup(cli->tree, SMBsendtxt, 1, 0);
+ req = cli_request_setup(tree, SMBsendtxt, 1, 0);
SSVAL(req->out.vwv, VWV(0), grp);
cli_req_append_bytes(req, msg, len);
if (!cli_request_send(req) ||
!cli_request_receive(req) ||
- cli_is_error(cli)) {
+ cli_is_error(tree)) {
cli_request_destroy(req);
return False;
}
/****************************************************************************
end a message
****************************************************************************/
-BOOL cli_message_end(struct cli_state *cli, int grp)
+BOOL cli_message_end(struct cli_tree *tree, int grp)
{
struct cli_request *req;
- req = cli_request_setup(cli->tree, SMBsendend, 1, 0);
+ req = cli_request_setup(tree, SMBsendend, 1, 0);
SSVAL(req->out.vwv, VWV(0), grp);
if (!cli_request_send(req) ||
!cli_request_receive(req) ||
- cli_is_error(cli)) {
+ cli_is_error(tree)) {
cli_request_destroy(req);
return False;
}
/****************************************************************************
Read size bytes at offset offset using SMBreadX.
****************************************************************************/
-ssize_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size)
+ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset,
+ size_t size)
{
union smb_read parms;
int readsize;
* Set readsize to the maximum size we can handle in one readX,
* rounded down to a multiple of 1024.
*/
- readsize = (cli->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
+ readsize = (tree->session->transport->negotiate.max_xmit -
+ (MIN_SMB_SIZE+32)) & ~1023;
if (readsize > 0xFFFF) readsize = 0xFFFF;
while (total < size) {
parms.readx.in.remaining = size - total;
parms.readx.out.data = buf + total;
- status = smb_raw_read(cli->tree, &parms);
+ status = smb_raw_read(tree, &parms);
if (!NT_STATUS_IS_OK(status)) {
return -1;
0x0004 use raw named pipe protocol
0x0008 start of message mode named pipe protocol
****************************************************************************/
-ssize_t cli_write(struct cli_state *cli,
+ssize_t cli_write(struct cli_tree *tree,
int fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size)
{
union smb_write parms;
- int block = (cli->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
+ int block = (tree->session->transport->negotiate.max_xmit - (MIN_SMB_SIZE+32)) & ~1023;
ssize_t total = 0;
if (size == 0) {
parms.writex.in.count = block;
parms.writex.in.data = buf;
- status = smb_raw_write(cli->tree, &parms);
+ status = smb_raw_write(tree, &parms);
if (!NT_STATUS_IS_OK(status)) {
return -1;
/****************************************************************************
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/
-ssize_t cli_smbwrite(struct cli_state *cli,
+ssize_t cli_smbwrite(struct cli_tree *tree,
int fnum, char *buf, off_t offset, size_t size1)
{
union smb_write parms;
parms.write.in.remaining = 0;
do {
- size_t size = MIN(size1, cli->transport->negotiate.max_xmit - 48);
+ size_t size = MIN(size1, tree->session->transport->negotiate.max_xmit - 48);
if (size > 0xFFFF) size = 0xFFFF;
parms.write.in.fnum = fnum;
parms.write.in.count = size;
parms.write.in.data = buf + total;
- if (NT_STATUS_IS_ERR(smb_raw_write(cli->tree, &parms)))
+ if (NT_STATUS_IS_ERR(smb_raw_write(tree, &parms)))
return -1;
size = parms.write.out.nwritten;
/****************************************************************************
query the security descriptor for a open file
****************************************************************************/
-SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum,
+SEC_DESC *cli_query_secdesc(struct cli_tree *tree, int fnum,
TALLOC_CTX *mem_ctx)
{
struct smb_nttrans parms;
parms.in.params = param_blob;
parms.in.data = data_blob(NULL, 0);
- status = smb_raw_nttrans(cli->tree, mem_ctx, &parms);
+ status = smb_raw_nttrans(tree, mem_ctx, &parms);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1,("Failed to send NT_TRANSACT_QUERY_SECURITY_DESC\n"));
/****************************************************************************
set the security descriptor for a open file
****************************************************************************/
-BOOL cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
+BOOL cli_set_secdesc(struct cli_tree *tree, int fnum, SEC_DESC *sd)
{
struct smb_nttrans parms;
char param[8];
parms.in.params = param_blob;
parms.in.data = data_blob(NULL, 0);
- status = smb_raw_nttrans(cli->tree, mem_ctx, &parms);
+ status = smb_raw_nttrans(tree, mem_ctx, &parms);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(1,("Failed to send NT_TRANSACT_SET_SECURITY_DESC\n"));
/****************************************************************************
send a qpathinfo call
****************************************************************************/
-BOOL cli_qpathinfo(struct cli_state *cli, const char *fname,
+BOOL cli_qpathinfo(struct cli_tree *tree, const char *fname,
time_t *c_time, time_t *a_time, time_t *m_time,
size_t *size, uint16 *mode)
{
parms.standard.level = RAW_FILEINFO_STANDARD;
parms.standard.in.fname = fname;
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_pathinfo(tree, mem_ctx, &parms);
talloc_destroy(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
return False;
/****************************************************************************
send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
****************************************************************************/
-BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
+BOOL cli_qpathinfo2(struct cli_tree *tree, const char *fname,
time_t *c_time, time_t *a_time, time_t *m_time,
time_t *w_time, size_t *size, uint16 *mode,
SMB_INO_T *ino)
parms.all_info.level = RAW_FILEINFO_ALL_INFO;
parms.all_info.in.fname = fname;
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_pathinfo(tree, mem_ctx, &parms);
talloc_destroy(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
return False;
/****************************************************************************
send a qfileinfo QUERY_FILE_NAME_INFO call
****************************************************************************/
-BOOL cli_qfilename(struct cli_state *cli, int fnum,
+BOOL cli_qfilename(struct cli_tree *tree, int fnum,
const char **name)
{
union smb_fileinfo parms;
parms.name_info.level = RAW_FILEINFO_NAME_INFO;
parms.name_info.in.fnum = fnum;
- status = smb_raw_fileinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_fileinfo(tree, mem_ctx, &parms);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(mem_ctx);
*name = NULL;
/****************************************************************************
send a qfileinfo call
****************************************************************************/
-BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
+BOOL cli_qfileinfo(struct cli_tree *tree, int fnum,
uint16 *mode, size_t *size,
time_t *c_time, time_t *a_time, time_t *m_time,
time_t *w_time, SMB_INO_T *ino)
parms.all_info.level = RAW_FILEINFO_ALL_INFO;
parms.all_info.in.fnum = fnum;
- status = smb_raw_fileinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_fileinfo(tree, mem_ctx, &parms);
talloc_destroy(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
return False;
/****************************************************************************
send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
****************************************************************************/
-NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname,
+NTSTATUS cli_qpathinfo_alt_name(struct cli_tree *tree, const char *fname,
const char **alt_name)
{
union smb_fileinfo parms;
mem_ctx = talloc_init("cli_qpathinfo_alt_name");
if (!mem_ctx) return NT_STATUS_NO_MEMORY;
- status = smb_raw_pathinfo(cli->tree, mem_ctx, &parms);
+ status = smb_raw_pathinfo(tree, mem_ctx, &parms);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(mem_ctx);
*alt_name = NULL;
- return cli_nt_error(cli);
+ return cli_nt_error(tree);
}
if (!parms.alt_name_info.out.fname.s) {
/***************************************************************************
Return an error message from the last response
****************************************************************************/
-const char *cli_errstr(struct cli_state *cli)
+const char *cli_errstr(struct cli_tree *tree)
{
- switch (cli->transport->error.etype) {
+ switch (tree->session->transport->error.etype) {
case ETYPE_DOS:
- return dos_errstr(cli->transport->error.e.dos.eclass,
- cli->transport->error.e.dos.ecode);
+ return dos_errstr(
+ tree->session->transport->error.e.dos.eclass,
+ tree->session->transport->error.e.dos.ecode);
case ETYPE_NT:
- return nt_errstr(cli->transport->error.e.nt_status);
+ return nt_errstr(tree->session->transport->error.e.nt_status);
case ETYPE_SOCKET:
return "socket_error";
/* Return the 32-bit NT status code from the last packet */
-NTSTATUS cli_nt_error(struct cli_state *cli)
+NTSTATUS cli_nt_error(struct cli_tree *tree)
{
- switch (cli->transport->error.etype) {
+ switch (tree->session->transport->error.etype) {
case ETYPE_NT:
- return cli->transport->error.e.nt_status;
+ return tree->session->transport->error.e.nt_status;
case ETYPE_DOS:
- return dos_to_ntstatus(cli->transport->error.e.dos.eclass,
- cli->transport->error.e.dos.ecode);
+ return dos_to_ntstatus(
+ tree->session->transport->error.e.dos.eclass,
+ tree->session->transport->error.e.dos.ecode);
case ETYPE_SOCKET:
return NT_STATUS_UNSUCCESSFUL;
/* Return true if the last packet was an error */
-BOOL cli_is_error(struct cli_state *cli)
+BOOL cli_is_error(struct cli_tree *tree)
{
- return NT_STATUS_IS_ERR(cli_nt_error(cli));
+ return NT_STATUS_IS_ERR(cli_nt_error(tree));
}
/* Return true if the last error was a DOS error */
-BOOL cli_is_dos_error(struct cli_state *cli)
+BOOL cli_is_dos_error(struct cli_tree *tree)
{
- return cli->transport->error.etype == ETYPE_DOS;
+ return tree->session->transport->error.etype == ETYPE_DOS;
}
t2.in.params = data_blob(NULL, 4);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
}
- cli_write(cli, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
SSVAL(t2.in.params.data, 0, fnum);
gen_aliases(cli, &t2, 2);
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
}
t2.in.params = data_blob_talloc(mem_ctx, NULL, 6);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
}
- cli_write(cli, fnum, 0, (char *)&t2, 0, sizeof(t2));
- cli_close(cli, fnum);
+ cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ cli_close(cli->tree, fnum);
SIVAL(t2.in.params.data, 2, 0);
gen_aliases(cli, &t2, 0);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
talloc_destroy(mem_ctx);
}
t2.in.params = data_blob_talloc(mem_ctx, NULL, 12);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
}
- cli_write(cli, fnum, 0, (char *)&t2, 0, sizeof(t2));
- cli_close(cli, fnum);
+ cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ cli_close(cli->tree, fnum);
SSVAL(t2.in.params.data, 0, 0);
SSVAL(t2.in.params.data, 2, 1);
gen_aliases(cli, &t2, 6);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
talloc_destroy(mem_ctx);
}
t2.in.params = data_blob(NULL, 6);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
}
- cli_write(cli, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
SSVAL(t2.in.params.data, 0, fnum);
SSVAL(t2.in.params.data, 4, 0);
gen_set_aliases(cli, &t2, 2);
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
}
/* look for setpathinfo aliases */
t2.in.params = data_blob_talloc(mem_ctx, NULL, 4);
t2.in.data = data_blob(NULL, 0);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
fnum = create_complex_file(cli, cli->mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
}
- cli_write(cli, fnum, 0, (char *)&t2, 0, sizeof(t2));
- cli_close(cli, fnum);
+ cli_write(cli->tree, fnum, 0, (char *)&t2, 0, sizeof(t2));
+ cli_close(cli->tree, fnum);
SSVAL(t2.in.params.data, 2, 0);
gen_set_aliases(cli, &t2, 0);
- if (!cli_unlink(cli, fname)) {
- printf("unlink: %s\n", cli_errstr(cli));
+ if (!cli_unlink(cli->tree, fname)) {
+ printf("unlink: %s\n", cli_errstr(cli->tree));
}
talloc_destroy(mem_ctx);
}
printf("Testing deny modes with 1 connection\n");
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i]);
- fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
- cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
- cli_close(cli1, fnum1);
+ cli_unlink(cli1->tree, fnames[i]);
+ fnum1 = cli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
+ cli_write(cli1->tree, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+ cli_close(cli1->tree, fnum1);
}
printf("testing %d entries\n", ARRAY_SIZE(denytable1));
progress_bar(i, ARRAY_SIZE(denytable1));
- fnum1 = cli_open(cli1, fname,
+ fnum1 = cli_open(cli1->tree, fname,
denytable1[i].mode1,
denytable1[i].deny1);
- fnum2 = cli_open(cli1, fname,
+ fnum2 = cli_open(cli1->tree, fname,
denytable1[i].mode2,
denytable1[i].deny2);
} else {
char x = 1;
res = A_0;
- if (cli_read(cli1, fnum2, (void *)&x, 0, 1) == 1) {
+ if (cli_read(cli1->tree, fnum2, (void *)&x, 0, 1) == 1) {
res += A_R;
}
- if (cli_write(cli1, fnum2, 0, (void *)&x, 0, 1) == 1) {
+ if (cli_write(cli1->tree, fnum2, 0, (void *)&x, 0, 1) == 1) {
res += A_W;
}
}
resultstr(denytable1[i].result));
}
- cli_close(cli1, fnum1);
- cli_close(cli1, fnum2);
+ cli_close(cli1->tree, fnum1);
+ cli_close(cli1->tree, fnum2);
}
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i]);
+ cli_unlink(cli1->tree, fnames[i]);
}
if (!torture_close_connection(cli1)) {
printf("Testing deny modes with 2 connections\n");
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i]);
- fnum1 = cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
- cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
- cli_close(cli1, fnum1);
+ cli_unlink(cli1->tree, fnames[i]);
+ fnum1 = cli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE);
+ cli_write(cli1->tree, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
+ cli_close(cli1->tree, fnum1);
}
for (i=0; i<ARRAY_SIZE(denytable2); i++) {
progress_bar(i, ARRAY_SIZE(denytable1));
- fnum1 = cli_open(cli1, fname,
+ fnum1 = cli_open(cli1->tree, fname,
denytable2[i].mode1,
denytable2[i].deny1);
- fnum2 = cli_open(cli2, fname,
+ fnum2 = cli_open(cli2->tree, fname,
denytable2[i].mode2,
denytable2[i].deny2);
} else {
char x = 1;
res = A_0;
- if (cli_read(cli2, fnum2, (void *)&x, 0, 1) == 1) {
+ if (cli_read(cli2->tree, fnum2, (void *)&x, 0, 1) == 1) {
res += A_R;
}
- if (cli_write(cli2, fnum2, 0, (void *)&x, 0, 1) == 1) {
+ if (cli_write(cli2->tree, fnum2, 0, (void *)&x, 0, 1) == 1) {
res += A_W;
}
}
resultstr(denytable2[i].result));
}
- cli_close(cli1, fnum1);
- cli_close(cli2, fnum2);
+ cli_close(cli1->tree, fnum1);
+ cli_close(cli2->tree, fnum2);
}
for (i=0;i<2;i++) {
- cli_unlink(cli1, fnames[i]);
+ cli_unlink(cli1->tree, fnames[i]);
}
if (!torture_close_connection(cli1)) {
for (h=0;h<options.max_open_handles;h++) {
if (!open_handles[h].active) continue;
for (i=0;i<NSERVERS;i++) {
- if (!cli_close(servers[i].cli[open_handles[h].instance],
+ if (!cli_close(servers[i].cli[open_handles[h].instance]->tree,
open_handles[h].server_fnum[i])) {
return False;
}
/* we have to force close a random handle */
h = random() % options.max_open_handles;
for (i=0;i<NSERVERS;i++) {
- if (!cli_close(servers[i].cli[open_handles[h].instance],
+ if (!cli_close(servers[i].cli[open_handles[h].instance]->tree,
open_handles[h].server_fnum[i])) {
printf("INTERNAL ERROR: Close failed when recovering handle! - %s\n",
- cli_errstr(servers[i].cli[open_handles[h].instance]));
+ cli_errstr(servers[i].cli[open_handles[h].instance]->tree));
}
}
printf("Recovered handle %d\n", h);
{
int i;
for (i=0;i<NSERVERS;i++) {
- int n = cli_deltree(servers[i].cli[0], "\\gentest");
+ int n = cli_deltree(servers[i].cli[0]->tree, "\\gentest");
if (n == -1) {
printf("Failed to wipe tree on server %d\n", i);
exit(1);
}
- if (!cli_mkdir(servers[i].cli[0], "\\gentest")) {
+ if (!cli_mkdir(servers[i].cli[0]->tree, "\\gentest")) {
printf("Failed to create \\gentest - %s\n",
- cli_errstr(servers[i].cli[0]));
+ cli_errstr(servers[i].cli[0]->tree));
exit(1);
}
if (n > 0) {
if (cli[server][conn]) {
for (f=0;f<NFILES;f++) {
if (fnum[server][conn][f] != -1) {
- cli_close(cli[server][conn], fnum[server][conn][f]);
+ cli_close(cli[server][conn]->tree, fnum[server][conn][f]);
fnum[server][conn][f] = -1;
}
}
case OP_LOCK:
/* set a lock */
for (server=0;server<NSERVERS;server++) {
- ret[server] = cli_lock64(cli[server][conn],
+ ret[server] = cli_lock64(cli[server][conn]->tree,
fnum[server][conn][f],
start, len, LOCK_TIMEOUT, op);
- status[server] = cli_nt_error(cli[server][conn]);
+ status[server] = cli_nt_error(cli[server][conn]->tree);
if (!exact_error_codes &&
NT_STATUS_EQUAL(status[server],
NT_STATUS_FILE_LOCK_CONFLICT)) {
case OP_UNLOCK:
/* unset a lock */
for (server=0;server<NSERVERS;server++) {
- ret[server] = cli_unlock64(cli[server][conn],
+ ret[server] = cli_unlock64(cli[server][conn]->tree,
fnum[server][conn][f],
start, len);
- status[server] = cli_nt_error(cli[server][conn]);
+ status[server] = cli_nt_error(cli[server][conn]->tree);
}
if (showall ||
(!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1]))) {
case OP_REOPEN:
/* reopen the file */
for (server=0;server<NSERVERS;server++) {
- cli_close(cli[server][conn], fnum[server][conn][f]);
+ cli_close(cli[server][conn]->tree, fnum[server][conn][f]);
fnum[server][conn][f] = -1;
}
for (server=0;server<NSERVERS;server++) {
- fnum[server][conn][f] = cli_open(cli[server][conn], FILENAME,
+ fnum[server][conn][f] = cli_open(cli[server][conn]->tree, FILENAME,
O_RDWR|O_CREAT,
DENY_NONE);
if (fnum[server][conn][f] == -1) {
for (conn=0;conn<NCONNECTIONS;conn++)
for (f=0;f<NFILES;f++) {
if (fnum[server][conn][f] != -1) {
- cli_close(cli[server][conn], fnum[server][conn][f]);
+ cli_close(cli[server][conn]->tree, fnum[server][conn][f]);
fnum[server][conn][f] = -1;
}
}
for (server=0;server<NSERVERS;server++) {
- cli_unlink(cli[server][0], FILENAME);
+ cli_unlink(cli[server][0]->tree, FILENAME);
}
}
for (server=0;server<NSERVERS;server++)
for (conn=0;conn<NCONNECTIONS;conn++)
for (f=0;f<NFILES;f++) {
- fnum[server][conn][f] = cli_open(cli[server][conn], FILENAME,
+ fnum[server][conn][f] = cli_open(cli[server][conn]->tree, FILENAME,
O_RDWR|O_CREAT,
DENY_NONE);
if (fnum[server][conn][f] == -1) {
total++;
- fnum = cli_open(cli, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = cli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", name, cli_errstr(cli));
+ printf("open of %s failed (%s)\n", name, cli_errstr(cli->tree));
return False;
}
- if (!cli_close(cli, fnum)) {
- printf("close of %s failed (%s)\n", name, cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum)) {
+ printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree));
return False;
}
/* get the short name */
- status = cli_qpathinfo_alt_name(cli, name, &shortname);
+ status = cli_qpathinfo_alt_name(cli->tree, name, &shortname);
if (!NT_STATUS_IS_OK(status)) {
- printf("query altname of %s failed (%s)\n", name, cli_errstr(cli));
+ printf("query altname of %s failed (%s)\n", name, cli_errstr(cli->tree));
return False;
}
snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname);
- if (!cli_unlink(cli, name2)) {
+ if (!cli_unlink(cli->tree, name2)) {
printf("unlink of %s (%s) failed (%s)\n",
- name2, name, cli_errstr(cli));
+ name2, name, cli_errstr(cli->tree));
return False;
}
/* recreate by short name */
- fnum = cli_open(cli, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = cli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli));
+ printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli->tree));
return False;
}
- if (!cli_close(cli, fnum)) {
- printf("close of %s failed (%s)\n", name, cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum)) {
+ printf("close of %s failed (%s)\n", name, cli_errstr(cli->tree));
return False;
}
/* and unlink by long name */
- if (!cli_unlink(cli, name)) {
+ if (!cli_unlink(cli->tree, name)) {
printf("unlink2 of %s (%s) failed (%s)\n",
- name, name2, cli_errstr(cli));
+ name, name2, cli_errstr(cli->tree));
failures++;
- cli_unlink(cli, name2);
+ cli_unlink(cli->tree, name2);
return True;
}
return False;
}
- cli_unlink(cli, "\\mangle_test\\*");
- cli_rmdir(cli, "\\mangle_test");
+ cli_unlink(cli->tree, "\\mangle_test\\*");
+ cli_rmdir(cli->tree, "\\mangle_test");
- if (!cli_mkdir(cli, "\\mangle_test")) {
+ if (!cli_mkdir(cli->tree, "\\mangle_test")) {
printf("ERROR: Failed to make directory\n");
return False;
}
}
}
- cli_unlink(cli, "\\mangle_test\\*");
- if (!cli_rmdir(cli, "\\mangle_test")) {
+ cli_unlink(cli->tree, "\\mangle_test\\*");
+ if (!cli_rmdir(cli->tree, "\\mangle_test")) {
printf("ERROR: Failed to remove directory\n");
return False;
}
f_info_hit = False;
- cli_list_new(cli, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
+ cli_list_new(cli->tree, mask,
+ FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
listfn, NULL);
if (f_info_hit) {
fstrcpy(res1, "---");
- fnum = cli_open(cli, file, O_CREAT|O_TRUNC|O_RDWR, 0);
+ fnum = cli_open(cli->tree, file, O_CREAT|O_TRUNC|O_RDWR, 0);
if (fnum == -1) {
DEBUG(0,("Can't create %s\n", file));
return;
}
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
resultp = res1;
fstrcpy(short_name, "");
get_real_name(cli, long_name, short_name);
fstrcpy(res1, "---");
- cli_list(cli, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
+ cli_list(cli->tree, mask,
+ FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
listfn, NULL);
res2 = reg_test(cli, mask, long_name, short_name);
if (die_on_error) exit(1);
}
- cli_unlink(cli, file);
+ cli_unlink(cli->tree, file);
if (count % 100 == 0) DEBUG(0,("%d\n", count));
}
int mc_len = strlen(maskchars);
int fc_len = strlen(filechars);
- cli_mkdir(cli, "\\masktest");
+ cli_mkdir(cli->tree, "\\masktest");
- cli_unlink(cli, "\\masktest\\*");
+ cli_unlink(cli->tree, "\\masktest\\*");
if (argc >= 2) {
while (argc >= 2) {
}
finished:
- cli_rmdir(cli, "\\masktest");
+ cli_rmdir(cli->tree, "\\masktest");
}
void nb_unlink(const char *fname)
{
- if (!cli_unlink(c, fname)) {
+ if (!cli_unlink(c->tree, fname)) {
#if NBDEBUG
printf("(%d) unlink %s failed (%s)\n",
line_count, fname, cli_errstr(c));
desired_access = SA_RIGHT_FILE_READ_DATA | SA_RIGHT_FILE_WRITE_DATA;
}
- fd = cli_nt_create_full(c, fname, 0,
+ fd = cli_nt_create_full(c->tree, fname, 0,
desired_access,
0x0,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE,
create_options, 0);
if (fd == -1 && handle != -1) {
printf("ERROR: cli_nt_create_full failed for %s - %s\n",
- fname, cli_errstr(c));
+ fname, cli_errstr(c->tree));
exit(1);
}
if (fd != -1 && handle == -1) {
if (buf[0] == 0) memset(buf, 1, sizeof(buf));
i = find_handle(handle);
- if (!bypass_io && cli_write(c, ftable[i].fd, 0, buf, offset, size) != ret_size) {
+ if (!bypass_io && cli_write(c->tree, ftable[i].fd, 0, buf, offset, size) != ret_size) {
printf("(%d) ERROR: write failed on handle %d, fd %d \
errno %d (%s)\n", line_count, handle, ftable[i].fd, errno, strerror(errno));
exit(1);
int i, ret;
i = find_handle(handle);
- if (!bypass_io && (ret=cli_read(c, ftable[i].fd, buf, offset, size)) != ret_size) {
+ if (!bypass_io && (ret=cli_read(c->tree, ftable[i].fd, buf, offset, size)) != ret_size) {
printf("(%d) ERROR: read failed on handle %d ofs=%d size=%d res=%d fd %d errno %d (%s)\n",
line_count, handle, offset, size, ret, ftable[i].fd, errno, strerror(errno));
exit(1);
{
int i;
i = find_handle(handle);
- if (!cli_close(c, ftable[i].fd)) {
+ if (!cli_close(c->tree, ftable[i].fd)) {
printf("(%d) close failed on handle %d\n", line_count, handle);
exit(1);
}
void nb_rmdir(const char *fname)
{
- if (!cli_rmdir(c, fname)) {
+ if (!cli_rmdir(c->tree, fname)) {
printf("ERROR: rmdir %s failed (%s)\n",
- fname, cli_errstr(c));
+ fname, cli_errstr(c->tree));
exit(1);
}
}
void nb_rename(const char *old, const char *new)
{
- if (!cli_rename(c, old, new)) {
+ if (!cli_rename(c->tree, old, new)) {
printf("ERROR: rename %s %s failed (%s)\n",
- old, new, cli_errstr(c));
+ old, new, cli_errstr(c->tree));
exit(1);
}
}
void nb_qpathinfo(const char *fname)
{
- cli_qpathinfo(c, fname, NULL, NULL, NULL, NULL, NULL);
+ cli_qpathinfo(c->tree, fname, NULL, NULL, NULL, NULL, NULL);
}
void nb_qfileinfo(int fnum)
{
int i;
i = find_handle(fnum);
- cli_qfileinfo(c, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ cli_qfileinfo(c->tree, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
void nb_qfsinfo(int level)
{
int bsize, total, avail;
/* this is not the right call - we need cli_qfsinfo() */
- cli_dskattr(c, &bsize, &total, &avail);
+ cli_dskattr(c->tree, &bsize, &total, &avail);
}
static void find_fn(file_info *finfo, const char *name, void *state)
void nb_findfirst(const char *mask)
{
- cli_list(c, mask, 0, find_fn, NULL);
+ cli_list(c->tree, mask, 0, find_fn, NULL);
}
void nb_flush(int fnum)
{
int total_deleted;
- total_deleted = cli_deltree(c, dname);
+ total_deleted = cli_deltree(c->tree, dname);
if (total_deleted == -1) {
printf("Failed to cleanup tree %s - exiting\n", dname);
void nb_cleanup(void)
{
- cli_rmdir(c, "clients");
+ cli_rmdir(c->tree, "clients");
children[nbio_id].done = 1;
}
fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\test.txt");
if (fnum == -1) {
- printf("failed to open test.txt - %s\n", cli_errstr(cli));
+ printf("failed to open test.txt - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
return ret;
}
mem_ctx = talloc_init("torture_raw_chkpath");
- 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;
}
}
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
}
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
REOPEN;
finfo2.generic.in.fname = fname;
CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
printf("testing flush\n");
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
io_flush.in.fnum = fnum;
status = smb_raw_flush(cli->tree, &io_flush);
done:
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
printf("TESTING SESSION HANDLING\n");
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("TESTING TREE HANDLING\n");
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("TESTING PID HANDLING\n");
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
}
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("Failed to create test.dat - %s\n", cli_errstr(cli));
+ printf("Failed to create test.dat - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_UNSUCCESSFUL);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
return ret;
}
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("Failed to create test.dat - %s\n", cli_errstr(cli));
+ printf("Failed to create test.dat - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
#endif
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
return ret;
}
mem_ctx = talloc_init("torture_raw_ioctl");
- 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;
}
}
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
int fnum;
const char *fname = BASEDIR "\\test.txt";
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_LOCK_LOCK\n");
io.generic.level = RAW_LOCK_LOCK;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
int fnum;
const char *fname = BASEDIR "\\test.txt";
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_LOCK_LOCKX\n");
io.generic.level = RAW_LOCK_LOCKX;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
const char *fname = BASEDIR "\\test.txt";
char c = 1;
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
cli->session->pid = 1;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
- if (cli_write(cli, fnum, 0, &c, 0, 1) != 1) {
- printf("Failed to write 1 byte - %s\n", cli_errstr(cli));
+ if (cli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) {
+ printf("Failed to write 1 byte - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- if (cli_read(cli, fnum, &c, 0, 1) != 1) {
- printf("Failed to read 1 byte - %s\n", cli_errstr(cli));
+ if (cli_read(cli->tree, fnum, &c, 0, 1) != 1) {
+ printf("Failed to read 1 byte - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
cli->session->pid = 2;
- if (cli_read(cli, fnum, &c, 0, 1) == 1) {
+ if (cli_read(cli->tree, fnum, &c, 0, 1) == 1) {
printf("pid is incorrect handled for read with lock!\n");
ret = False;
goto done;
cli->session->pid = 0x10001;
- if (cli_read(cli, fnum, &c, 0, 1) != 1) {
+ if (cli_read(cli->tree, fnum, &c, 0, 1) != 1) {
printf("High pid is used on this server!\n");
ret = False;
} else {
}
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
BOOL ret = True;
/* cleanup */
- cli_rmdir(cli, path);
- cli_unlink(cli, path);
+ cli_rmdir(cli->tree, path);
+ cli_unlink(cli->tree, path);
/*
basic mkdir
printf("testing mkdir collision with file\n");
/* name collision with a file */
- cli_close(cli, create_complex_file(cli, mem_ctx, path));
+ cli_close(cli->tree, create_complex_file(cli, mem_ctx, path));
status = smb_raw_mkdir(cli->tree, &md);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION);
status = smb_raw_rmdir(cli->tree, &rd);
CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
- cli_unlink(cli, path);
+ cli_unlink(cli->tree, path);
printf("testing invalid dir\n");
done:
- cli_rmdir(cli, path);
- cli_unlink(cli, path);
+ cli_rmdir(cli->tree, path);
+ cli_unlink(cli->tree, path);
return ret;
}
req = smb_raw_open_send(cli->tree, &io);
/* and close the file */
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
/* see if the async open succeeded */
status = smb_raw_open_recv(req, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- cli_close(cli, io.ntcreatex.out.fnum);
+ cli_close(cli->tree, io.ntcreatex.out.fnum);
done:
return ret;
printf("testing multiplexed lock/write/close\n");
- fnum = cli_open(cli, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("open failed in mux_write - %s\n", cli_errstr(cli));
+ printf("open failed in mux_write - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
cli->session->pid = 1;
/* lock a range */
- if (!cli_lock(cli, fnum, 0, 4, 0, WRITE_LOCK)) {
- printf("lock failed in mux_write - %s\n", cli_errstr(cli));
+ if (!cli_lock(cli->tree, fnum, 0, 4, 0, WRITE_LOCK)) {
+ printf("lock failed in mux_write - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
/* unlock the range */
cli->session->pid = 1;
- cli_unlock(cli, fnum, 0, 4);
+ cli_unlock(cli->tree, fnum, 0, 4);
/* and recv the async write reply */
status = smb_raw_write_recv(req, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
done:
return ret;
printf("TESTING MULTIPLEXED LOCK/LOCK/UNLOCK\n");
- fnum = cli_open(cli, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("open failed in mux_write - %s\n", cli_errstr(cli));
+ printf("open failed in mux_write - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
printf("reopening with an exit\n");
smb_raw_exit(cli->session);
- fnum = cli_open(cli, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE);
printf("Now trying with a cancel\n");
status = cli_request_simple_recv(req);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
done:
return ret;
mem_ctx = talloc_init("torture_raw_mux");
/* cleanup */
- if (cli_deltree(cli, BASEDIR) == -1) {
+ if (cli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to cleanup " BASEDIR "\n");
ret = False;
goto done;
}
- if (!cli_mkdir(cli, BASEDIR)) {
+ if (!cli_mkdir(cli->tree, BASEDIR)) {
printf("Failed to create %s\n", BASEDIR);
ret = False;
goto done;
done:
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
mem_ctx = talloc_init("torture_raw_notify");
/* cleanup */
- if (cli_deltree(cli, BASEDIR) == -1) {
+ if (cli_deltree(cli->tree, BASEDIR) == -1) {
printf("Failed to cleanup " BASEDIR "\n");
ret = False;
goto done;
printf("testing notify mkdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
- cli_mkdir(cli, BASEDIR "\\subdir-name");
+ cli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
printf("testing notify rmdir\n");
req = smb_raw_changenotify_send(cli->tree, ¬ify);
- cli_rmdir(cli, BASEDIR "\\subdir-name");
+ cli_rmdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_OK);
req = smb_raw_changenotify_send(cli->tree, ¬ify);
smb_raw_ntcancel(req);
- cli_mkdir(cli, BASEDIR "\\subdir-name");
+ cli_mkdir(cli->tree, BASEDIR "\\subdir-name");
status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify);
CHECK_STATUS(status, NT_STATUS_CANCELLED);
done:
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
return ret;
/*
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;
#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)); \
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);
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;
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;
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 */
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;
}
};
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;
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);
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);
}
}
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);
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);
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);
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;
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;
__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;
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;
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;
}
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);
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);
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);
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;
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;
}
/* 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);
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);
}
}
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);
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 */
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;
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;
}
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;
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;
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;
}
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;
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;
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;
}
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;
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;
}
}
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
uint16 fnum, fnum2;
/* cleanup */
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
/*
with a batch oplock we get a break
CHECK_VAL(break_info.count, 1);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
printf("if we close on break then the unlink can succeed\n");
ZERO_STRUCT(break_info);
printf("a self read should not cause a break\n");
ZERO_STRUCT(break_info);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
printf("a 2nd open should give a break\n");
ZERO_STRUCT(break_info);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
cli_oplock_handler(cli->transport, oplock_handler_ack, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
printf("a 2nd open should get an oplock when we close instead of ack\n");
ZERO_STRUCT(break_info);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
cli_oplock_handler(cli->transport, oplock_handler_close, cli->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
done:
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
return ret;
}
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);
/* and make sure we can open by alternate name */
- cli_close(cli, fnum);
- fnum = cli_nt_create_full(cli, correct_name, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ cli_close(cli->tree, fnum);
+ fnum = cli_nt_create_full(cli->tree, correct_name, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
NTCREATEX_DISP_OVERWRITE_IF,
0, 0);
if (fnum == -1) {
- printf("Unable to open by alt_name - %s\n", cli_errstr(cli));
+ printf("Unable to open by alt_name - %s\n", cli_errstr(cli->tree));
ret = False;
}
done:
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
torture_close_connection(cli);
talloc_destroy(mem_ctx);
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_READ\n");
io.generic.level = RAW_READ_READ;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io.read.in.fnum = fnum;
- cli_write(cli, fnum, 0, test_data, 0, strlen(test_data));
+ cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.read.in.fnum = fnum;
CHECK_VALUE(io.read.out.nread, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli, fnum, 0, buf, 0, maxsize);
+ cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
printf("Trying locked region\n");
cli->session->pid++;
- if (!cli_lock(cli, fnum, 103, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK)) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_LOCKREAD\n");
io.generic.level = RAW_READ_LOCKREAD;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io.lockread.in.fnum = fnum;
- cli_write(cli, fnum, 0, test_data, 0, strlen(test_data));
+ cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.lockread.in.fnum = fnum;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- cli_unlock(cli, fnum, 0, 1);
+ cli_unlock(cli->tree, fnum, 0, 1);
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
io.lockread.in.count = strlen(test_data);
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
- cli_unlock(cli, fnum, 0, strlen(test_data));
+ cli_unlock(cli->tree, fnum, 0, strlen(test_data));
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.lockread.out.nread, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli, fnum, 0, buf, 0, maxsize);
+ cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
io.lockread.in.count = ~0;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
- cli_unlock(cli, fnum, 1, strlen(test_data));
+ cli_unlock(cli->tree, fnum, 1, strlen(test_data));
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_BUFFER(buf, seed, io.lockread.out.nread);
- cli_unlock(cli, fnum, 0, 0xFFFF);
+ cli_unlock(cli->tree, fnum, 0, 0xFFFF);
printf("Trying locked region\n");
cli->session->pid++;
- if (!cli_lock(cli, fnum, 103, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK)) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
done:
- cli_close(cli, fnum);
- cli_deltree(cli, BASEDIR);
+ cli_close(cli->tree, fnum);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_READX\n");
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io.readx.in.fnum = fnum;
- cli_write(cli, fnum, 0, test_data, 0, strlen(test_data));
+ cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.readx.in.fnum = fnum;
CHECK_VALUE(io.readx.out.compaction_mode, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli, fnum, 0, buf, 0, maxsize);
+ cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
printf("Trying locked region\n");
cli->session->pid++;
- if (!cli_lock(cli, fnum, 103, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK)) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.readx.out.nread, 0);
- if (!cli_lock64(cli, fnum, io.readx.in.offset, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock64(cli->tree, fnum, io.readx.in.offset, 1, 0, WRITE_LOCK)) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
#endif
done:
- cli_close(cli, fnum);
- cli_deltree(cli, BASEDIR);
+ cli_close(cli->tree, fnum);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_READ_READBRAW\n");
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.readbraw.out.nread, 0);
io.readbraw.in.fnum = fnum;
- cli_write(cli, fnum, 0, test_data, 0, strlen(test_data));
+ cli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data));
printf("Trying small read\n");
io.readbraw.in.fnum = fnum;
CHECK_VALUE(io.readbraw.out.nread, 0);
setup_buffer(buf, seed, maxsize);
- cli_write(cli, fnum, 0, buf, 0, maxsize);
+ cli_write(cli->tree, fnum, 0, buf, 0, maxsize);
memset(buf, 0, maxsize);
printf("Trying large read\n");
printf("Trying locked region\n");
cli->session->pid++;
- if (!cli_lock(cli, fnum, 103, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK)) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
#endif
done:
- cli_close(cli, fnum);
- cli_deltree(cli, BASEDIR);
+ cli_close(cli->tree, fnum);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
printf("Testing SMBmv\n");
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
CHECK_STATUS(status, NT_STATUS_OK);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
printf("Testing SMBntrename\n");
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL);
- cli_unlink(cli, fname2);
+ cli_unlink(cli->tree, fname2);
finfo.generic.in.fname = fname1;
status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL);
- cli_unlink(cli, fname2);
+ cli_unlink(cli->tree, fname2);
finfo.generic.in.fname = fname1;
status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
#if 0
{
char buf[16384];
- fnum = cli_open(cli, fname1, O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname1, O_RDWR, DENY_NONE);
memset(buf, 1, sizeof(buf));
- cli_write(cli, fnum, 0, buf, 0, sizeof(buf));
- cli_close(cli, fnum);
+ cli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
+ cli_close(cli->tree, fnum);
- fnum = cli_open(cli, fname2, O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname2, O_RDWR, DENY_NONE);
memset(buf, 1, sizeof(buf));
- cli_write(cli, fnum, 0, buf, 0, sizeof(buf)-1);
- cli_close(cli, fnum);
+ cli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf)-1);
+ cli_close(cli->tree, fnum);
torture_all_info(cli->tree, fname1);
torture_all_info(cli->tree, fname2);
done:
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
fnum = create_complex_file(cli, mem_ctx, fname);
if (fnum == -1) {
- printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("ERROR: open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
done:
smb_raw_exit(cli->session);
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
return ret;
}
{"SEARCH", "ID", RAW_SEARCH_SEARCH, CONT_RESUME_KEY}
};
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Failed to create " BASEDIR " - %s\n", cli_errstr(cli->tree));
return False;
}
for (i=0;i<num_files;i++) {
asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
- fnum = cli_open(cli, fname, O_CREAT|O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
free(fname);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
}
done:
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
const char *fname = BASEDIR "\\test.txt";
char c[2];
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
if (fnum == -1) {
- printf("Failed to open test.txt - %s\n", cli_errstr(cli));
+ printf("Failed to open test.txt - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
printf("trying write to update offset\n");
ZERO_STRUCT(c);
- if (cli_write(cli, fnum, 0, c, 0, 2) != 2) {
- printf("Write failed - %s\n", cli_errstr(cli));
+ if (cli_write(cli->tree, fnum, 0, c, 0, 2) != 2) {
+ printf("Write failed - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.out.offset, 2);
- if (cli_read(cli, fnum, c, 0, 1) != 1) {
- printf("Read failed - %s\n", cli_errstr(cli));
+ if (cli_read(cli->tree, fnum, c, 0, 1) != 1) {
+ printf("Read failed - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.out.offset, 1);
printf("Testing position information\n");
- fnum2 = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum2 = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("2nd open failed - %s\n", cli_errstr(cli));
+ printf("2nd open failed - %s\n", cli_errstr(cli->tree));
ret = False;
goto done;
}
done:
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
mem_ctx = talloc_init("torture_sfileinfo");
- cli_deltree(cli, BASEDIR);
- cli_mkdir(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
+ cli_mkdir(cli->tree, BASEDIR);
#define RECREATE_FILE(fname) do { \
- if (fnum != -1) cli_close(cli, fnum); \
+ if (fnum != -1) cli_close(cli->tree, fnum); \
fnum = create_complex_file(cli, mem_ctx, fname); \
if (fnum == -1) { \
printf("(%d) ERROR: open of %s failed (%s)\n", \
- __LINE__, fname, cli_errstr(cli)); \
+ __LINE__, fname, cli_errstr(cli->tree)); \
ret = False; \
goto done; \
}} while (0)
#define RECREATE_BOTH do { \
RECREATE_FILE(path_fname); \
- cli_close(cli, fnum); \
+ cli_close(cli->tree, fnum); \
RECREATE_FILE(fnum_fname); \
} while (0)
CHECK_VALUE(MODE_INFORMATION, mode_information, mode, 0);
#if 1
printf("finally the rename_information level\n");
- cli_close(cli, create_complex_file(cli, mem_ctx, fnum_fname_new));
- cli_close(cli, create_complex_file(cli, mem_ctx, path_fname_new));
+ cli_close(cli->tree, create_complex_file(cli, mem_ctx, fnum_fname_new));
+ cli_close(cli->tree, create_complex_file(cli, mem_ctx, path_fname_new));
sfinfo.rename_information.in.overwrite = 0;
sfinfo.rename_information.in.root_fid = 0;
printf("Trying rename with dest file open and delete_on_close\n");
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_ACCESS_DENIED);
- cli_close(cli, fnum2);
+ cli_close(cli->tree, fnum2);
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
sfinfo.rename_information.in.overwrite = 0;
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new);
- cli_close(cli, fnum2);
+ cli_close(cli->tree, fnum2);
sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1;
sfinfo.rename_information.in.overwrite = 0;
done:
smb_raw_exit(cli->session);
- cli_close(cli, fnum);
- if (!cli_unlink(cli, fnum_fname)) {
- printf("Failed to delete %s - %s\n", fnum_fname, cli_errstr(cli));
+ cli_close(cli->tree, fnum);
+ if (!cli_unlink(cli->tree, fnum_fname)) {
+ printf("Failed to delete %s - %s\n", fnum_fname, cli_errstr(cli->tree));
}
- if (!cli_unlink(cli, path_fname)) {
- printf("Failed to delete %s - %s\n", path_fname, cli_errstr(cli));
+ if (!cli_unlink(cli->tree, path_fname)) {
+ printf("Failed to delete %s - %s\n", path_fname, cli_errstr(cli->tree));
}
torture_close_connection(cli);
mem_ctx = talloc_init("torture_sfileinfo");
fnum = create_complex_file(cli, mem_ctx, fname);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
sfinfo.generic.level = RAW_SFILEINFO_STANDARD;
sfinfo.generic.file.fname = fname;
BOOL ret = True;
const char *fname = BASEDIR "\\test.txt";
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
status = smb_raw_unlink(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
- cli_close(cli, cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE));
+ cli_close(cli->tree, cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
io.in.pattern = fname;
io.in.attrib = 0;
CHECK_STATUS(status, NT_STATUS_OK);
printf("Trying a hidden file\n");
- cli_close(cli, cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE));
+ cli_close(cli->tree, cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
torture_set_file_attribute(cli->tree, fname, FILE_ATTRIBUTE_HIDDEN);
io.in.pattern = fname;
CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
printf("Trying wildcards\n");
- cli_close(cli, cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE));
+ cli_close(cli->tree, cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE));
io.in.pattern = BASEDIR "\\t*.t";
io.in.attrib = 0;
status = smb_raw_unlink(cli->tree, &io);
done:
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITE\n");
io.generic.level = RAW_WRITE_WRITE;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.write.out.nwritten, io.write.in.count);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 13) != 13) {
+ if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.write.out.nwritten, 4000);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_ALL_INFO(io.write.in.count + (SMB_BIG_UINT)io.write.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, io.write.in.offset, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_BUFFER(buf, seed, 4000);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITEX\n");
io.generic.level = RAW_WRITE_WRITEX;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
CHECK_VALUE(io.writex.out.nwritten, io.writex.in.count);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 13) != 13) {
+ if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.writex.out.nwritten, 4000);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
printf("Trying locked region\n");
cli->session->pid++;
- if (!cli_lock(cli, fnum, 3, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK)) {
printf("Failed to lock file at %d\n", __LINE__);
ret = False;
goto done;
CHECK_ALL_INFO(io.writex.in.count + (SMB_BIG_UINT)io.writex.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, io.writex.in.offset, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_ALL_INFO(io.writex.in.count + (SMB_BIG_UINT)io.writex.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, io.writex.in.offset, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
setup_buffer(buf, seed, maxsize);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITEUNLOCK\n");
io.generic.level = RAW_WRITE_WRITEUNLOCK;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
io.writeunlock.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
- if (cli_read(cli, fnum, buf, 0, 13) != 13) {
+ if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(IVAL(buf,0), 0);
setup_buffer(buf, seed, maxsize);
- cli_lock(cli, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
+ cli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
0, WRITE_LOCK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeunlock.out.nwritten, io.writeunlock.in.count);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 13) != 13) {
+ if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
io.writeunlock.in.count = 4000;
io.writeunlock.in.offset = 0;
io.writeunlock.in.data = buf;
- cli_lock(cli, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
+ cli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
0, WRITE_LOCK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
io.writeunlock.in.count = 4000;
io.writeunlock.in.offset = 0xFFFFFFFF - 2000;
io.writeunlock.in.data = buf;
- cli_lock(cli, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
+ cli_lock(cli->tree, fnum, io.writeunlock.in.offset, io.writeunlock.in.count,
0, WRITE_LOCK);
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_ALL_INFO(io.writeunlock.in.count + (SMB_BIG_UINT)io.writeunlock.in.offset, size);
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_BUFFER(buf, seed, 4000);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
buf = talloc_zero(mem_ctx, maxsize);
- if (cli_deltree(cli, BASEDIR) == -1 ||
- !cli_mkdir(cli, BASEDIR)) {
- printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli));
+ if (cli_deltree(cli->tree, BASEDIR) == -1 ||
+ !cli_mkdir(cli->tree, BASEDIR)) {
+ printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli->tree));
return False;
}
printf("Testing RAW_WRITE_WRITECLOSE\n");
io.generic.level = RAW_WRITE_WRITECLOSE;
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
- printf("Failed to create %s - %s\n", fname, cli_errstr(cli));
+ printf("Failed to create %s - %s\n", fname, cli_errstr(cli->tree));
ret = False;
goto done;
}
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
- fnum = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
- if (cli_read(cli, fnum, buf, 0, 13) != 13) {
+ if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.writeclose.out.nwritten, io.writeclose.in.count);
- fnum = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 13) != 13) {
+ if (cli_read(cli->tree, fnum, buf, 0, 13) != 13) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
- fnum = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, 0, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_VALUE(io.writeclose.out.nwritten, 4000);
CHECK_ALL_INFO(io.writeclose.in.count + (SMB_BIG_UINT)io.writeclose.in.offset, size);
- fnum = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
io.writeclose.in.fnum = fnum;
memset(buf, 0, maxsize);
- if (cli_read(cli, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
+ if (cli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {
printf("read failed at %d\n", __LINE__);
ret = False;
goto done;
CHECK_BUFFER(buf, seed, 4000);
done:
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
- cli_deltree(cli, BASEDIR);
+ cli_deltree(cli->tree, BASEDIR);
return ret;
}
status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_unlink(cli, "\\newfile.dat");
- cli_rmdir(cli, "\\newfile.dat");
+ cli_unlink(cli->tree, "\\newfile.dat");
+ cli_rmdir(cli->tree, "\\newfile.dat");
if (NT_STATUS_IS_OK(status)) return True;
/* try dfs style */
- cli_mkdir(cli, "\\testdir");
+ cli_mkdir(cli->tree, "\\testdir");
param_len = 2;
SSVAL(param, 0, level);
param_len += push_string(NULL, ¶m[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE);
status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_rmdir(cli, "\\testdir");
+ cli_rmdir(cli->tree, "\\testdir");
if (NT_STATUS_IS_OK(status)) return True;
return False;
return False;
}
- fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
if (fnum == -1) {
- printf("file open failed - %s\n", cli_errstr(cli));
+ printf("file open failed - %s\n", cli_errstr(cli->tree));
}
- dnum = cli_nt_create_full(cli, "\\",
+ dnum = cli_nt_create_full(cli->tree, "\\",
0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE,
NTCREATEX_DISP_OPEN,
NTCREATEX_OPTIONS_DIRECTORY, 0);
if (dnum == -1) {
- printf("directory open failed - %s\n", cli_errstr(cli));
+ printf("directory open failed - %s\n", cli_errstr(cli->tree));
}
- qfnum = cli_nt_create_full(cli, "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION",
+ qfnum = cli_nt_create_full(cli->tree, "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION",
NTCREATEX_FLAGS_EXTENDED,
SEC_RIGHTS_MAXIMUM_ALLOWED,
0,
NTCREATEX_DISP_OPEN,
0, 0);
if (qfnum == -1) {
- printf("quota open failed - %s\n", cli_errstr(cli));
+ printf("quota open failed - %s\n", cli_errstr(cli->tree));
}
for (op=OP_MIN; op<=OP_MAX; op++) {
status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_unlink(cli, "\\newfile.dat");
- cli_rmdir(cli, "\\newfile.dat");
+ cli_unlink(cli->tree, "\\newfile.dat");
+ cli_rmdir(cli->tree, "\\newfile.dat");
if (NT_STATUS_IS_OK(status)) return True;
/* try dfs style */
- cli_mkdir(cli, "\\testdir");
+ cli_mkdir(cli->tree, "\\testdir");
param_len = 2;
SSVAL(param, 0, level);
param_len += push_string(NULL, ¶m[2], "\\testdir", -1, STR_TERMINATE | STR_UNICODE);
status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len,
&rparam_len, &rdata_len);
- cli_rmdir(cli, "\\testdir");
+ cli_rmdir(cli->tree, "\\testdir");
if (NT_STATUS_IS_OK(status)) return True;
return False;
return False;
}
- fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
+ fnum = cli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
DENY_NONE);
- dnum = cli_open(cli, "\\", O_RDONLY, DENY_NONE);
+ dnum = cli_open(cli->tree, "\\", O_RDONLY, DENY_NONE);
for (op=OP_MIN; op<=OP_MAX; op++) {
printf("Scanning op=%d\n", op);
DEBUG(9,("torture_close_connection: cli_state@%p\n", c));
if (!c) return True;
if (!cli_tdis(c)) {
- printf("tdis failed (%s)\n", cli_errstr(c));
+ printf("tdis failed (%s)\n", cli_errstr(c->tree));
ret = False;
}
DEBUG(9,("torture_close_connection: call cli_shutdown\n"));
static BOOL check_error(int line, struct cli_state *c,
uint8 eclass, uint32 ecode, NTSTATUS nterr)
{
- if (cli_is_dos_error(c)) {
+ if (cli_is_dos_error(c->tree)) {
uint8 class;
uint32 num;
/* Check NT error */
- status = cli_nt_error(c);
+ status = cli_nt_error(c->tree);
if (NT_STATUS_V(nterr) != NT_STATUS_V(status)) {
printf("unexpected error code %s\n", nt_errstr(status));
static BOOL wait_lock(struct cli_state *c, int fnum, uint32 offset, uint32 len)
{
- while (!cli_lock(c, fnum, offset, len, -1, WRITE_LOCK)) {
+ while (!cli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK)) {
if (!check_error(__LINE__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
return True;
char buf[1024];
BOOL correct = True;
- fnum2 = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ fnum2 = cli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
if (fnum2 == -1)
- fnum2 = cli_open(c, lockfname, O_RDWR, DENY_NONE);
+ fnum2 = cli_open(c->tree, lockfname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open of %s failed (%s)\n", lockfname, cli_errstr(c));
+ printf("open of %s failed (%s)\n", lockfname, cli_errstr(c->tree));
return False;
}
return False;
}
- fnum = cli_open(c, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL);
+ fnum = cli_open(c->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL);
if (fnum == -1) {
- printf("open failed (%s)\n", cli_errstr(c));
+ printf("open failed (%s)\n", cli_errstr(c->tree));
correct = False;
break;
}
- if (cli_write(c, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
- printf("write failed (%s)\n", cli_errstr(c));
+ if (cli_write(c->tree, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
+ printf("write failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
for (j=0;j<50;j++) {
- if (cli_write(c, fnum, 0, (char *)buf,
+ if (cli_write(c->tree, fnum, 0, (char *)buf,
sizeof(pid)+(j*sizeof(buf)),
sizeof(buf)) != sizeof(buf)) {
- printf("write failed (%s)\n", cli_errstr(c));
+ printf("write failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
}
pid2 = 0;
- if (cli_read(c, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
- printf("read failed (%s)\n", cli_errstr(c));
+ if (cli_read(c->tree, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
+ printf("read failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
correct = False;
}
- if (!cli_close(c, fnum)) {
- printf("close failed (%s)\n", cli_errstr(c));
+ if (!cli_close(c->tree, fnum)) {
+ printf("close failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
- if (!cli_unlink(c, fname)) {
- printf("unlink failed (%s)\n", cli_errstr(c));
+ if (!cli_unlink(c->tree, fname)) {
+ printf("unlink failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
- if (!cli_unlock(c, fnum2, n*sizeof(int), sizeof(int))) {
- printf("unlock failed (%s)\n", cli_errstr(c));
+ if (!cli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int))) {
+ printf("unlock failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
free(fname);
}
- cli_close(c, fnum2);
- cli_unlink(c, lockfname);
+ cli_close(c->tree, fnum2);
+ cli_unlink(c->tree, lockfname);
printf("%d\n", i);
if (procnum == 0)
{
- fnum = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
- DENY_NONE);
+ fnum = cli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ DENY_NONE);
if (fnum == -1) {
printf("first open read/write of %s failed (%s)\n",
- lockfname, cli_errstr(c));
+ lockfname, cli_errstr(c->tree));
return False;
}
}
{
for (i = 0; i < 500 && fnum == -1; i++)
{
- fnum = cli_open(c, lockfname, O_RDONLY,
- DENY_NONE);
+ fnum = cli_open(c->tree, lockfname, O_RDONLY,
+ DENY_NONE);
msleep(10);
}
if (fnum == -1) {
printf("second open read-only of %s failed (%s)\n",
- lockfname, cli_errstr(c));
+ lockfname, cli_errstr(c->tree));
return False;
}
}
sent = sizeof(buf) - count;
}
- if (cli_write(c, fnum, 0, buf+count, count, (size_t)sent) != sent) {
- printf("write failed (%s)\n", cli_errstr(c));
+ if (cli_write(c->tree, fnum, 0, buf+count, count, (size_t)sent) != sent) {
+ printf("write failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
}
else
{
- sent = cli_read(c, fnum, buf_rd+count, count,
- sizeof(buf)-count);
+ sent = cli_read(c->tree, fnum, buf_rd+count, count,
+ sizeof(buf)-count);
if (sent < 0)
{
printf("read failed offset:%d size:%d (%s)\n",
count, sizeof(buf)-count,
- cli_errstr(c));
+ cli_errstr(c->tree));
correct = False;
sent = 0;
}
}
- if (!cli_close(c, fnum)) {
- printf("close failed (%s)\n", cli_errstr(c));
+ if (!cli_close(c->tree, fnum)) {
+ printf("close failed (%s)\n", cli_errstr(c->tree));
correct = False;
}
BOOL correct = True;
ssize_t bytes_read, bytes_written;
- if (cli_deltree(c1, lockfname) == -1) {
- printf("unlink failed (%s)\n", cli_errstr(c1));
+ if (cli_deltree(c1->tree, lockfname) == -1) {
+ printf("unlink failed (%s)\n", cli_errstr(c1->tree));
}
- fnum1 = cli_open(c1, lockfname, O_RDWR | O_CREAT | O_EXCL,
+ fnum1 = cli_open(c1->tree, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
if (fnum1 == -1) {
printf("first open read/write of %s failed (%s)\n",
- lockfname, cli_errstr(c1));
+ lockfname, cli_errstr(c1->tree));
return False;
}
- fnum2 = cli_open(c2, lockfname, O_RDONLY,
+ fnum2 = cli_open(c2->tree, lockfname, O_RDONLY,
DENY_NONE);
if (fnum2 == -1) {
printf("second open read-only of %s failed (%s)\n",
- lockfname, cli_errstr(c2));
- cli_close(c1, fnum1);
+ lockfname, cli_errstr(c2->tree));
+ cli_close(c1->tree, fnum1);
return False;
}
generate_random_buffer(buf, buf_size, False);
- if ((bytes_written = cli_write(c1, fnum1, 0, buf, 0, buf_size)) != buf_size) {
- printf("write failed (%s)\n", cli_errstr(c1));
+ if ((bytes_written = cli_write(c1->tree, fnum1, 0, buf, 0, buf_size)) != buf_size) {
+ printf("write failed (%s)\n", cli_errstr(c1->tree));
printf("wrote %d, expected %d\n", bytes_written, buf_size);
correct = False;
break;
}
- if ((bytes_read = cli_read(c2, fnum2, buf_rd, 0, buf_size)) != buf_size) {
- printf("read failed (%s)\n", cli_errstr(c2));
+ if ((bytes_read = cli_read(c2->tree, fnum2, buf_rd, 0, buf_size)) != buf_size) {
+ printf("read failed (%s)\n", cli_errstr(c2->tree));
printf("read %d, expected %d\n", bytes_read, buf_size);
correct = False;
break;
}
}
- if (!cli_close(c2, fnum2)) {
- printf("close failed (%s)\n", cli_errstr(c2));
+ if (!cli_close(c2->tree, fnum2)) {
+ printf("close failed (%s)\n", cli_errstr(c2->tree));
correct = False;
}
- if (!cli_close(c1, fnum1)) {
- printf("close failed (%s)\n", cli_errstr(c1));
+ if (!cli_close(c1->tree, fnum1)) {
+ printf("close failed (%s)\n", cli_errstr(c1->tree));
correct = False;
}
- if (!cli_unlink(c1, lockfname)) {
- printf("unlink failed (%s)\n", cli_errstr(c1));
+ if (!cli_unlink(c1->tree, lockfname)) {
+ printf("unlink failed (%s)\n", cli_errstr(c1->tree));
correct = False;
}
printf("starting locktest1\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- fnum2 = cli_open(cli1, fname, O_RDWR, DENY_NONE);
+ fnum2 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- fnum3 = cli_open(cli2, fname, O_RDWR, DENY_NONE);
+ fnum3 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum3 == -1) {
- printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
return False;
}
- if (!cli_lock(cli1, fnum1, 0, 4, 0, WRITE_LOCK)) {
- printf("lock1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) {
+ printf("lock1 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- if (cli_lock(cli2, fnum3, 0, 4, 0, WRITE_LOCK)) {
+ if (cli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)) {
printf("lock2 succeeded! This is a locking bug\n");
return False;
} else {
lock_timeout = (6 + (random() % 20));
printf("Testing lock timeout with timeout=%u\n", lock_timeout);
t1 = time(NULL);
- if (cli_lock(cli2, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK)) {
+ if (cli_lock(cli2->tree, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK)) {
printf("lock3 succeeded! This is a locking bug\n");
return False;
} else {
printf("server slept for %u seconds for a %u second timeout\n",
(unsigned int)(t2-t1), lock_timeout);
- if (!cli_close(cli1, fnum2)) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum2)) {
+ printf("close1 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- if (cli_lock(cli2, fnum3, 0, 4, 0, WRITE_LOCK)) {
+ if (cli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)) {
printf("lock4 succeeded! This is a locking bug\n");
return False;
} else {
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum3)) {
- printf("close3 failed (%s)\n", cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum3)) {
+ printf("close3 failed (%s)\n", cli_errstr(cli2->tree));
return False;
}
- if (!cli_unlink(cli1, fname)) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ if (!cli_unlink(cli1->tree, fname)) {
+ printf("unlink failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
printf("starting tcontest\n");
- if (cli_deltree(cli, fname) == -1) {
- printf("unlink of %s failed (%s)\n", fname, cli_errstr(cli));
+ if (cli_deltree(cli->tree, fname) == -1) {
+ printf("unlink of %s failed (%s)\n", fname, cli_errstr(cli->tree));
}
- fnum1 = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
vuid1 = cli->session->vuid;
memset(&buf, 0, 4); /* init buf so valgrind won't complain */
- if (cli_write(cli, fnum1, 0, buf, 130, 4) != 4) {
- printf("initial write failed (%s)\n", cli_errstr(cli));
+ if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("initial write failed (%s)\n", cli_errstr(cli->tree));
return False;
}
if (!cli_send_tconX(cli, share, "?????",
password)) {
printf("%s refused 2nd tree connect (%s)\n", host,
- cli_errstr(cli));
+ cli_errstr(cli->tree));
cli_shutdown(cli);
return False;
}
/* try a write with the wrong tid */
cli->tree->tid = cnum2;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
+ if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
printf("* server allows write with wrong TID\n");
ret = False;
} else {
- printf("server fails write with wrong TID : %s\n", cli_errstr(cli));
+ printf("server fails write with wrong TID : %s\n", cli_errstr(cli->tree));
}
/* try a write with an invalid tid */
cli->tree->tid = cnum3;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
+ if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
printf("* server allows write with invalid TID\n");
ret = False;
} else {
- printf("server fails write with invalid TID : %s\n", cli_errstr(cli));
+ printf("server fails write with invalid TID : %s\n", cli_errstr(cli->tree));
}
/* try a write with an invalid vuid */
cli->session->vuid = vuid2;
cli->tree->tid = cnum1;
- if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
+ if (cli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) {
printf("* server allows write with invalid VUID\n");
ret = False;
} else {
- printf("server fails write with invalid VUID : %s\n", cli_errstr(cli));
+ printf("server fails write with invalid VUID : %s\n", cli_errstr(cli->tree));
}
cli->session->vuid = vuid1;
cli->tree->tid = cnum1;
- if (!cli_close(cli, fnum1)) {
- printf("close failed (%s)\n", cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum1)) {
+ printf("close failed (%s)\n", cli_errstr(cli->tree));
return False;
}
cli->tree->tid = cnum2;
if (!cli_tdis(cli)) {
- printf("secondary tdis failed (%s)\n", cli_errstr(cli));
+ printf("secondary tdis failed (%s)\n", cli_errstr(cli->tree));
return False;
}
myshare, devtype);
ret = False;
} else {
- if (NT_STATUS_EQUAL(cli_nt_error(cli),
+ if (NT_STATUS_EQUAL(cli_nt_error(cli->tree),
expected_error)) {
ret = True;
} else {
printf("starting locktest2\n");
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
printf("Testing pid context\n");
cli->session->pid = 1;
- fnum1 = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
- fnum2 = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum2 = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
cli->session->pid = 2;
- fnum3 = cli_open(cli, fname, O_RDWR, DENY_NONE);
+ fnum3 = cli_open(cli->tree, fname, O_RDWR, DENY_NONE);
if (fnum3 == -1) {
- printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open3 of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
cli->session->pid = 1;
- if (!cli_lock(cli, fnum1, 0, 4, 0, WRITE_LOCK)) {
- printf("lock1 failed (%s)\n", cli_errstr(cli));
+ if (!cli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK)) {
+ printf("lock1 failed (%s)\n", cli_errstr(cli->tree));
return False;
}
- if (cli_lock(cli, fnum1, 0, 4, 0, WRITE_LOCK)) {
+ if (cli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK)) {
printf("WRITE lock1 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
- if (cli_lock(cli, fnum2, 0, 4, 0, WRITE_LOCK)) {
+ if (cli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK)) {
printf("WRITE lock2 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
- if (cli_lock(cli, fnum2, 0, 4, 0, READ_LOCK)) {
+ if (cli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK)) {
printf("READ lock2 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
- if (!cli_lock(cli, fnum1, 100, 4, 0, WRITE_LOCK)) {
- printf("lock at 100 failed (%s)\n", cli_errstr(cli));
+ if (!cli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK)) {
+ printf("lock at 100 failed (%s)\n", cli_errstr(cli->tree));
}
cli->session->pid = 2;
- if (cli_unlock(cli, fnum1, 100, 4)) {
+ if (cli_unlock(cli->tree, fnum1, 100, 4)) {
printf("unlock at 100 succeeded! This is a locking bug\n");
correct = False;
}
- if (cli_unlock(cli, fnum1, 0, 4)) {
+ if (cli_unlock(cli->tree, fnum1, 0, 4)) {
printf("unlock1 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_RANGE_NOT_LOCKED)) return False;
}
- if (cli_unlock(cli, fnum1, 0, 8)) {
+ if (cli_unlock(cli->tree, fnum1, 0, 8)) {
printf("unlock2 succeeded! This is a locking bug\n");
correct = False;
} else {
NT_STATUS_RANGE_NOT_LOCKED)) return False;
}
- if (cli_lock(cli, fnum3, 0, 4, 0, WRITE_LOCK)) {
+ if (cli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK)) {
printf("lock3 succeeded! This is a locking bug\n");
correct = False;
} else {
cli->session->pid = 1;
- if (!cli_close(cli, fnum1)) {
- printf("close1 failed (%s)\n", cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum1)) {
+ printf("close1 failed (%s)\n", cli_errstr(cli->tree));
return False;
}
- if (!cli_close(cli, fnum2)) {
- printf("close2 failed (%s)\n", cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum2)) {
+ printf("close2 failed (%s)\n", cli_errstr(cli->tree));
return False;
}
- if (!cli_close(cli, fnum3)) {
- printf("close3 failed (%s)\n", cli_errstr(cli));
+ if (!cli_close(cli->tree, fnum3)) {
+ printf("close3 failed (%s)\n", cli_errstr(cli->tree));
return False;
}
printf("Testing 32 bit offset ranges\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- fnum2 = cli_open(cli2, fname, O_RDWR, DENY_NONE);
+ fnum2 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("open2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
return False;
}
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (!cli_lock(cli1, fnum1, offset-1, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK)) {
printf("lock1 %d failed (%s)\n",
i,
- cli_errstr(cli1));
+ cli_errstr(cli1->tree));
return False;
}
- if (!cli_lock(cli2, fnum2, offset-2, 1, 0, WRITE_LOCK)) {
+ if (!cli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK)) {
printf("lock2 %d failed (%s)\n",
i,
- cli_errstr(cli1));
+ cli_errstr(cli1->tree));
return False;
}
}
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (cli_lock(cli1, fnum1, offset-2, 1, 0, WRITE_LOCK)) {
+ if (cli_lock(cli1->tree, fnum1, offset-2, 1, 0, WRITE_LOCK)) {
printf("error: lock1 %d succeeded!\n", i);
return False;
}
- if (cli_lock(cli2, fnum2, offset-1, 1, 0, WRITE_LOCK)) {
+ if (cli_lock(cli2->tree, fnum2, offset-1, 1, 0, WRITE_LOCK)) {
printf("error: lock2 %d succeeded!\n", i);
return False;
}
- if (cli_lock(cli1, fnum1, offset-1, 1, 0, WRITE_LOCK)) {
+ if (cli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK)) {
printf("error: lock3 %d succeeded!\n", i);
return False;
}
- if (cli_lock(cli2, fnum2, offset-2, 1, 0, WRITE_LOCK)) {
+ if (cli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK)) {
printf("error: lock4 %d succeeded!\n", i);
return False;
}
for (offset=i=0;i<torture_numops;i++) {
NEXT_OFFSET;
- if (!cli_unlock(cli1, fnum1, offset-1, 1)) {
+ if (!cli_unlock(cli1->tree, fnum1, offset-1, 1)) {
printf("unlock1 %d failed (%s)\n",
i,
- cli_errstr(cli1));
+ cli_errstr(cli1->tree));
return False;
}
- if (!cli_unlock(cli2, fnum2, offset-2, 1)) {
+ if (!cli_unlock(cli2->tree, fnum2, offset-2, 1)) {
printf("unlock2 %d failed (%s)\n",
i,
- cli_errstr(cli1));
+ cli_errstr(cli1->tree));
return False;
}
}
- if (!cli_close(cli1, fnum1)) {
- printf("close1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close1 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum2)) {
- printf("close2 failed (%s)\n", cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("close2 failed (%s)\n", cli_errstr(cli2->tree));
return False;
}
- if (!cli_unlink(cli1, fname)) {
- printf("unlink failed (%s)\n", cli_errstr(cli1));
+ if (!cli_unlink(cli1->tree, fname)) {
+ printf("unlink failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
printf("starting locktest4\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- fnum2 = cli_open(cli2, fname, O_RDWR, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum2 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
+ if (cli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
correct = False;
goto fail;
}
- ret = cli_lock(cli1, fnum1, 0, 4, 0, WRITE_LOCK) &&
- cli_lock(cli1, fnum1, 2, 4, 0, WRITE_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 2, 4, 0, WRITE_LOCK);
EXPECTED(ret, False);
printf("the same process %s set overlapping write locks\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 10, 4, 0, READ_LOCK) &&
- cli_lock(cli1, fnum1, 12, 4, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 10, 4, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 12, 4, 0, READ_LOCK);
EXPECTED(ret, True);
printf("the same process %s set overlapping read locks\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 20, 4, 0, WRITE_LOCK) &&
- cli_lock(cli2, fnum2, 22, 4, 0, WRITE_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 20, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli2->tree, fnum2, 22, 4, 0, WRITE_LOCK);
EXPECTED(ret, False);
printf("a different connection %s set overlapping write locks\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 30, 4, 0, READ_LOCK) &&
- cli_lock(cli2, fnum2, 32, 4, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 30, 4, 0, READ_LOCK) &&
+ cli_lock(cli2->tree, fnum2, 32, 4, 0, READ_LOCK);
EXPECTED(ret, True);
printf("a different connection %s set overlapping read locks\n", ret?"can":"cannot");
- ret = (cli1->session->pid = 1, cli_lock(cli1, fnum1, 40, 4, 0, WRITE_LOCK)) &&
- (cli1->session->pid = 2, cli_lock(cli1, fnum1, 42, 4, 0, WRITE_LOCK));
+ ret = (cli1->session->pid = 1, cli_lock(cli1->tree, fnum1, 40, 4, 0, WRITE_LOCK)) &&
+ (cli1->session->pid = 2, cli_lock(cli1->tree, fnum1, 42, 4, 0, WRITE_LOCK));
EXPECTED(ret, False);
printf("a different pid %s set overlapping write locks\n", ret?"can":"cannot");
- ret = (cli1->session->pid = 1, cli_lock(cli1, fnum1, 50, 4, 0, READ_LOCK)) &&
- (cli1->session->pid = 2, cli_lock(cli1, fnum1, 52, 4, 0, READ_LOCK));
+ ret = (cli1->session->pid = 1, cli_lock(cli1->tree, fnum1, 50, 4, 0, READ_LOCK)) &&
+ (cli1->session->pid = 2, cli_lock(cli1->tree, fnum1, 52, 4, 0, READ_LOCK));
EXPECTED(ret, True);
printf("a different pid %s set overlapping read locks\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 60, 4, 0, READ_LOCK) &&
- cli_lock(cli1, fnum1, 60, 4, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK);
EXPECTED(ret, True);
printf("the same process %s set the same read lock twice\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 70, 4, 0, WRITE_LOCK) &&
- cli_lock(cli1, fnum1, 70, 4, 0, WRITE_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK);
EXPECTED(ret, False);
printf("the same process %s set the same write lock twice\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 80, 4, 0, READ_LOCK) &&
- cli_lock(cli1, fnum1, 80, 4, 0, WRITE_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 80, 4, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 80, 4, 0, WRITE_LOCK);
EXPECTED(ret, False);
printf("the same process %s overlay a read lock with a write lock\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 90, 4, 0, WRITE_LOCK) &&
- cli_lock(cli1, fnum1, 90, 4, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 90, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 90, 4, 0, READ_LOCK);
EXPECTED(ret, True);
printf("the same process %s overlay a write lock with a read lock\n", ret?"can":"cannot");
- ret = (cli1->session->pid = 1, cli_lock(cli1, fnum1, 100, 4, 0, WRITE_LOCK)) &&
- (cli1->session->pid = 2, cli_lock(cli1, fnum1, 100, 4, 0, READ_LOCK));
+ ret = (cli1->session->pid = 1, cli_lock(cli1->tree, fnum1, 100, 4, 0, WRITE_LOCK)) &&
+ (cli1->session->pid = 2, cli_lock(cli1->tree, fnum1, 100, 4, 0, READ_LOCK));
EXPECTED(ret, False);
printf("a different pid %s overlay a write lock with a read lock\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 110, 4, 0, READ_LOCK) &&
- cli_lock(cli1, fnum1, 112, 4, 0, READ_LOCK) &&
- cli_unlock(cli1, fnum1, 110, 6);
+ ret = cli_lock(cli1->tree, fnum1, 110, 4, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 112, 4, 0, READ_LOCK) &&
+ cli_unlock(cli1->tree, fnum1, 110, 6);
EXPECTED(ret, False);
printf("the same process %s coalesce read locks\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 120, 4, 0, WRITE_LOCK) &&
- (cli_read(cli2, fnum2, buf, 120, 4) == 4);
+ ret = cli_lock(cli1->tree, fnum1, 120, 4, 0, WRITE_LOCK) &&
+ (cli_read(cli2->tree, fnum2, buf, 120, 4) == 4);
EXPECTED(ret, False);
printf("this server %s strict write locking\n", ret?"doesn't do":"does");
- ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK) &&
- (cli_write(cli2, fnum2, 0, buf, 130, 4) == 4);
+ ret = cli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK) &&
+ (cli_write(cli2->tree, fnum2, 0, buf, 130, 4) == 4);
EXPECTED(ret, False);
printf("this server %s strict read locking\n", ret?"doesn't do":"does");
- ret = cli_lock(cli1, fnum1, 140, 4, 0, READ_LOCK) &&
- cli_lock(cli1, fnum1, 140, 4, 0, READ_LOCK) &&
- cli_unlock(cli1, fnum1, 140, 4) &&
- cli_unlock(cli1, fnum1, 140, 4);
+ ret = cli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK) &&
+ cli_unlock(cli1->tree, fnum1, 140, 4) &&
+ cli_unlock(cli1->tree, fnum1, 140, 4);
EXPECTED(ret, True);
printf("this server %s do recursive read locking\n", ret?"does":"doesn't");
- ret = cli_lock(cli1, fnum1, 150, 4, 0, WRITE_LOCK) &&
- cli_lock(cli1, fnum1, 150, 4, 0, READ_LOCK) &&
- cli_unlock(cli1, fnum1, 150, 4) &&
- (cli_read(cli2, fnum2, buf, 150, 4) == 4) &&
- !(cli_write(cli2, fnum2, 0, buf, 150, 4) == 4) &&
- cli_unlock(cli1, fnum1, 150, 4);
+ ret = cli_lock(cli1->tree, fnum1, 150, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 150, 4, 0, READ_LOCK) &&
+ cli_unlock(cli1->tree, fnum1, 150, 4) &&
+ (cli_read(cli2->tree, fnum2, buf, 150, 4) == 4) &&
+ !(cli_write(cli2->tree, fnum2, 0, buf, 150, 4) == 4) &&
+ cli_unlock(cli1->tree, fnum1, 150, 4);
EXPECTED(ret, True);
printf("this server %s do recursive lock overlays\n", ret?"does":"doesn't");
- ret = cli_lock(cli1, fnum1, 160, 4, 0, READ_LOCK) &&
- cli_unlock(cli1, fnum1, 160, 4) &&
- (cli_write(cli2, fnum2, 0, buf, 160, 4) == 4) &&
- (cli_read(cli2, fnum2, buf, 160, 4) == 4);
+ ret = cli_lock(cli1->tree, fnum1, 160, 4, 0, READ_LOCK) &&
+ cli_unlock(cli1->tree, fnum1, 160, 4) &&
+ (cli_write(cli2->tree, fnum2, 0, buf, 160, 4) == 4) &&
+ (cli_read(cli2->tree, fnum2, buf, 160, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove a read lock using write locking\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 170, 4, 0, WRITE_LOCK) &&
- cli_unlock(cli1, fnum1, 170, 4) &&
- (cli_write(cli2, fnum2, 0, buf, 170, 4) == 4) &&
- (cli_read(cli2, fnum2, buf, 170, 4) == 4);
+ ret = cli_lock(cli1->tree, fnum1, 170, 4, 0, WRITE_LOCK) &&
+ cli_unlock(cli1->tree, fnum1, 170, 4) &&
+ (cli_write(cli2->tree, fnum2, 0, buf, 170, 4) == 4) &&
+ (cli_read(cli2->tree, fnum2, buf, 170, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove a write lock using read locking\n", ret?"can":"cannot");
- ret = cli_lock(cli1, fnum1, 190, 4, 0, WRITE_LOCK) &&
- cli_lock(cli1, fnum1, 190, 4, 0, READ_LOCK) &&
- cli_unlock(cli1, fnum1, 190, 4) &&
- !(cli_write(cli2, fnum2, 0, buf, 190, 4) == 4) &&
- (cli_read(cli2, fnum2, buf, 190, 4) == 4);
+ ret = cli_lock(cli1->tree, fnum1, 190, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 190, 4, 0, READ_LOCK) &&
+ cli_unlock(cli1->tree, fnum1, 190, 4) &&
+ !(cli_write(cli2->tree, fnum2, 0, buf, 190, 4) == 4) &&
+ (cli_read(cli2->tree, fnum2, buf, 190, 4) == 4);
EXPECTED(ret, True);
printf("the same process %s remove the first lock first\n", ret?"does":"doesn't");
- cli_close(cli1, fnum1);
- cli_close(cli2, fnum2);
- fnum1 = cli_open(cli1, fname, O_RDWR, DENY_NONE);
- f = cli_open(cli1, fname, O_RDWR, DENY_NONE);
- ret = cli_lock(cli1, fnum1, 0, 8, 0, READ_LOCK) &&
- cli_lock(cli1, f, 0, 1, 0, READ_LOCK) &&
- cli_close(cli1, fnum1) &&
- ((fnum1 = cli_open(cli1, fname, O_RDWR, DENY_NONE)) != -1) &&
- cli_lock(cli1, fnum1, 7, 1, 0, WRITE_LOCK);
- cli_close(cli1, f);
- cli_close(cli1, fnum1);
+ cli_close(cli1->tree, fnum1);
+ cli_close(cli2->tree, fnum2);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ f = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ ret = cli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, f, 0, 1, 0, READ_LOCK) &&
+ cli_close(cli1->tree, fnum1) &&
+ ((fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE)) != -1) &&
+ cli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK);
+ cli_close(cli1->tree, f);
+ cli_close(cli1->tree, fnum1);
EXPECTED(ret, True);
printf("the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't");
fail:
- cli_close(cli1, fnum1);
- cli_close(cli2, fnum2);
- cli_unlink(cli1, fname);
+ cli_close(cli1->tree, fnum1);
+ cli_close(cli2->tree, fnum2);
+ cli_unlink(cli1->tree, fname);
torture_close_connection(cli1);
torture_close_connection(cli2);
printf("starting locktest5\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- fnum2 = cli_open(cli2, fname, O_RDWR, DENY_NONE);
- fnum3 = cli_open(cli1, fname, O_RDWR, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum2 = cli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
+ fnum3 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
+ if (cli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
correct = False;
goto fail;
}
/* Check for NT bug... */
- ret = cli_lock(cli1, fnum1, 0, 8, 0, READ_LOCK) &&
- cli_lock(cli1, fnum3, 0, 1, 0, READ_LOCK);
- cli_close(cli1, fnum1);
- fnum1 = cli_open(cli1, fname, O_RDWR, DENY_NONE);
- ret = cli_lock(cli1, fnum1, 7, 1, 0, WRITE_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum3, 0, 1, 0, READ_LOCK);
+ cli_close(cli1->tree, fnum1);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ ret = cli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK);
EXPECTED(ret, True);
printf("this server %s the NT locking bug\n", ret ? "doesn't have" : "has");
- cli_close(cli1, fnum1);
- fnum1 = cli_open(cli1, fname, O_RDWR, DENY_NONE);
- cli_unlock(cli1, fnum3, 0, 1);
+ cli_close(cli1->tree, fnum1);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
+ cli_unlock(cli1->tree, fnum3, 0, 1);
- ret = cli_lock(cli1, fnum1, 0, 4, 0, WRITE_LOCK) &&
- cli_lock(cli1, fnum1, 1, 1, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 1, 1, 0, READ_LOCK);
EXPECTED(ret, True);
printf("the same process %s overlay a write with a read lock\n", ret?"can":"cannot");
- ret = cli_lock(cli2, fnum2, 0, 4, 0, READ_LOCK);
+ ret = cli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK);
EXPECTED(ret, False);
printf("a different processs %s get a read lock on the first process lock stack\n", ret?"can":"cannot");
/* Unlock the process 2 lock. */
- cli_unlock(cli2, fnum2, 0, 4);
+ cli_unlock(cli2->tree, fnum2, 0, 4);
- ret = cli_lock(cli1, fnum3, 0, 4, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum3, 0, 4, 0, READ_LOCK);
EXPECTED(ret, False);
printf("the same processs on a different fnum %s get a read lock\n", ret?"can":"cannot");
/* Unlock the process 1 fnum3 lock. */
- cli_unlock(cli1, fnum3, 0, 4);
+ cli_unlock(cli1->tree, fnum3, 0, 4);
/* Stack 2 more locks here. */
- ret = cli_lock(cli1, fnum1, 0, 4, 0, READ_LOCK) &&
- cli_lock(cli1, fnum1, 0, 4, 0, READ_LOCK);
+ ret = cli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK) &&
+ cli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK);
EXPECTED(ret, True);
printf("the same process %s stack read locks\n", ret?"can":"cannot");
/* Unlock the first process lock, then check this was the WRITE lock that was
removed. */
- ret = cli_unlock(cli1, fnum1, 0, 4) &&
- cli_lock(cli2, fnum2, 0, 4, 0, READ_LOCK);
+ ret = cli_unlock(cli1->tree, fnum1, 0, 4) &&
+ cli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK);
EXPECTED(ret, True);
printf("the first unlock removes the %s lock\n", ret?"WRITE":"READ");
/* Unlock the process 2 lock. */
- cli_unlock(cli2, fnum2, 0, 4);
+ cli_unlock(cli2->tree, fnum2, 0, 4);
/* We should have 3 stacked locks here. Ensure we need to do 3 unlocks. */
- ret = cli_unlock(cli1, fnum1, 1, 1) &&
- cli_unlock(cli1, fnum1, 0, 4) &&
- cli_unlock(cli1, fnum1, 0, 4);
+ ret = cli_unlock(cli1->tree, fnum1, 1, 1) &&
+ cli_unlock(cli1->tree, fnum1, 0, 4) &&
+ cli_unlock(cli1->tree, fnum1, 0, 4);
EXPECTED(ret, True);
printf("the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot");
/* Ensure the next unlock fails. */
- ret = cli_unlock(cli1, fnum1, 0, 4);
+ ret = cli_unlock(cli1->tree, fnum1, 0, 4);
EXPECTED(ret, False);
printf("the same process %s count the lock stack\n", !ret?"can":"cannot");
/* Ensure connection 2 can get a write lock. */
- ret = cli_lock(cli2, fnum2, 0, 4, 0, WRITE_LOCK);
+ ret = cli_lock(cli2->tree, fnum2, 0, 4, 0, WRITE_LOCK);
EXPECTED(ret, True);
printf("a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot");
fail:
- cli_close(cli1, fnum1);
- cli_close(cli2, fnum2);
- cli_unlink(cli1, fname);
+ cli_close(cli1->tree, fnum1);
+ cli_close(cli2->tree, fnum2);
+ cli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
correct = False;
}
for (i=0;i<1;i++) {
printf("Testing %s\n", fname[i]);
- cli_unlink(cli, fname[i]);
+ cli_unlink(cli->tree, fname[i]);
- fnum = cli_open(cli, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- status = cli_locktype(cli, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE);
- cli_close(cli, fnum);
+ fnum = cli_open(cli->tree, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ status = cli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE);
+ cli_close(cli->tree, fnum);
printf("CHANGE_LOCKTYPE gave %s\n", nt_errstr(status));
- fnum = cli_open(cli, fname[i], O_RDWR, DENY_NONE);
- status = cli_locktype(cli, fnum, 0, 8, 0, LOCKING_ANDX_CANCEL_LOCK);
- cli_close(cli, fnum);
+ fnum = cli_open(cli->tree, fname[i], O_RDWR, DENY_NONE);
+ status = cli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CANCEL_LOCK);
+ cli_close(cli->tree, fnum);
printf("CANCEL_LOCK gave %s\n", nt_errstr(status));
- cli_unlink(cli, fname[i]);
+ cli_unlink(cli->tree, fname[i]);
}
torture_close_connection(cli);
printf("starting locktest7\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
memset(buf, 0, sizeof(buf));
- if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
+ if (cli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
printf("Failed to create file\n");
goto fail;
}
cli1->session->pid = 1;
- if (!cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK)) {
- printf("Unable to apply read lock on range 130:4, error was %s\n", cli_errstr(cli1));
+ if (!cli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK)) {
+ printf("Unable to apply read lock on range 130:4, error was %s\n", cli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully locked range 130:4 for READ\n");
}
- if (cli_read(cli1, fnum1, buf, 130, 4) != 4) {
- printf("pid1 unable to read the range 130:4, error was %s\n", cli_errstr(cli1));
+ if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid1 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully read the range 130:4\n");
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
cli1->session->pid = 2;
- if (cli_read(cli1, fnum1, buf, 130, 4) != 4) {
- printf("pid2 unable to read the range 130:4, error was %s\n", cli_errstr(cli1));
+ if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid2 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
} else {
printf("pid2 successfully read the range 130:4\n");
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
}
cli1->session->pid = 1;
- cli_unlock(cli1, fnum1, 130, 4);
+ cli_unlock(cli1->tree, fnum1, 130, 4);
- if (!cli_lock(cli1, fnum1, 130, 4, 0, WRITE_LOCK)) {
- printf("Unable to apply write lock on range 130:4, error was %s\n", cli_errstr(cli1));
+ if (!cli_lock(cli1->tree, fnum1, 130, 4, 0, WRITE_LOCK)) {
+ printf("Unable to apply write lock on range 130:4, error was %s\n", cli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully locked range 130:4 for WRITE\n");
}
- if (cli_read(cli1, fnum1, buf, 130, 4) != 4) {
- printf("pid1 unable to read the range 130:4, error was %s\n", cli_errstr(cli1));
+ if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid1 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully read the range 130:4\n");
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
+ if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
goto fail;
} else {
printf("pid1 successfully wrote to the range 130:4\n");
cli1->session->pid = 2;
- if (cli_read(cli1, fnum1, buf, 130, 4) != 4) {
- printf("pid2 unable to read the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (cli_read(cli1->tree, fnum1, buf, 130, 4) != 4) {
+ printf("pid2 unable to read the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
goto fail;
}
- if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
- printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
+ if (cli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) {
+ printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1->tree));
+ if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
goto fail;
}
goto fail;
}
- cli_unlock(cli1, fnum1, 130, 0);
+ cli_unlock(cli1->tree, fnum1, 130, 0);
correct = True;
fail:
- cli_close(cli1, fnum1);
- cli_unlink(cli1, fname);
+ cli_close(cli1->tree, fnum1);
+ cli_unlink(cli1->tree, fname);
torture_close_connection(cli1);
printf("finished locktest7\n");
printf("starting fdpasstest\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("Opening a file on connection 1\n");
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
printf("writing to file on connection 1\n");
- if (cli_write(cli1, fnum1, 0, "hello world\n", 0, 13) != 13) {
- printf("write failed (%s)\n", cli_errstr(cli1));
+ if (cli_write(cli1->tree, fnum1, 0, "hello world\n", 0, 13) != 13) {
+ printf("write failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
printf("reading from file on connection 2\n");
- if (cli_read(cli2, fnum1, buf, 0, 13) == 13) {
+ if (cli_read(cli2->tree, fnum1, buf, 0, 13) == 13) {
printf("read succeeded! nasty security hole [%s]\n",
buf);
return False;
}
- cli_close(cli1, fnum1);
- cli_unlink(cli1, fname);
+ cli_close(cli1->tree, fnum1);
+ cli_unlink(cli1->tree, fname);
cli2->tree->tid = oldtid;
printf("starting unlink test\n");
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
cli->session->pid = 1;
printf("Opening a file\n");
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
printf("Unlinking a open file\n");
- if (cli_unlink(cli, fname)) {
+ if (cli_unlink(cli->tree, fname)) {
printf("error: server allowed unlink on an open file\n");
correct = False;
} else {
NT_STATUS_SHARING_VIOLATION);
}
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
if (!torture_close_connection(cli)) {
correct = False;
for (i=0; i<0x11000; i++) {
asprintf(&fname, template, i,(int)getpid());
- if ((fnums[i] = cli_open(cli, fname,
+ if ((fnums[i] = cli_open(cli->tree, fname,
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) ==
-1) {
printf("open of %s failed (%s)\n",
- fname, cli_errstr(cli));
+ fname, cli_errstr(cli->tree));
printf("maximum fnum is %d\n", i);
break;
}
printf("cleaning up\n");
for (;i>=0;i--) {
asprintf(&fname, template, i,(int)getpid());
- if (!cli_close(cli, fnums[i])) {
- printf("Close of fnum %d failed - %s\n", fnums[i], cli_errstr(cli));
+ if (!cli_close(cli->tree, fnums[i])) {
+ printf("Close of fnum %d failed - %s\n", fnums[i], cli_errstr(cli->tree));
}
- if (!cli_unlink(cli, fname)) {
+ if (!cli_unlink(cli->tree, fname)) {
printf("unlink of %s failed (%s)\n",
- fname, cli_errstr(cli));
+ fname, cli_errstr(cli->tree));
correct = False;
}
free(fname);
return False;
}
- cli_unlink(cli, fname);
- fnum = cli_open(cli, fname,
+ cli_unlink(cli->tree, fname);
+ fnum = cli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
- if (!cli_getatr(cli, fname, NULL, NULL, &t)) {
- printf("getatr failed (%s)\n", cli_errstr(cli));
+ if (!cli_getatr(cli->tree, fname, NULL, NULL, &t)) {
+ printf("getatr failed (%s)\n", cli_errstr(cli->tree));
correct = False;
}
printf("Setting file time to %s", ctime(&t2));
- if (!cli_setatr(cli, fname, 0, t2)) {
- printf("setatr failed (%s)\n", cli_errstr(cli));
+ if (!cli_setatr(cli->tree, fname, 0, t2)) {
+ printf("setatr failed (%s)\n", cli_errstr(cli->tree));
correct = True;
}
- if (!cli_getatr(cli, fname, NULL, NULL, &t)) {
- printf("getatr failed (%s)\n", cli_errstr(cli));
+ if (!cli_getatr(cli->tree, fname, NULL, NULL, &t)) {
+ printf("getatr failed (%s)\n", cli_errstr(cli->tree));
correct = True;
}
correct = True;
}
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
if (!torture_close_connection(cli)) {
correct = False;
return False;
}
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
printf("Testing qfileinfo\n");
- fnum = cli_open(cli, fname,
+ fnum = cli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- if (!cli_qfileinfo(cli, fnum, NULL, &size, &c_time, &a_time, &m_time,
+ if (!cli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time,
NULL, NULL)) {
- printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(cli));
+ printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(cli->tree));
correct = False;
}
printf("Testing NAME_INFO\n");
- if (!cli_qfilename(cli, fnum, &pname)) {
- printf("ERROR: qfilename failed (%s)\n", cli_errstr(cli));
+ if (!cli_qfilename(cli->tree, fnum, &pname)) {
+ printf("ERROR: qfilename failed (%s)\n", cli_errstr(cli->tree));
correct = False;
}
correct = False;
}
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
- fnum = cli_open(cli, fname,
+ fnum = cli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
printf("Checking for sticky create times\n");
- if (!cli_qpathinfo(cli, fname, &c_time, &a_time, &m_time, &size, NULL)) {
- printf("ERROR: qpathinfo failed (%s)\n", cli_errstr(cli));
+ if (!cli_qpathinfo(cli->tree, fname, &c_time, &a_time, &m_time, &size, NULL)) {
+ printf("ERROR: qpathinfo failed (%s)\n", cli_errstr(cli->tree));
correct = False;
} else {
if (c_time != m_time) {
}
- cli_unlink(cli, fname);
- fnum = cli_open(cli, fname,
+ cli_unlink(cli->tree, fname);
+ fnum = cli_open(cli->tree, fname,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- cli_close(cli, fnum);
- if (!cli_qpathinfo2(cli, fname, &c_time, &a_time, &m_time,
+ cli_close(cli->tree, fnum);
+ if (!cli_qpathinfo2(cli->tree, fname, &c_time, &a_time, &m_time,
&w_time, &size, NULL, NULL)) {
- printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
+ printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli->tree));
correct = False;
} else {
if (w_time < 60*60*24*2) {
}
}
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
/* check if the server updates the directory modification time
when creating a new file */
- if (!cli_mkdir(cli, dname)) {
- printf("ERROR: mkdir failed (%s)\n", cli_errstr(cli));
+ if (!cli_mkdir(cli->tree, dname)) {
+ printf("ERROR: mkdir failed (%s)\n", cli_errstr(cli->tree));
correct = False;
}
sleep(3);
- if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time, &a_time, &m_time,
+ if (!cli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time,
&w_time, &size, NULL, NULL)) {
- printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
+ printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli->tree));
correct = False;
}
- fnum = cli_open(cli, fname2,
+ fnum = cli_open(cli->tree, fname2,
O_RDWR | O_CREAT | O_TRUNC, DENY_NONE);
- cli_write(cli, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
- cli_close(cli, fnum);
- if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time, &a_time, &m_time2,
+ cli_write(cli->tree, fnum, 0, (char *)&fnum, 0, sizeof(fnum));
+ cli_close(cli->tree, fnum);
+ if (!cli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2,
&w_time, &size, NULL, NULL)) {
- printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
+ printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli->tree));
correct = False;
} else {
if (m_time2 == m_time) {
correct = False;
}
}
- cli_unlink(cli, fname2);
- cli_rmdir(cli, dname);
+ cli_unlink(cli->tree, fname2);
+ cli_rmdir(cli->tree, dname);
if (!torture_close_connection(cli)) {
correct = False;
/* Test 1 - this should delete the file on close. */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF,
NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
if (fnum1 == -1) {
- printf("[1] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[1] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[1] close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[1] close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- fnum1 = cli_open(cli1, fname, O_RDWR, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR, DENY_NONE);
if (fnum1 != -1) {
printf("[1] open of %s succeeded (should fail)\n", fname);
correct = False;
/* Test 2 - this should delete the file on close. */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE,
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[2] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[2] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_nt_delete_on_close(cli1, fnum1, True)) {
- printf("[2] setting delete_on_close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
+ printf("[2] setting delete_on_close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[2] close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[2] close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[2] open of %s succeeded should have been deleted on close !\n", fname);
- if (!cli_close(cli1, fnum1)) {
- printf("[2] close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[2] close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
} else
printf("second delete on close test succeeded.\n");
/* Test 3 - ... */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[3] open - 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[3] open - 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail with a sharing violation - open for delete is only compatible
with SHARE_DELETE. */
- fnum2 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE,
NTCREATEX_DISP_OPEN, 0, 0);
/* This should succeed. */
- fnum2 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[3] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[3] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_nt_delete_on_close(cli1, fnum1, True)) {
- printf("[3] setting delete_on_close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
+ printf("[3] setting delete_on_close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[3] close 1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[3] close 1 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum2)) {
- printf("[3] close 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum2)) {
+ printf("[3] close 2 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - file should no longer be there. */
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[3] open of %s succeeded should have been deleted on close !\n", fname);
- if (!cli_close(cli1, fnum1)) {
- printf("[3] close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[3] close failed (%s)\n", cli_errstr(cli1->tree));
}
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
correct = False;
goto fail;
} else
printf("third delete on close test succeeded.\n");
/* Test 4 ... */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA |
SA_RIGHT_FILE_WRITE_DATA |
STD_RIGHT_DELETE_ACCESS,
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[4] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[4] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should succeed. */
- fnum2 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_READ,
+ fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE |
NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[4] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[4] open - 2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum2)) {
- printf("[4] close - 1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum2)) {
+ printf("[4] close - 1 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_nt_delete_on_close(cli1, fnum1, True)) {
- printf("[4] setting delete_on_close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
+ printf("[4] setting delete_on_close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - no more opens once delete on close set. */
- fnum2 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_READ,
+ fnum2 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 != -1) {
} else
printf("fourth delete on close test succeeded.\n");
- if (!cli_close(cli1, fnum1)) {
- printf("[4] close - 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[4] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* Test 5 ... */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
- printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - only allowed on NT opens with DELETE access. */
- if (cli_nt_delete_on_close(cli1, fnum1, True)) {
+ if (cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
printf("[5] setting delete_on_close on OpenX file succeeded - should fail !\n");
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[5] close - 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[5] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
printf("fifth delete on close test succeeded.\n");
/* Test 6 ... */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA | SA_RIGHT_FILE_WRITE_DATA,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[6] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[6] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail - only allowed on NT opens with DELETE access. */
- if (cli_nt_delete_on_close(cli1, fnum1, True)) {
+ if (cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
printf("[6] setting delete_on_close on file with no delete access succeeded - should fail !\n");
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[6] close - 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[6] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
printf("sixth delete on close test succeeded.\n");
/* Test 7 ... */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA |
SA_RIGHT_FILE_WRITE_DATA |
STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[7] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[7] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_nt_delete_on_close(cli1, fnum1, True)) {
+ if (!cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
printf("[7] setting delete_on_close on file failed !\n");
correct = False;
goto fail;
}
- if (!cli_nt_delete_on_close(cli1, fnum1, False)) {
+ if (!cli_nt_delete_on_close(cli1->tree, fnum1, False)) {
printf("[7] unsetting delete_on_close on file failed !\n");
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This next open should succeed - we reset the flag. */
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 == -1) {
- printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[5] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[7] close - 2 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
printf("seventh delete on close test succeeded.\n");
/* Test 7 ... */
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
if (!torture_open_connection(&cli2)) {
printf("[8] failed to open second connection.\n");
goto fail;
}
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_nt_delete_on_close(cli1, fnum1, True)) {
+ if (!cli_nt_delete_on_close(cli1->tree, fnum1, True)) {
printf("[8] setting delete_on_close on file failed !\n");
correct = False;
goto fail;
}
- if (!cli_close(cli1, fnum1)) {
- printf("[8] close - 1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[8] close - 1 failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
- if (!cli_close(cli2, fnum2)) {
- printf("[8] close - 2 failed (%s)\n", cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("[8] close - 2 failed (%s)\n", cli_errstr(cli2->tree));
correct = False;
goto fail;
}
/* This should fail.. */
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[8] open of %s succeeded should have been deleted on close !\n", fname);
goto fail;
printf("eighth delete on close test succeeded.\n");
/* This should fail - we need to set DELETE_ACCESS. */
- fnum1 = cli_nt_create_full(cli1, fname, 0,SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0,SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
if (fnum1 != -1) {
printf("ninth delete on close test succeeded.\n");
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA|STD_RIGHT_DELETE_ACCESS,
FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0);
if (fnum1 == -1) {
- printf("[10] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[10] open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should delete the file. */
- if (!cli_close(cli1, fnum1)) {
- printf("[10] close failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("[10] close failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
goto fail;
}
/* This should fail.. */
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_NONE);
if (fnum1 != -1) {
printf("[10] open of %s succeeded should have been deleted on close !\n", fname);
goto fail;
* intialized, because these functions don't handle
* uninitialized connections. */
- cli_close(cli1, fnum1);
- cli_close(cli1, fnum2);
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_close(cli1->tree, fnum1);
+ cli_close(cli1->tree, fnum2);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
correct = False;
return False;
}
- fnum1 = cli_nt_create_full(cli1, fname, 0,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF,
0x4044, 0);
if (fnum1 == -1) {
- printf("First open failed - %s\n", cli_errstr(cli1));
+ printf("First open failed - %s\n", cli_errstr(cli1->tree));
return False;
}
- fnum2 = cli_nt_create_full(cli1, fname, 0,
+ fnum2 = cli_nt_create_full(cli1->tree, fname, 0,
SECOND_DESIRED_ACCESS, 0,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN,
0x200000, 0);
if (fnum2 == -1) {
- printf("second open failed - %s\n", cli_errstr(cli1));
+ printf("second open failed - %s\n", cli_errstr(cli1->tree));
return False;
}
return False;
}
- cli_unlink(cli1, fname);
- cli_unlink(cli1, fname1);
- fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ cli_unlink(cli1->tree, fname);
+ cli_unlink(cli1->tree, fname1);
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("First open failed - %s\n", cli_errstr(cli1));
+ printf("First open failed - %s\n", cli_errstr(cli1->tree));
return False;
}
- if (!cli_rename(cli1, fname, fname1)) {
- printf("First rename failed (this is correct) - %s\n", cli_errstr(cli1));
+ if (!cli_rename(cli1->tree, fname, fname1)) {
+ printf("First rename failed (this is correct) - %s\n", cli_errstr(cli1->tree));
} else {
printf("First rename succeeded - this should have failed !\n");
correct = False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("close - 1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close - 1 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1, fname);
- cli_unlink(cli1, fname1);
- fnum1 = cli_nt_create_full(cli1, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
+ cli_unlink(cli1->tree, fname);
+ cli_unlink(cli1->tree, fname1);
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, GENERIC_RIGHTS_FILE_READ, FILE_ATTRIBUTE_NORMAL,
#if 0
NTCREATEX_SHARE_ACCESS_DELETE|NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
#else
#endif
if (fnum1 == -1) {
- printf("Second open failed - %s\n", cli_errstr(cli1));
+ printf("Second open failed - %s\n", cli_errstr(cli1->tree));
return False;
}
- if (!cli_rename(cli1, fname, fname1)) {
- printf("Second rename failed - this should have succeeded - %s\n", cli_errstr(cli1));
+ if (!cli_rename(cli1->tree, fname, fname1)) {
+ printf("Second rename failed - this should have succeeded - %s\n", cli_errstr(cli1->tree));
correct = False;
} else {
printf("Second rename succeeded\n");
}
- if (!cli_close(cli1, fnum1)) {
- printf("close - 2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close - 2 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1, fname);
- cli_unlink(cli1, fname1);
+ cli_unlink(cli1->tree, fname);
+ cli_unlink(cli1->tree, fname1);
- fnum1 = cli_nt_create_full(cli1, fname, 0, STD_RIGHT_READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("Third open failed - %s\n", cli_errstr(cli1));
+ printf("Third open failed - %s\n", cli_errstr(cli1->tree));
return False;
}
{
int fnum2;
- fnum2 = cli_nt_create_full(cli1, fname, 0, DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli1->tree, fname, 0, DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum2 == -1) {
- printf("Fourth open failed - %s\n", cli_errstr(cli1));
+ printf("Fourth open failed - %s\n", cli_errstr(cli1->tree));
return False;
}
- if (!cli_nt_delete_on_close(cli1, fnum2, True)) {
+ if (!cli_nt_delete_on_close(cli1->tree, fnum2, True)) {
printf("[8] setting delete_on_close on file failed !\n");
return False;
}
- if (!cli_close(cli1, fnum2)) {
- printf("close - 4 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum2)) {
+ printf("close - 4 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
}
#endif
- if (!cli_rename(cli1, fname, fname1)) {
- printf("Third rename failed - this should have succeeded - %s\n", cli_errstr(cli1));
+ if (!cli_rename(cli1->tree, fname, fname1)) {
+ printf("Third rename failed - this should have succeeded - %s\n", cli_errstr(cli1->tree));
correct = False;
} else {
printf("Third rename succeeded\n");
}
- if (!cli_close(cli1, fnum1)) {
- printf("close - 3 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close - 3 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1, fname);
- cli_unlink(cli1, fname1);
+ cli_unlink(cli1->tree, fname);
+ cli_unlink(cli1->tree, fname1);
if (!torture_close_connection(cli1)) {
correct = False;
}
while(1) {
- fnum = cli_nt_create_full(cli1, pipe_name, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ fnum = cli_nt_create_full(cli1->tree, pipe_name, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum == -1) {
- printf("Open of pipe %s failed with error (%s)\n", pipe_name, cli_errstr(cli1));
+ printf("Open of pipe %s failed with error (%s)\n", pipe_name, cli_errstr(cli1->tree));
break;
}
num_pipes++;
return False;
}
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- if (!cli_setatr(cli1, fname, FILE_ATTRIBUTE_READONLY, 0)) {
- printf("cli_setatr failed (%s)\n", cli_errstr(cli1));
+ if (!cli_setatr(cli1->tree, fname, FILE_ATTRIBUTE_READONLY, 0)) {
+ printf("cli_setatr failed (%s)\n", cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test1);
return False;
}
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_WRITE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test1);
return False;
}
/* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */
- fnum2 = cli_open(cli1, fname, O_RDWR, DENY_ALL);
+ fnum2 = cli_open(cli1->tree, fname, O_RDWR, DENY_ALL);
if (check_error(__LINE__, cli1, ERRDOS, ERRnoaccess,
NT_STATUS_ACCESS_DENIED)) {
printf("finished open test 1\n");
error_test1:
- cli_close(cli1, fnum1);
+ cli_close(cli1->tree, fnum1);
/* Now try not readonly and ensure ERRbadshare is returned. */
- cli_setatr(cli1, fname, 0, 0);
+ cli_setatr(cli1->tree, fname, 0, 0);
- fnum1 = cli_open(cli1, fname, O_RDONLY, DENY_WRITE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
/* This will fail - but the error should be ERRshare. */
- fnum2 = cli_open(cli1, fname, O_RDWR, DENY_ALL);
+ fnum2 = cli_open(cli1->tree, fname, O_RDWR, DENY_ALL);
if (check_error(__LINE__, cli1, ERRDOS, ERRbadshare,
NT_STATUS_SHARING_VIOLATION)) {
printf("correct error code ERRDOS/ERRbadshare returned\n");
}
- if (!cli_close(cli1, fnum1)) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("finished open test 2\n");
/* Test truncate open disposition on file opened for read. */
- fnum1 = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum1 == -1) {
- printf("(3) open (1) of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("(3) open (1) of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
memset(buf, '\0', 20);
- if (cli_write(cli1, fnum1, 0, buf, 0, 20) != 20) {
- printf("write failed (%s)\n", cli_errstr(cli1));
+ if (cli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
+ printf("write failed (%s)\n", cli_errstr(cli1->tree));
correct = False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("(3) close1 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("(3) close1 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
/* Ensure size == 20. */
- if (!cli_getatr(cli1, fname, NULL, &fsize, NULL)) {
- printf("(3) getatr failed (%s)\n", cli_errstr(cli1));
+ if (!cli_getatr(cli1->tree, fname, NULL, &fsize, NULL)) {
+ printf("(3) getatr failed (%s)\n", cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
return False;
}
/* Now test if we can truncate a file opened for readonly. */
- fnum1 = cli_open(cli1, fname, O_RDONLY|O_TRUNC, DENY_NONE);
+ fnum1 = cli_open(cli1->tree, fname, O_RDONLY|O_TRUNC, DENY_NONE);
if (fnum1 == -1) {
- printf("(3) open (2) of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("(3) open (2) of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("close2 failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close2 failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
/* Ensure size == 0. */
- if (!cli_getatr(cli1, fname, NULL, &fsize, NULL)) {
- printf("(3) getatr failed (%s)\n", cli_errstr(cli1));
+ if (!cli_getatr(cli1->tree, fname, NULL, &fsize, NULL)) {
+ printf("(3) getatr failed (%s)\n", cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test3);
return False;
}
}
printf("finished open test 3\n");
error_test3:
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("testing ctemp\n");
- fnum1 = cli_ctemp(cli1, "\\", &tmp_path);
+ fnum1 = cli_ctemp(cli1->tree, "\\", &tmp_path);
if (fnum1 == -1) {
- printf("ctemp failed (%s)\n", cli_errstr(cli1));
+ printf("ctemp failed (%s)\n", cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test4);
return False;
}
printf("ctemp gave path %s\n", tmp_path);
- if (!cli_close(cli1, fnum1)) {
- printf("close of temp failed (%s)\n", cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close of temp failed (%s)\n", cli_errstr(cli1->tree));
}
- if (!cli_unlink(cli1, tmp_path)) {
- printf("unlink of temp failed (%s)\n", cli_errstr(cli1));
+ if (!cli_unlink(cli1->tree, tmp_path)) {
+ printf("unlink of temp failed (%s)\n", cli_errstr(cli1->tree));
}
error_test4:
/* Test the non-io opens... */
return False;
}
- cli_setatr(cli2, fname, 0, 0);
- cli_unlink(cli2, fname);
+ cli_setatr(cli2->tree, fname, 0, 0);
+ cli_unlink(cli2->tree, fname);
printf("TEST #1 testing 2 non-io opens (no delete)\n");
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test10);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test10);
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum2)) {
- printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
return False;
}
printf("non-io open test #1 passed.\n");
error_test10:
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("TEST #2 testing 2 non-io opens (first with delete)\n");
- fnum1 = cli_nt_create_full(cli1, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test20);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test20);
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum2)) {
- printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
printf("non-io open test #2 passed.\n");
error_test20:
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("TEST #3 testing 2 non-io opens (second with delete)\n");
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test30);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test30);
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("test 3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum2)) {
- printf("test 3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("test 3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
return False;
}
printf("non-io open test #3 passed.\n");
error_test30:
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("TEST #4 testing 2 non-io opens (both with delete)\n");
- fnum1 = cli_nt_create_full(cli1, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test40);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 != -1) {
- printf("test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test40);
return False;
}
- printf("test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
+ printf("test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2->tree), "sharing violation");
- if (!cli_close(cli1, fnum1)) {
- printf("test 4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
printf("non-io open test #4 passed.\n");
error_test40:
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
printf("TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n");
- fnum1 = cli_nt_create_full(cli1, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test50);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test50);
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("test 5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum2)) {
- printf("test 5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("test 5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
return False;
}
error_test50:
printf("TEST #6 testing 1 non-io open, one io open\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test60);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 == -1) {
- printf("test 6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test60);
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("test 6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli2, fnum2)) {
- printf("test 6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
+ if (!cli_close(cli2->tree, fnum2)) {
+ printf("test 6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2->tree));
return False;
}
error_test60:
printf("TEST #7 testing 1 non-io open, one io open with delete\n");
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("test 7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("test 7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
CHECK_MAX_FAILURES(error_test70);
return False;
}
- fnum2 = cli_nt_create_full(cli2, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
+ fnum2 = cli_nt_create_full(cli2->tree, fname, 0, STD_RIGHT_DELETE_ACCESS|SA_RIGHT_FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN_IF, 0, 0);
if (fnum2 != -1) {
- printf("test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
+ printf("test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2->tree));
CHECK_MAX_FAILURES(error_test70);
return False;
}
- printf("test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
+ printf("test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2->tree), "sharing violation");
- if (!cli_close(cli1, fnum1)) {
- printf("test 7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("test 7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
return False;
}
printf("non-io open test #7 passed.\n");
error_test70:
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
correct = False;
}
for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32); i++) {
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
- fnum1 = cli_nt_create_full(cli1, fname, 0, SA_RIGHT_FILE_WRITE_DATA, open_attrs_table[i],
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_WRITE_DATA, open_attrs_table[i],
NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("open %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1));
+ printf("open %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_close(cli1, fnum1)) {
- printf("close %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close %d (1) of %s failed (%s)\n", i, fname, cli_errstr(cli1->tree));
return False;
}
for (j = 0; j < ARRAY_SIZE(open_attrs_table); j++) {
- fnum1 = cli_nt_create_full(cli1, fname, 0,
+ fnum1 = cli_nt_create_full(cli1->tree, fname, 0,
SA_RIGHT_FILE_READ_DATA|SA_RIGHT_FILE_WRITE_DATA,
open_attrs_table[j],
NTCREATEX_SHARE_ACCESS_NONE,
printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(0x%x:%s)\n",
k, open_attrs_table[i],
open_attrs_table[j],
- fname, NT_STATUS_V(cli_nt_error(cli1)), cli_errstr(cli1));
+ fname, NT_STATUS_V(cli_nt_error(cli1->tree)), cli_errstr(cli1->tree));
correct = False;
CHECK_MAX_FAILURES(error_exit);
}
}
- if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
+ if (NT_STATUS_V(cli_nt_error(cli1->tree)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n",
k, open_attrs_table[i], open_attrs_table[j],
- cli_errstr(cli1));
+ cli_errstr(cli1->tree));
correct = False;
CHECK_MAX_FAILURES(error_exit);
}
continue;
}
- if (!cli_close(cli1, fnum1)) {
- printf("close %d (2) of %s failed (%s)\n", j, fname, cli_errstr(cli1));
+ if (!cli_close(cli1->tree, fnum1)) {
+ printf("close %d (2) of %s failed (%s)\n", j, fname, cli_errstr(cli1->tree));
return False;
}
- if (!cli_getatr(cli1, fname, &attr, NULL, NULL)) {
- printf("getatr(2) failed (%s)\n", cli_errstr(cli1));
+ if (!cli_getatr(cli1->tree, fname, &attr, NULL, NULL)) {
+ printf("getatr(2) failed (%s)\n", cli_errstr(cli1->tree));
return False;
}
}
}
error_exit:
- cli_setatr(cli1, fname, 0, 0);
- cli_unlink(cli1, fname);
+ cli_setatr(cli1->tree, fname, 0, 0);
+ cli_unlink(cli1->tree, fname);
printf("open attr test %s.\n", correct ? "passed" : "failed");
for (i=0;i<torture_numops;i++) {
char *fname;
asprintf(&fname, "\\%x", (int)random());
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
fprintf(stderr,"Failed to open %s\n", fname);
return False;
}
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
free(fname);
}
t1 = end_timer();
- printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL));
+ printf("Matched %d\n", cli_list(cli->tree, "a*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", cli_list(cli->tree, "b*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", cli_list(cli->tree, "xyzabc", 0, list_fn, NULL));
printf("dirtest core %g seconds\n", end_timer() - t1);
for (i=0;i<torture_numops;i++) {
char *fname;
asprintf(&fname, "\\%x", (int)random());
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
free(fname);
}
return;
if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
- if (!cli_rmdir(pcli, fname))
- printf("del_fn: failed to rmdir %s, error=%s\n", fname, cli_errstr(pcli) );
+ if (!cli_rmdir(pcli->tree, fname))
+ printf("del_fn: failed to rmdir %s, error=%s\n", fname, cli_errstr(pcli->tree) );
} else {
- if (!cli_unlink(pcli, fname))
- printf("del_fn: failed to unlink %s, error=%s\n", fname, cli_errstr(pcli) );
+ if (!cli_unlink(pcli->tree, fname))
+ printf("del_fn: failed to unlink %s, error=%s\n", fname, cli_errstr(pcli->tree) );
}
free(fname);
}
printf("starting ioctl test\n");
- cli_unlink(cli, fname);
+ cli_unlink(cli->tree, fname);
- fnum = cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = cli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
+ printf("open of %s failed (%s)\n", fname, cli_errstr(cli->tree));
return False;
}
parms.ioctl.level = RAW_IOCTL_IOCTL;
parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO;
status = smb_raw_ioctl(cli->tree, mem_ctx, &parms);
- printf("ioctl job info: %s\n", cli_errstr(cli));
+ printf("ioctl job info: %s\n", cli_errstr(cli->tree));
for (device=0;device<0x100;device++) {
printf("testing device=0x%x\n", device);
printf("Testing valid and invalid paths\n");
/* cleanup from an old run */
- cli_rmdir(cli, "\\chkpath.dir\\dir2");
- cli_unlink(cli, "\\chkpath.dir\\*");
- cli_rmdir(cli, "\\chkpath.dir");
+ cli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
+ cli_unlink(cli->tree, "\\chkpath.dir\\*");
+ cli_rmdir(cli->tree, "\\chkpath.dir");
- if (!cli_mkdir(cli, "\\chkpath.dir")) {
- printf("mkdir1 failed : %s\n", cli_errstr(cli));
+ if (!cli_mkdir(cli->tree, "\\chkpath.dir")) {
+ printf("mkdir1 failed : %s\n", cli_errstr(cli->tree));
return False;
}
- if (!cli_mkdir(cli, "\\chkpath.dir\\dir2")) {
- printf("mkdir2 failed : %s\n", cli_errstr(cli));
+ if (!cli_mkdir(cli->tree, "\\chkpath.dir\\dir2")) {
+ printf("mkdir2 failed : %s\n", cli_errstr(cli->tree));
return False;
}
- fnum = cli_open(cli, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
+ fnum = cli_open(cli->tree, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
if (fnum == -1) {
- printf("open1 failed (%s)\n", cli_errstr(cli));
+ printf("open1 failed (%s)\n", cli_errstr(cli->tree));
return False;
}
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
- if (!cli_chkpath(cli, "\\chkpath.dir")) {
- printf("chkpath1 failed: %s\n", cli_errstr(cli));
+ if (!cli_chkpath(cli->tree, "\\chkpath.dir")) {
+ printf("chkpath1 failed: %s\n", cli_errstr(cli->tree));
ret = False;
}
- if (!cli_chkpath(cli, "\\chkpath.dir\\dir2")) {
- printf("chkpath2 failed: %s\n", cli_errstr(cli));
+ if (!cli_chkpath(cli->tree, "\\chkpath.dir\\dir2")) {
+ printf("chkpath2 failed: %s\n", cli_errstr(cli->tree));
ret = False;
}
- if (!cli_chkpath(cli, "\\chkpath.dir\\foo.txt")) {
+ if (!cli_chkpath(cli->tree, "\\chkpath.dir\\foo.txt")) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadpath,
NT_STATUS_NOT_A_DIRECTORY);
} else {
ret = False;
}
- if (!cli_chkpath(cli, "\\chkpath.dir\\bar.txt")) {
+ if (!cli_chkpath(cli->tree, "\\chkpath.dir\\bar.txt")) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadfile,
NT_STATUS_OBJECT_NAME_NOT_FOUND);
} else {
ret = False;
}
- if (!cli_chkpath(cli, "\\chkpath.dir\\dirxx\\bar.txt")) {
+ if (!cli_chkpath(cli->tree, "\\chkpath.dir\\dirxx\\bar.txt")) {
ret = check_error(__LINE__, cli, ERRDOS, ERRbadpath,
NT_STATUS_OBJECT_PATH_NOT_FOUND);
} else {
ret = False;
}
- cli_rmdir(cli, "\\chkpath.dir\\dir2");
- cli_unlink(cli, "\\chkpath.dir\\*");
- cli_rmdir(cli, "\\chkpath.dir");
+ cli_rmdir(cli->tree, "\\chkpath.dir\\dir2");
+ cli_unlink(cli->tree, "\\chkpath.dir\\*");
+ cli_rmdir(cli->tree, "\\chkpath.dir");
if (!torture_close_connection(cli)) {
return False;
return False;
}
- cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli);
- cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
- if (cli_deltree(cli, "\\LISTDIR") == -1) {
- fprintf(stderr,"Failed to deltree %s, error=%s\n", "\\LISTDIR", cli_errstr(cli));
+ cli_list(cli->tree, "\\LISTDIR\\*", 0, del_fn, cli);
+ cli_list(cli->tree, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
+ if (cli_deltree(cli->tree, "\\LISTDIR") == -1) {
+ fprintf(stderr,"Failed to deltree %s, error=%s\n", "\\LISTDIR", cli_errstr(cli->tree));
return False;
}
- if (!cli_mkdir(cli, "\\LISTDIR")) {
- fprintf(stderr,"Failed to mkdir %s, error=%s\n", "\\LISTDIR", cli_errstr(cli));
+ if (!cli_mkdir(cli->tree, "\\LISTDIR")) {
+ fprintf(stderr,"Failed to mkdir %s, error=%s\n", "\\LISTDIR", cli_errstr(cli->tree));
return False;
}
for (i=0;i<torture_entries;i++) {
char *fname;
asprintf(&fname, "\\LISTDIR\\f%d", i);
- fnum = cli_nt_create_full(cli, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
+ fnum = cli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0);
if (fnum == -1) {
- fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli));
+ fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli->tree));
return False;
}
free(fname);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
}
for (i=0;i<torture_entries;i++) {
char *fname;
asprintf(&fname, "\\LISTDIR\\d%d", i);
- if (!cli_mkdir(cli, fname)) {
- fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli));
+ if (!cli_mkdir(cli->tree, fname)) {
+ fprintf(stderr,"Failed to open %s, error=%s\n", fname, cli_errstr(cli->tree));
return False;
}
free(fname);
}
/* Now ensure that doing an old list sees both files and directories. */
- num_seen = cli_list_old(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
+ num_seen = cli_list_old(cli->tree, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
printf("num_seen = %d\n", num_seen );
/* We should see (torture_entries) each of files & directories + . and .. */
if (num_seen != (2*torture_entries)+2) {
/* Ensure if we have the "must have" bits we only see the
* relevant entries.
*/
- num_seen = cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
+ num_seen = cli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
printf("num_seen = %d\n", num_seen );
if (num_seen != torture_entries+2) {
correct = False;
torture_entries+2, num_seen);
}
- num_seen = cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
+ num_seen = cli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL);
printf("num_seen = %d\n", num_seen );
if (num_seen != torture_entries) {
correct = False;
}
/* Delete everything. */
- cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli);
- cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
- cli_rmdir(cli, "\\LISTDIR");
+ cli_list(cli->tree, "\\LISTDIR\\*", 0, del_fn, cli);
+ cli_list(cli->tree, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
+ cli_rmdir(cli->tree, "\\LISTDIR");
#if 0
- printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL));
- printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL));
+ printf("Matched %d\n", cli_list(cli->tree, "a*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", cli_list(cli->tree, "b*.*", 0, list_fn, NULL));
+ printf("Matched %d\n", cli_list(cli->tree, "xyzabc", 0, list_fn, NULL));
#endif
if (!torture_close_connection(cli)) {
fname = "\\deny_dos1.dat";
- cli_unlink(cli1, fname);
- fnum1 = cli_open(cli1, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- fnum2 = cli_open(cli1, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- if (fnum1 != -1) cli_close(cli1, fnum1);
- if (fnum2 != -1) cli_close(cli1, fnum2);
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
+ fnum1 = cli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ fnum2 = cli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ if (fnum1 != -1) cli_close(cli1->tree, fnum1);
+ if (fnum2 != -1) cli_close(cli1->tree, fnum2);
+ cli_unlink(cli1->tree, fname);
printf("fnum1=%d fnum2=%d\n", fnum1, fnum2);
fname = "\\deny_dos2.dat";
- cli_unlink(cli1, fname);
- fnum1 = cli_open(cli1, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- fnum2 = cli_open(cli2, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
- if (fnum1 != -1) cli_close(cli1, fnum1);
- if (fnum2 != -1) cli_close(cli2, fnum2);
- cli_unlink(cli1, fname);
+ cli_unlink(cli1->tree, fname);
+ fnum1 = cli_open(cli1->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ fnum2 = cli_open(cli2->tree, fname, O_CREAT|O_TRUNC|O_WRONLY, DENY_DOS);
+ if (fnum1 != -1) cli_close(cli1->tree, fnum1);
+ if (fnum2 != -1) cli_close(cli2->tree, fnum2);
+ cli_unlink(cli1->tree, fname);
printf("fnum1=%d fnum2=%d\n", fnum1, fnum2);
time_t t = (time(NULL) & ~1);
NTSTATUS status;
- cli_unlink(cli, fname);
- fnum = cli_nt_create_full(cli, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
+ cli_unlink(cli->tree, fname);
+ fnum = cli_nt_create_full(cli->tree, fname, 0, GENERIC_RIGHTS_FILE_ALL_ACCESS,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
0, 0);
if (fnum == -1) return -1;
- cli_write(cli, fnum, 0, buf, 0, sizeof(buf));
+ cli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
/* setup some EAs */
setfile.generic.level = RAW_SFILEINFO_EA_SET;
memset(valid, 0, sizeof(valid));
- cli_mkdir(cli, "\\utable");
- cli_unlink(cli, "\\utable\\*");
+ cli_mkdir(cli->tree, "\\utable");
+ cli_unlink(cli->tree, "\\utable\\*");
for (c=1; c < 0x10000; c++) {
char *p;
p[len] = 0;
fstrcat(fname,"_a_long_extension");
- fnum = cli_open(cli, fname, O_RDWR | O_CREAT | O_TRUNC,
+ fnum = cli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
DENY_NONE);
if (fnum == -1) continue;
chars_allowed++;
- cli_qpathinfo_alt_name(cli, fname, &alt_name);
+ cli_qpathinfo_alt_name(cli->tree, fname, &alt_name);
if (strncmp(alt_name, "X_A_L", 5) != 0) {
alt_allowed++;
d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name);
}
- cli_close(cli, fnum);
- cli_unlink(cli, fname);
+ cli_close(cli->tree, fnum);
+ cli_unlink(cli->tree, fname);
if (c % 100 == 0) {
printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed);
}
printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed);
- cli_rmdir(cli, "\\utable");
+ cli_rmdir(cli->tree, "\\utable");
d_printf("%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed);
memset(equiv, 0, sizeof(equiv));
- cli_deltree(cli, "\\utable");
- if (!cli_mkdir(cli, "\\utable")) {
+ cli_deltree(cli->tree, "\\utable");
+ if (!cli_mkdir(cli->tree, "\\utable")) {
printf("Failed to create utable directory!\n");
return False;
}
d_printf("%04x (%c)\n", c, isprint(c)?c:'.');
fname = form_name(c);
- fnum = cli_nt_create_full(cli, fname, 0,
+ fnum = cli_nt_create_full(cli->tree, fname, 0,
#if 0
SEC_RIGHT_MAXIMUM_ALLOWED,
#else
size = 0;
- if (!cli_qfileinfo(cli, fnum, NULL, &size,
+ if (!cli_qfileinfo(cli->tree, fnum, NULL, &size,
NULL, NULL, NULL, NULL, NULL)) continue;
if (size > 0) {
if (size/sizeof(int) >= MAX_EQUIVALENCE) {
printf("too many chars match?? size=%d c=0x%04x\n",
size, c);
- cli_close(cli, fnum);
+ cli_close(cli->tree, fnum);
return False;
}
- cli_read(cli, fnum, (char *)c2, 0, size);
+ cli_read(cli->tree, fnum, (char *)c2, 0, size);
printf("%04x: ", c);
equiv[c][0] = c;
for (i=0; i<size/sizeof(int); i++) {
fflush(stdout);
}
- cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c));
- cli_close(cli, fnum);
+ cli_write(cli->tree, fnum, 0, (char *)&c, size, sizeof(c));
+ cli_close(cli->tree, fnum);
}
- cli_unlink(cli, "\\utable\\*");
- cli_rmdir(cli, "\\utable");
+ cli_unlink(cli->tree, "\\utable\\*");
+ cli_rmdir(cli->tree, "\\utable");
return True;
}