r24872: Use torture API a bit more
[kai/samba.git] / source4 / torture / locktest2.c
index 63f71f2004557732bfd3111d0377c1c95f8f4d18..9d4f0260b17c50464a3ea5f9799ec2a589681d58 100644 (file)
@@ -5,7 +5,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
+#include "system/passwd.h"
 
 static fstring password;
 static fstring username;
@@ -133,17 +133,6 @@ static BOOL try_unlock(struct smbcli_state *c, int fstype,
        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
 *******************************************************/
@@ -173,10 +162,9 @@ static struct smbcli_state *connect_one(char *share)
 
        slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
 
-       nt_status = smbcli_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, NULL);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
                return NULL;
@@ -207,7 +195,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                                smbcli_close(cli[server][conn], fnum[server][fstype][conn][f]);
                        }
                        smbcli_ulogoff(cli[server][conn]);
-                       smbcli_shutdown(cli[server][conn]);
+                       talloc_free(cli[server][conn]);
                }
                cli[server][conn] = connect_one(share[server]);
                if (!cli[server][conn]) {
@@ -255,7 +243,6 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                               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 */
@@ -270,7 +257,6 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                               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 */
@@ -286,7 +272,6 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                if (showall) {
                        printf("reopen conn=%u fstype=%u f=%u\n",
                               conn, fstype, f);
-                       brl_forall(print_brl);
                }
        }
        return True;
@@ -371,7 +356,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
        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;
@@ -498,8 +483,7 @@ static void usage(void)
        argc -= 4;
        argv += 4;
 
-       lp_load(dyn_CONFIGFILE,True,False,False);
-       load_interfaces();
+       lp_load();
 
        if (getenv("USER")) {
                fstrcpy(username,getenv("USER"));