r14173: change smb interface structures to always use
[jelmer/samba4-debian.git] / source / torture / raw / write.c
index 7241f8c91a52e355dfc49b4d94c27942fe902661..e9a391a7dc049af04fbb49fff3caff4ac55e91aa 100644 (file)
 */
 
 #include "includes.h"
+#include "torture/torture.h"
 #include "libcli/raw/libcliraw.h"
 #include "system/time.h"
+#include "system/filesys.h"
+#include "libcli/libcli.h"
 
 #define CHECK_STATUS(status, correct) do { \
        if (!NT_STATUS_EQUAL(status, correct)) { \
@@ -47,7 +50,7 @@
 
 #define CHECK_ALL_INFO(v, field) do { \
        finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
-       finfo.all_info.in.fname = fname; \
+       finfo.all_info.file.path = fname; \
        status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); \
        CHECK_STATUS(status, NT_STATUS_OK); \
        if ((v) != finfo.all_info.out.field) { \
@@ -121,7 +124,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        }
 
        printf("Trying zero write\n");
-       io.write.in.fnum = fnum;
+       io.write.file.fnum = fnum;
        io.write.in.count = 0;
        io.write.in.offset = 0;
        io.write.in.remaining = 0;
@@ -168,7 +171,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_BUFFER(buf, seed, 4000);
 
        printf("Trying bad fnum\n");
-       io.write.in.fnum = fnum+1;
+       io.write.file.fnum = fnum+1;
        io.write.in.count = 4000;
        io.write.in.offset = 0;
        io.write.in.data = buf;
@@ -181,7 +184,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
-       io.write.in.fnum = fnum;
+       io.write.file.fnum = fnum;
        io.write.in.count = 4000;
        io.write.in.offset = 0xFFFFFFFF - 2000;
        io.write.in.data = buf;
@@ -238,7 +241,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        }
 
        printf("Trying zero write\n");
-       io.writex.in.fnum = fnum;
+       io.writex.file.fnum = fnum;
        io.writex.in.offset = 0;
        io.writex.in.wmode = 0;
        io.writex.in.remaining = 0;
@@ -286,7 +289,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_BUFFER(buf, seed, 4000);
 
        printf("Trying bad fnum\n");
-       io.writex.in.fnum = fnum+1;
+       io.writex.file.fnum = fnum+1;
        io.writex.in.count = 4000;
        io.writex.in.offset = 0;
        io.writex.in.data = buf;
@@ -294,7 +297,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
 
        printf("Testing wmode\n");
-       io.writex.in.fnum = fnum;
+       io.writex.file.fnum = fnum;
        io.writex.in.count = 1;
        io.writex.in.offset = 0;
        io.writex.in.wmode = 1;
@@ -329,7 +332,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
-       io.writex.in.fnum = fnum;
+       io.writex.file.fnum = fnum;
        io.writex.in.count = 4000;
        io.writex.in.offset = 0xFFFFFFFF - 2000;
        io.writex.in.data = buf;
@@ -349,12 +352,12 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        for (i=33;i<64;i++) {
                printf("Trying 2^%d offset\n", i);
                setup_buffer(buf, seed+1, maxsize);
-               io.writex.in.fnum = fnum;
+               io.writex.file.fnum = fnum;
                io.writex.in.count = 4000;
                io.writex.in.offset = ((uint64_t)1) << i;
                io.writex.in.data = buf;
                status = smb_raw_write(cli->tree, &io);
-               if (i>40 &&
+               if (i>33 &&
                    NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
                        break;
                }
@@ -414,7 +417,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        }
 
        printf("Trying zero write\n");
-       io.writeunlock.in.fnum = fnum;
+       io.writeunlock.file.fnum = fnum;
        io.writeunlock.in.count = 0;
        io.writeunlock.in.offset = 0;
        io.writeunlock.in.remaining = 0;
@@ -479,7 +482,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_BUFFER(buf, seed, 4000);
 
        printf("Trying bad fnum\n");
-       io.writeunlock.in.fnum = fnum+1;
+       io.writeunlock.file.fnum = fnum+1;
        io.writeunlock.in.count = 4000;
        io.writeunlock.in.offset = 0;
        io.writeunlock.in.data = buf;
@@ -492,7 +495,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
-       io.writeunlock.in.fnum = fnum;
+       io.writeunlock.file.fnum = fnum;
        io.writeunlock.in.count = 4000;
        io.writeunlock.in.offset = 0xFFFFFFFF - 2000;
        io.writeunlock.in.data = buf;
@@ -551,7 +554,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        }
 
        printf("Trying zero write\n");
-       io.writeclose.in.fnum = fnum;
+       io.writeclose.file.fnum = fnum;
        io.writeclose.in.count = 0;
        io.writeclose.in.offset = 0;
        io.writeclose.in.mtime = 0;
@@ -577,7 +580,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
 
        fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
-       io.writeclose.in.fnum = fnum;
+       io.writeclose.file.fnum = fnum;
 
        if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
                printf("read failed at %s\n", __location__);
@@ -593,7 +596,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_VALUE(io.writeclose.out.nwritten, io.writeclose.in.count);
 
        fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
-       io.writeclose.in.fnum = fnum;
+       io.writeclose.file.fnum = fnum;
 
        memset(buf, 0, maxsize);
        if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
@@ -618,7 +621,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
 
        fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
-       io.writeclose.in.fnum = fnum;
+       io.writeclose.file.fnum = fnum;
 
        memset(buf, 0, maxsize);
        if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
@@ -629,7 +632,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_BUFFER(buf, seed, 4000);
 
        printf("Trying bad fnum\n");
-       io.writeclose.in.fnum = fnum+1;
+       io.writeclose.file.fnum = fnum+1;
        io.writeclose.in.count = 4000;
        io.writeclose.in.offset = 0;
        io.writeclose.in.data = buf;
@@ -642,7 +645,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        
        printf("Trying 2^32 offset\n");
        setup_buffer(buf, seed, maxsize);
-       io.writeclose.in.fnum = fnum;
+       io.writeclose.file.fnum = fnum;
        io.writeclose.in.count = 4000;
        io.writeclose.in.offset = 0xFFFFFFFF - 2000;
        io.writeclose.in.data = buf;
@@ -652,7 +655,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        CHECK_ALL_INFO(io.writeclose.in.count + (uint64_t)io.writeclose.in.offset, size);
 
        fnum = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE);
-       io.writeclose.in.fnum = fnum;
+       io.writeclose.file.fnum = fnum;
 
        memset(buf, 0, maxsize);
        if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) {