s3-util: for convenience, provide format comments in tdb_unpack().
[jra/samba/.git] / source3 / torture / locktest.c
index 9e4b8953162b0c304a03c2f856b0a91240e3fb1c..1bff95f4f3a950176511a74cf1d19fcdb4e933e3 100644 (file)
@@ -23,17 +23,17 @@ static fstring password[2];
 static fstring username[2];
 static int got_user;
 static int got_pass;
-static BOOL use_kerberos;
+static bool use_kerberos;
 static int numops = 1000;
-static BOOL showall;
-static BOOL analyze;
-static BOOL hide_unlock_fails;
-static BOOL use_oplocks;
+static bool showall;
+static bool analyze;
+static bool hide_unlock_fails;
+static bool use_oplocks;
 static unsigned lock_range = 100;
 static unsigned lock_base = 0;
 static unsigned min_length = 0;
-static BOOL exact_error_codes;
-static BOOL zero_zero;
+static bool exact_error_codes;
+static bool zero_zero;
 
 extern char *optarg;
 extern int optind;
@@ -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;
 };
 
@@ -125,13 +125,15 @@ static void print_brl(struct file_id id,
 {
 #if NASTY_POSIX_LOCK_HACK
        {
-               pstring cmd;
                static SMB_INO_T lastino;
 
                if (lastino != ino) {
-                       slprintf(cmd, sizeof(cmd), 
-                                "egrep POSIX.*%u /proc/locks", (int)ino);
-                       system(cmd);
+                       char *cmd;
+                       if (asprintf(&cmd,
+                                "egrep POSIX.*%u /proc/locks", (int)ino) > 0) {
+                               system(cmd);
+                               SAFE_FREE(cmd);
+                       }
                }
                lastino = ino;
        }
@@ -161,7 +163,7 @@ static struct cli_state *connect_one(char *share, int snum)
        struct nmb_name called, calling;
        char *server_n;
        fstring server;
-       struct in_addr ip;
+       struct sockaddr_storage ss;
        fstring myname;
        static int count;
        NTSTATUS status;
@@ -173,8 +175,8 @@ static struct cli_state *connect_one(char *share, int snum)
        share++;
 
        server_n = server;
-       
-        zero_ip(&ip);
+
+       zero_sockaddr(&ss);
 
        slprintf(myname,sizeof(myname), "lock-%lu-%u", (unsigned long)getpid(), count++);
 
@@ -182,7 +184,7 @@ static struct cli_state *connect_one(char *share, int snum)
        make_nmb_name(&called , server, 0x20);
 
  again:
-        zero_ip(&ip);
+        zero_sockaddr(&ss);
 
        /* have to open a new connection */
        if (!(c=cli_initialise())) {
@@ -190,7 +192,7 @@ static struct cli_state *connect_one(char *share, int snum)
                return NULL;
        }
 
-       status = cli_connect(c, server_n, &ip);
+       status = cli_connect(c, server_n, &ss);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Connection to %s failed. Error %s\n", server_n, nt_errstr(status) ));
                return NULL;
@@ -210,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;
        }
@@ -295,17 +299,17 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS
 
 
 
-static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], 
+static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], 
                     int 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];
+       bool ret[NSERVERS];
        NTSTATUS status[NSERVERS];
 
        switch (rec->lock_op) {
@@ -615,7 +619,7 @@ static void usage(void)
        argc -= NSERVERS;
        argv += NSERVERS;
 
-       lp_load(dyn_CONFIGFILE,True,False,False,True);
+       lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
        load_interfaces();
 
        if (getenv("USER")) {