s4:operational LDB module - enable support for passing referrals through it
[ira/wip.git] / source3 / torture / locktest.c
index 2ba5ab8f06e3003e6b27b4fa88901b48a053c8b8..a90c2e2dfee02227c7b30bf0e619e5014f1e5b76 100644 (file)
@@ -71,7 +71,7 @@ struct record {
        enum lock_op lock_op;
        enum brl_type lock_type;
        char conn, f;
-       SMB_BIG_UINT start, len;
+       uint64_t start, len;
        char needed;
 };
 
@@ -176,7 +176,7 @@ static struct cli_state *connect_one(char *share, int snum)
 
        server_n = server;
 
-       zero_addr(&ss);
+       zero_sockaddr(&ss);
 
        slprintf(myname,sizeof(myname), "lock-%lu-%u", (unsigned long)getpid(), count++);
 
@@ -184,7 +184,7 @@ static struct cli_state *connect_one(char *share, int snum)
        make_nmb_name(&called , server, 0x20);
 
  again:
-        zero_addr(&ss);
+        zero_sockaddr(&ss);
 
        /* have to open a new connection */
        if (!(c=cli_initialise())) {
@@ -212,8 +212,10 @@ static struct cli_state *connect_one(char *share, int snum)
 
        DEBUG(4,(" session request ok\n"));
 
-       if (!cli_negprot(c)) {
-               DEBUG(0,("protocol negotiation failed\n"));
+       status = cli_negprot(c);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("protocol negotiation failed: %s\n",
+                         nt_errstr(status)));
                cli_shutdown(c);
                return NULL;
        }
@@ -255,9 +257,10 @@ static struct cli_state *connect_one(char *share, int snum)
        
        DEBUG(4,(" session setup ok\n"));
 
-       if (!cli_send_tconX(c, share, "?????",
-                           password[snum], strlen(password[snum])+1)) {
-               DEBUG(0,("tree connect failed: %s\n", cli_errstr(c)));
+       status = cli_tcon_andx(c, share, "?????", password[snum],
+                              strlen(password[snum])+1);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("tree connect failed: %s\n", nt_errstr(status)));
                cli_shutdown(c);
                return NULL;
        }
@@ -270,7 +273,7 @@ static struct cli_state *connect_one(char *share, int snum)
 }
 
 
-static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
+static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES],
                      char *share[NSERVERS])
 {
        int server, conn, f;
@@ -279,9 +282,9 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS
        for (conn=0;conn<NCONNECTIONS;conn++) {
                if (cli[server][conn]) {
                        for (f=0;f<NFILES;f++) {
-                               if (fnum[server][conn][f] != -1) {
+                               if (fnum[server][conn][f] != (uint16_t)-1) {
                                        cli_close(cli[server][conn], fnum[server][conn][f]);
-                                       fnum[server][conn][f] = -1;
+                                       fnum[server][conn][f] = (uint16_t)-1;
                                }
                        }
                        cli_ulogoff(cli[server][conn]);
@@ -298,13 +301,13 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS
 
 
 static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], 
-                    int fnum[NSERVERS][NCONNECTIONS][NFILES],
+                    uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES],
                     struct record *rec)
 {
        unsigned conn = rec->conn;
        unsigned f = rec->f;
-       SMB_BIG_UINT start = rec->start;
-       SMB_BIG_UINT len = rec->len;
+       uint64_t start = rec->start;
+       uint64_t len = rec->len;
        enum brl_type op = rec->lock_type;
        int server;
        bool ret[NSERVERS];
@@ -338,9 +341,9 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
        case OP_UNLOCK:
                /* unset a lock */
                for (server=0;server<NSERVERS;server++) {
-                       ret[server] = cli_unlock64(cli[server][conn], 
+                       ret[server] = NT_STATUS_IS_OK(cli_unlock64(cli[server][conn], 
                                                   fnum[server][conn][f],
-                                                  start, len);
+                                                  start, len));
                        status[server] = cli_nt_error(cli[server][conn]);
                }
                if (showall || 
@@ -359,13 +362,13 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
                /* reopen the file */
                for (server=0;server<NSERVERS;server++) {
                        cli_close(cli[server][conn], fnum[server][conn][f]);
-                       fnum[server][conn][f] = -1;
+                       fnum[server][conn][f] = (uint16_t)-1;
                }
                for (server=0;server<NSERVERS;server++) {
-                       fnum[server][conn][f] = cli_open(cli[server][conn], FILENAME,
+                       fnum[server][conn][f] = (uint16_t)-1;
+                       if (!NT_STATUS_IS_OK(cli_open(cli[server][conn], FILENAME,
                                                         O_RDWR|O_CREAT,
-                                                        DENY_NONE);
-                       if (fnum[server][conn][f] == -1) {
+                                                        DENY_NONE, &fnum[server][conn][f]))) {
                                printf("failed to reopen on share%d\n", server);
                                return False;
                        }
@@ -382,35 +385,36 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS],
 }
 
 static void close_files(struct cli_state *cli[NSERVERS][NCONNECTIONS], 
-                       int fnum[NSERVERS][NCONNECTIONS][NFILES])
+                       uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES])
 {
        int server, conn, f; 
 
        for (server=0;server<NSERVERS;server++)
        for (conn=0;conn<NCONNECTIONS;conn++)
        for (f=0;f<NFILES;f++) {
-               if (fnum[server][conn][f] != -1) {
+               if (fnum[server][conn][f] != (uint16_t)-1) {
                        cli_close(cli[server][conn], fnum[server][conn][f]);
-                       fnum[server][conn][f] = -1;
+                       fnum[server][conn][f] = (uint16_t)-1;
                }
        }
        for (server=0;server<NSERVERS;server++) {
-               cli_unlink(cli[server][0], FILENAME);
+               cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
        }
 }
 
 static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS], 
-                      int fnum[NSERVERS][NCONNECTIONS][NFILES])
+                      uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES])
 {
        int server, conn, f; 
 
        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] = (uint16_t)-1;
+               if (!NT_STATUS_IS_OK(cli_open(cli[server][conn], FILENAME,
                                                 O_RDWR|O_CREAT,
-                                                DENY_NONE);
-               if (fnum[server][conn][f] == -1) {
+                                                DENY_NONE,
+                                                &fnum[server][conn][f]))) {
                        fprintf(stderr,"Failed to open fnum[%u][%u][%u]\n",
                                server, conn, f);
                        exit(1);
@@ -420,7 +424,7 @@ static void open_files(struct cli_state *cli[NSERVERS][NCONNECTIONS],
 
 
 static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS], 
-                  int fnum[NSERVERS][NCONNECTIONS][NFILES],
+                  uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES],
                   int n)
 {
        int i;
@@ -446,7 +450,7 @@ static int retest(struct cli_state *cli[NSERVERS][NCONNECTIONS],
 static void test_locks(char *share[NSERVERS])
 {
        struct cli_state *cli[NSERVERS][NCONNECTIONS];
-       int fnum[NSERVERS][NCONNECTIONS][NFILES];
+       uint16_t fnum[NSERVERS][NCONNECTIONS][NFILES];
        int n, i, n1, skip, r1, r2; 
 
        ZERO_STRUCT(fnum);