s4-dns: dlz_bind9: Fix ipv6 updates
[samba.git] / source3 / torture / nbio.c
index 0da6bc084e2dceafc1f02110c8e10e5cc0674829..ba4fa9559872f15eea31c1087c7791ee8835bed5 100644 (file)
@@ -76,7 +76,7 @@ void nb_alarm(int ignore)
 void nbio_shmem(int n)
 {
        nprocs = n;
-       children = (struct children *)shm_setup(sizeof(*children) * nprocs);
+       children = (struct children *)anonymous_shared_allocate(sizeof(*children) * nprocs);
        if (!children) {
                printf("Failed to setup shared memory!\n");
                exit(1);
@@ -166,7 +166,7 @@ void nb_createx(const char *fname,
                                0x0,
                                FILE_SHARE_READ|FILE_SHARE_WRITE, 
                                create_disposition, 
-                               create_options, 0, &fd);
+                               create_options, 0, &fd, NULL);
        if (!NT_STATUS_IS_OK(status) && handle != -1) {
                printf("ERROR: cli_ntcreate failed for %s - %s\n",
                       fname, nt_errstr(status));
@@ -212,12 +212,23 @@ void nb_writex(int handle, int offset, int size, int ret_size)
 
 void nb_readx(int handle, int offset, int size, int ret_size)
 {
-       int i, ret;
+       int i;
+       NTSTATUS status;
+       size_t nread;
 
        i = find_handle(handle);
-       if ((ret=cli_read(c, ftable[i].fd, buf, offset, size)) != ret_size) {
-               printf("(%d) ERROR: read failed on handle %d ofs=%d size=%d res=%d fd %d errno %d (%s)\n",
-                       line_count, handle, offset, size, ret, ftable[i].fd, errno, strerror(errno));
+       status = cli_read(c, ftable[i].fd, buf, offset, size, &nread);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("(%d) ERROR: read failed on handle %d ofs=%d size=%d "
+                      "fd %d nterror %s\n",
+                      line_count, handle, offset, size,
+                      ftable[i].fd, nt_errstr(status));
+               exit(1);
+       } else if (nread != ret_size) {
+               printf("(%d) ERROR: read failed on handle %d ofs=%d size=%d "
+                      "nread=%lu ret_size=%d fd %d\n",
+                      line_count, handle, offset, size, (unsigned long)nread,
+                      ret_size, ftable[i].fd);
                exit(1);
        }
        children[nbio_id].bytes_in += ret_size;
@@ -295,7 +306,8 @@ void nb_flush(int fnum)
 {
        int i;
        i = find_handle(fnum);
-       /* hmmm, we don't have cli_flush() yet */
+
+       cli_flush(NULL, c, i);
 }
 
 static int total_deleted;
@@ -312,6 +324,7 @@ static NTSTATUS delete_fn(const char *mnt, struct file_info *finfo,
        n = SMB_STRDUP(name);
        n[strlen(n)-1] = 0;
        if (asprintf(&s, "%s%s", n, finfo->name) == -1) {
+               free(n);
                printf("asprintf failed\n");
                return NT_STATUS_NO_MEMORY;
        }
@@ -319,12 +332,15 @@ static NTSTATUS delete_fn(const char *mnt, struct file_info *finfo,
                char *s2;
                if (asprintf(&s2, "%s\\*", s) == -1) {
                        printf("asprintf failed\n");
+                       free(s);
+                       free(n);
                        return NT_STATUS_NO_MEMORY;
                }
                status = cli_list(c, s2, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL);
+               free(s2);
                if (!NT_STATUS_IS_OK(status)) {
+                       free(s);
                        free(n);
-                       free(s2);
                        return status;
                }
                nb_rmdir(s);