r3082: added a "cifs:mapgeneric" option, which tells the cifs backend to use
authorAndrew Tridgell <tridge@samba.org>
Wed, 20 Oct 2004 11:08:58 +0000 (11:08 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:01:57 +0000 (13:01 -0500)
the ntvfs_generic mapping functions rather than sending the exact
function asked for. This allows the generic mapping functions to be
tested by comparing the behaviour of smbtorture against two cifs
backend shares, one using "cifs:mapgeneric = true" and the other
"cifs:mapgeneric = False"
(This used to be commit c240c6bca5e10f1acbff45b0ed41c4c1ebcaae96)

source4/include/smb_interfaces.h
source4/ntvfs/cifs/vfs_cifs.c

index 7a369a04cbfe0df322466d332d84545cf10a2656..7f0133bbd77b53aa26783db502a537f19bb44421 100644 (file)
@@ -1327,7 +1327,8 @@ union smb_read {
 
 
 enum smb_write_level {RAW_WRITE_WRITEUNLOCK, RAW_WRITE_WRITE, 
-                     RAW_WRITE_WRITEX, RAW_WRITE_WRITECLOSE, RAW_WRITE_SPLWRITE};
+                     RAW_WRITE_WRITEX, RAW_WRITE_WRITECLOSE, 
+                     RAW_WRITE_SPLWRITE};
 
 #define RAW_WRITE_GENERIC RAW_WRITE_WRITEX
 
index feacc063b42de9f02e6a13af1a5908179508f2cd..07cfb912bde6a2c5ad1c31d0bdf6eb9d4186d12e 100644 (file)
@@ -32,7 +32,7 @@ struct cvfs_private {
        struct smbcli_tree *tree;
        struct smbcli_transport *transport;
        struct smbsrv_tcon *tcon;
-       /*const struct ntvfs_ops *ops;*/
+       BOOL map_generic;
 };
 
 
@@ -152,6 +152,8 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
        private->transport->event.ctx = event_context_merge(tcon->smb_conn->connection->event.ctx,
                                                            private->transport->event.ctx);
        talloc_reference(private, private->transport->event.ctx);
+       private->map_generic = lp_parm_bool(req->tcon->service, 
+                                           "cifs", "mapgeneric", False);
 
        return NT_STATUS_OK;
 }
@@ -370,6 +372,11 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
        struct cvfs_private *private = ntvfs->private_data;
        struct smbcli_request *c_req;
 
+       if (io->generic.level != RAW_OPEN_GENERIC &&
+           private->map_generic) {
+               return ntvfs_map_open(req, io, ntvfs);
+       }
+
        if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
                return smb_raw_open(private->tree, req, io);
        }
@@ -461,6 +468,11 @@ static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs,
        struct cvfs_private *private = ntvfs->private_data;
        struct smbcli_request *c_req;
 
+       if (rd->generic.level != RAW_READ_GENERIC &&
+           private->map_generic) {
+               return ntvfs_map_read(req, rd, ntvfs);
+       }
+
        if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
                return smb_raw_read(private->tree, rd);
        }
@@ -490,6 +502,11 @@ static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs,
        struct cvfs_private *private = ntvfs->private_data;
        struct smbcli_request *c_req;
 
+       if (wr->generic.level != RAW_WRITE_GENERIC &&
+           private->map_generic) {
+               return ntvfs_map_write(req, wr, ntvfs);
+       }
+
        if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
                return smb_raw_write(private->tree, wr);
        }
@@ -503,18 +520,36 @@ static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs,
   seek in a file
 */
 static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs, 
-                               struct smbsrv_request *req, struct smb_seek *io)
+                         struct smbsrv_request *req, struct smb_seek *io)
 {
-       return NT_STATUS_NOT_SUPPORTED;
+       struct cvfs_private *private = ntvfs->private_data;
+       struct smbcli_request *c_req;
+
+       if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
+               return smb_raw_seek(private->tree, io);
+       }
+
+       c_req = smb_raw_seek_send(private->tree, io);
+
+       SIMPLE_ASYNC_TAIL;
 }
 
 /*
   flush a file
 */
 static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, 
-                               struct smbsrv_request *req, struct smb_flush *io)
+                          struct smbsrv_request *req, struct smb_flush *io)
 {
-       return NT_STATUS_OK;
+       struct cvfs_private *private = ntvfs->private_data;
+       struct smbcli_request *c_req;
+
+       if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
+               return smb_raw_flush(private->tree, io);
+       }
+
+       c_req = smb_raw_flush_send(private->tree, io);
+
+       SIMPLE_ASYNC_TAIL;
 }
 
 /*
@@ -526,6 +561,11 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
        struct cvfs_private *private = ntvfs->private_data;
        struct smbcli_request *c_req;
 
+       if (io->generic.level != RAW_CLOSE_GENERIC &&
+           private->map_generic) {
+               return ntvfs_map_close(req, io, ntvfs);
+       }
+
        if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
                return smb_raw_close(private->tree, io);
        }
@@ -582,6 +622,11 @@ static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs,
        struct cvfs_private *private = ntvfs->private_data;
        struct smbcli_request *c_req;
 
+       if (lck->generic.level != RAW_LOCK_GENERIC &&
+           private->map_generic) {
+               return ntvfs_map_lock(req, lck, ntvfs);
+       }
+
        if (!(req->control_flags & REQ_CONTROL_MAY_ASYNC)) {
                return smb_raw_lock(private->tree, lck);
        }