*/
#include "includes.h"
+#include "system/passwd.h"
static fstring password;
static fstring username;
struct record {
char r1, r2;
char conn, f, fstype;
- unsigned start, len;
+ uint_t start, len;
char needed;
};
static struct record *recorded;
-static int try_open(struct cli_state *c, char *nfs, int fstype, const char *fname, int flags)
+static int try_open(struct smbcli_state *c, char *nfs, int fstype, const char *fname, int flags)
{
pstring path;
switch (fstype) {
case FSTYPE_SMB:
- return cli_open(c, fname, flags, DENY_NONE);
+ return smbcli_open(c, fname, flags, DENY_NONE);
case FSTYPE_NFS:
slprintf(path, sizeof(path), "%s%s", nfs, fname);
return -1;
}
-static BOOL try_close(struct cli_state *c, int fstype, int fd)
+static BOOL try_close(struct smbcli_state *c, int fstype, int fd)
{
switch (fstype) {
case FSTYPE_SMB:
- return cli_close(c, fd);
+ return smbcli_close(c, fd);
case FSTYPE_NFS:
return close(fd) == 0;
return False;
}
-static BOOL try_lock(struct cli_state *c, int fstype,
- int fd, unsigned start, unsigned len,
+static BOOL try_lock(struct smbcli_state *c, int fstype,
+ int fd, uint_t start, uint_t len,
enum brl_type op)
{
struct flock lock;
switch (fstype) {
case FSTYPE_SMB:
- return cli_lock(c, fd, start, len, LOCK_TIMEOUT, op);
+ return smbcli_lock(c, fd, start, len, LOCK_TIMEOUT, op);
case FSTYPE_NFS:
lock.l_type = (op==READ_LOCK) ? F_RDLCK:F_WRLCK;
return False;
}
-static BOOL try_unlock(struct cli_state *c, int fstype,
- int fd, unsigned start, unsigned len)
+static BOOL try_unlock(struct smbcli_state *c, int fstype,
+ int fd, uint_t start, uint_t len)
{
struct flock lock;
switch (fstype) {
case FSTYPE_SMB:
- return cli_unlock(c, fd, start, len);
+ return smbcli_unlock(c, fd, start, len);
case FSTYPE_NFS:
lock.l_type = F_UNLCK;
return False;
}
-static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, int pid,
- enum brl_type lock_type,
- br_off start, br_off size)
-{
- printf("%6d %05x:%05x %s %.0f:%.0f(%.0f)\n",
- (int)pid, (int)dev, (int)ino,
- lock_type==READ_LOCK?"R":"W",
- (double)start, (double)start+size-1,(double)size);
-
-}
-
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *connect_one(char *share)
+static struct smbcli_state *connect_one(char *share)
{
- struct cli_state *c;
+ struct smbcli_state *c;
char *server_n;
fstring server;
fstring myname;
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
- nt_status = cli_full_connection(&c, myname, server_n, NULL, 0, share, "?????",
- username, lp_workgroup(), password, 0,
- NULL);
-
+ nt_status = smbcli_full_connection(NULL,
+ &c, myname, server_n, 0, share, NULL,
+ username, lp_workgroup(), password);
if (!NT_STATUS_IS_OK(nt_status)) {
- DEBUG(0, ("cli_full_connection failed with error %s\n", nt_errstr(nt_status)));
+ DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
return NULL;
}
}
-static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
char *share1, char *share2)
for (conn=0;conn<NCONNECTIONS;conn++) {
if (cli[server][conn]) {
for (f=0;f<NFILES;f++) {
- cli_close(cli[server][conn], fnum[server][fstype][conn][f]);
+ smbcli_close(cli[server][conn], fnum[server][fstype][conn][f]);
}
- cli_ulogoff(cli[server][conn]);
- cli_shutdown(cli[server][conn]);
+ smbcli_ulogoff(cli[server][conn]);
+ smbcli_shutdown(cli[server][conn]);
}
cli[server][conn] = connect_one(share[server]);
if (!cli[server][conn]) {
-static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
struct record *rec)
{
- unsigned conn = rec->conn;
- unsigned f = rec->f;
- unsigned fstype = rec->fstype;
- unsigned start = rec->start;
- unsigned len = rec->len;
- unsigned r1 = rec->r1;
- unsigned r2 = rec->r2;
+ uint_t conn = rec->conn;
+ uint_t f = rec->f;
+ uint_t fstype = rec->fstype;
+ uint_t start = rec->start;
+ uint_t len = rec->len;
+ uint_t r1 = rec->r1;
+ uint_t r2 = rec->r2;
enum brl_type op;
int server;
BOOL ret[NSERVERS];
op==READ_LOCK?"READ_LOCK":"WRITE_LOCK",
ret[0], ret[1]);
}
- if (showall) brl_forall(print_brl);
if (ret[0] != ret[1]) return False;
} else if (r2 < LOCK_PCT+UNLOCK_PCT) {
/* unset a lock */
start, start+len-1, len,
ret[0], ret[1]);
}
- if (showall) brl_forall(print_brl);
if (!hide_unlock_fails && ret[0] != ret[1]) return False;
} else {
/* reopen the file */
if (showall) {
printf("reopen conn=%u fstype=%u f=%u\n",
conn, fstype, f);
- brl_forall(print_brl);
}
}
return True;
}
-static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES])
{
}
}
for (server=0;server<NSERVERS;server++) {
- cli_unlink(cli[server][0], FILENAME);
+ smbcli_unlink(cli[server][0], FILENAME);
}
}
-static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static void open_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES])
{
}
-static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS],
+static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
char *nfs[NSERVERS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
int n)
*/
static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2)
{
- struct cli_state *cli[NSERVERS][NCONNECTIONS];
+ struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
char *nfs[NSERVERS];
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES];
int n, i, n1;
ZERO_STRUCT(fnum);
ZERO_STRUCT(cli);
- recorded = (struct record *)malloc(sizeof(*recorded) * numops);
+ recorded = malloc_array_p(struct record, numops);
for (n=0; n<numops; n++) {
recorded[n].conn = random() % NCONNECTIONS;
recorded[n].fstype = random() % NUMFSTYPES;
recorded[n].f = random() % NFILES;
- recorded[n].start = LOCKBASE + ((unsigned)random() % (LOCKRANGE-1));
+ recorded[n].start = LOCKBASE + ((uint_t)random() % (LOCKRANGE-1));
recorded[n].len = 1 +
random() % (LOCKRANGE-(recorded[n].start-LOCKBASE));
recorded[n].start *= RANGE_MULTIPLE;
all_string_sub(share1,"/","\\",0);
all_string_sub(share2,"/","\\",0);
- setup_logging(argv[0],True);
+ setup_logging(argv[0], DEBUG_STDOUT);
argc -= 4;
argv += 4;