s3: Remove some pointless uses of string_sid_talloc
[ira/wip.git] / source3 / torture / nbio.c
index 1542a8ffb47389664016436678f866ac2a1c9460..054806811bd6b5f7ebd8a85cc64db7697d3943a7 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "includes.h"
+#include "torture/proto.h"
 
 #define MAX_FILES 1000
 
@@ -27,6 +28,7 @@ static char buf[70000];
 extern int line_count;
 extern int nbio_id;
 static int nprocs;
+static struct timeval nb_start;
 
 static struct {
        int fd;
@@ -60,7 +62,9 @@ void nb_alarm(int ignore)
                if (!children[i].done) num_clients++;
        }
 
-       printf("%4d  %8d  %.2f MB/sec\r", num_clients, lines/nprocs, 1.0e-6 * nbio_total() / end_timer());
+       printf("%4d  %8d  %.2f MB/sec\r",
+              num_clients, lines/nprocs,
+              1.0e-6 * nbio_total() / timeval_elapsed(&nb_start));
 
        signal(SIGALRM, nb_alarm);
        alarm(1);       
@@ -121,7 +125,7 @@ void nb_setup(struct cli_state *cli)
 {
        signal(SIGSEGV, sigsegv);
        c = cli;
-       start_timer();
+       nb_start = timeval_current();
        children[nbio_id].done = 0;
 }
 
@@ -140,7 +144,9 @@ void nb_unlink(const char *fname)
 void nb_createx(const char *fname, 
                unsigned create_options, unsigned create_disposition, int handle)
 {
-       int fd, i;
+       uint16_t fd = (uint16_t)-1;
+       int i;
+       NTSTATUS status;
        uint32 desired_access;
 
        if (create_options & FILE_DIRECTORY_FILE) {
@@ -149,22 +155,22 @@ void nb_createx(const char *fname,
                desired_access = FILE_READ_DATA | FILE_WRITE_DATA;
        }
 
-       fd = cli_nt_create_full(c, fname, 0, 
+       status = cli_ntcreate(c, fname, 0, 
                                desired_access,
                                0x0,
                                FILE_SHARE_READ|FILE_SHARE_WRITE, 
                                create_disposition, 
-                               create_options, 0);
-       if (fd == -1 && handle != -1) {
-               printf("ERROR: cli_nt_create_full failed for %s - %s\n",
+                               create_options, 0, &fd);
+       if (!NT_STATUS_IS_OK(status) && handle != -1) {
+               printf("ERROR: cli_ntcreate failed for %s - %s\n",
                       fname, cli_errstr(c));
                exit(1);
        }
-       if (fd != -1 && handle == -1) {
-               printf("ERROR: cli_nt_create_full succeeded for %s\n", fname);
+       if (NT_STATUS_IS_OK(status) && handle == -1) {
+               printf("ERROR: cli_ntcreate succeeded for %s\n", fname);
                exit(1);
        }
-       if (fd == -1) return;
+       if (fd == (uint16_t)-1) return;
 
        for (i=0;i<MAX_FILES;i++) {
                if (ftable[i].handle == 0) break;
@@ -211,7 +217,7 @@ void nb_close(int handle)
 {
        int i;
        i = find_handle(handle);
-       if (!cli_close(c, ftable[i].fd)) {
+       if (!NT_STATUS_IS_OK(cli_close(c, ftable[i].fd))) {
                printf("(%d) close failed on handle %d\n", line_count, handle);
                exit(1);
        }