r3039: This solves the problem of async handlers in ntvfs backends not being
[garming/samba-autobuild/.git] / source4 / ntvfs / cifs / vfs_cifs.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    CIFS-on-CIFS NTVFS filesystem backend
5
6    Copyright (C) Andrew Tridgell 2003
7    Copyright (C) James J Myers 2003 <myersjj@samba.org>
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23 /*
24   this implements a CIFS->CIFS NTVFS filesystem backend. 
25   
26 */
27
28 #include "includes.h"
29
30 /* this is stored in ntvfs_private */
31 struct cvfs_private {
32         struct smbcli_tree *tree;
33         struct smbcli_transport *transport;
34         struct smbsrv_tcon *tcon;
35         /*const struct ntvfs_ops *ops;*/
36 };
37
38
39 /* a structure used to pass information to an async handler */
40 struct async_info {
41         struct smbsrv_request *req;
42         void *parms;
43 };
44
45 /*
46   an idle function to cope with messages from the smbd client while 
47   waiting for a reply from the server
48   this function won't be needed once all of the cifs backend
49   and the core of smbd is converted to use async calls
50 */
51 static void idle_func(struct smbcli_transport *transport, void *p_private)
52 {
53         struct cvfs_private *private = p_private;
54         int fd = socket_get_fd(private->tcon->smb_conn->connection->socket);
55
56         if (socket_pending(fd)) {
57                 smbd_process_async(private->tcon->smb_conn);
58         }
59 }
60
61 /*
62   a handler for oplock break events from the server - these need to be passed
63   along to the client
64  */
65 static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
66 {
67         struct cvfs_private *private = p_private;
68         
69         DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum));
70         return req_send_oplock_break(private->tcon, fnum, level);
71 }
72
73  /*
74   a handler for read events on a connection to a backend server
75 */
76 static void cifs_socket_handler(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags)
77 {
78         struct cvfs_private *private = fde->private;
79         struct smbsrv_tcon *tcon = private->tcon;
80         
81         DEBUG(5,("cifs_socket_handler event on fd %d\n", fde->fd));
82         
83         if (!smbcli_transport_process(private->transport)) {
84                 /* the connection to our server is dead */
85                 close_cnum(tcon);
86         }
87 }
88
89 /*
90   connect to a share - used when a tree_connect operation comes in.
91 */
92 static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, 
93                                 struct smbsrv_request *req, const char *sharename)
94 {
95         struct smbsrv_tcon *tcon = req->tcon;
96         NTSTATUS status;
97         struct cvfs_private *private;
98         const char *host, *user, *pass, *domain, *remote_share;
99
100         /* Here we need to determine which server to connect to.
101          * For now we use parametric options, type cifs.
102          * Later we will use security=server and auth_server.c.
103          */
104         host = lp_parm_string(req->tcon->service, "cifs", "server");
105         user = lp_parm_string(req->tcon->service, "cifs", "user");
106         pass = lp_parm_string(req->tcon->service, "cifs", "password");
107         domain = lp_parm_string(req->tcon->service, "cifs", "domain");
108         remote_share = lp_parm_string(req->tcon->service, "cifs", "share");
109         if (!remote_share) {
110                 remote_share = sharename;
111         }
112
113         if (!host || !user || !pass || !domain) {
114                 DEBUG(1,("CIFS backend: You must supply server, user, password and domain\n"));
115                 return NT_STATUS_INVALID_PARAMETER;
116         }
117         
118         private = talloc(req->tcon, sizeof(struct cvfs_private));
119         if (!private) {
120                 return NT_STATUS_NO_MEMORY;
121         }
122         ZERO_STRUCTP(private);
123
124         ntvfs->private_data = private;
125
126         status = smbcli_tree_full_connection(private,
127                                              &private->tree, 
128                                              "vfs_cifs",
129                                              host,
130                                              0,
131                                              remote_share, "?????",
132                                              user, domain,
133                                              pass);
134         if (!NT_STATUS_IS_OK(status)) {
135                 return status;
136         }
137
138         private->transport = private->tree->session->transport;
139         private->tree->session->pid = SVAL(req->in.hdr, HDR_PID);
140         private->tcon = req->tcon;
141
142         tcon->fs_type = talloc_strdup(tcon, "NTFS");
143         tcon->dev_type = talloc_strdup(tcon, "A:");
144         
145         /* we need to receive oplock break requests from the server */
146         smbcli_oplock_handler(private->transport, oplock_handler, private);
147         smbcli_transport_idle_handler(private->transport, idle_func, 1, private);
148
149         private->transport->event.fde->handler = cifs_socket_handler;
150         private->transport->event.fde->private = private;
151
152         private->transport->event.ctx = event_context_merge(tcon->smb_conn->connection->event.ctx,
153                                                             private->transport->event.ctx);
154         talloc_reference(private, private->transport->event.ctx);
155
156         return NT_STATUS_OK;
157 }
158
159 /*
160   disconnect from a share
161 */
162 static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs, 
163                                 struct smbsrv_tcon *tcon)
164 {
165         struct cvfs_private *private = ntvfs->private_data;
166
167         smb_tree_disconnect(private->tree);
168         talloc_free(private->tree);
169
170         return NT_STATUS_OK;
171 }
172
173 /*
174   a handler for simple async replies
175   this handler can only be used for functions that don't return any
176   parameters (those that just return a status code)
177  */
178 static void async_simple(struct smbcli_request *c_req)
179 {
180         struct async_info *async = c_req->async.private;
181         struct smbsrv_request *req = async->req;
182         req->async.status = smbcli_request_simple_recv(c_req);
183         req->async.send_fn(req);
184 }
185
186
187 /* save some typing for the simple functions */
188 #define ASYNC_RECV_TAIL(io, async_fn) do { \
189         if (!c_req) return NT_STATUS_UNSUCCESSFUL; \
190         { \
191                 struct async_info *async; \
192                 async = talloc_p(req, struct async_info); \
193                 if (!async) return NT_STATUS_NO_MEMORY; \
194                 async->parms = io; \
195                 async->req = req; \
196                 c_req->async.private = async; \
197         } \
198         c_req->async.fn = async_fn; \
199         req->control_flags |= REQ_CONTROL_ASYNC; \
200         return NT_STATUS_OK; \
201 } while (0)
202
203 #define SIMPLE_ASYNC_TAIL ASYNC_RECV_TAIL(NULL, async_simple)
204
205 /*
206   delete a file - the dirtype specifies the file types to include in the search. 
207   The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
208 */
209 static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, 
210                                 struct smbsrv_request *req, struct smb_unlink *unl)
211 {
212         struct cvfs_private *private = ntvfs->private_data;
213         struct smbcli_request *c_req;
214
215         /* see if the front end will allow us to perform this
216            function asynchronously.  */
217         if (!req->async.send_fn) {
218                 return smb_raw_unlink(private->tree, unl);
219         }
220
221         c_req = smb_raw_unlink_send(private->tree, unl);
222
223         SIMPLE_ASYNC_TAIL;
224 }
225
226 /*
227   a handler for async ioctl replies
228  */
229 static void async_ioctl(struct smbcli_request *c_req)
230 {
231         struct async_info *async = c_req->async.private;
232         struct smbsrv_request *req = async->req;
233         req->async.status = smb_raw_ioctl_recv(c_req, req, async->parms);
234         req->async.send_fn(req);
235 }
236
237 /*
238   ioctl interface
239 */
240 static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, 
241                                 struct smbsrv_request *req, union smb_ioctl *io)
242 {
243         struct cvfs_private *private = ntvfs->private_data;
244         struct smbcli_request *c_req;
245
246         /* see if the front end will allow us to perform this
247            function asynchronously.  */
248         if (!req->async.send_fn) {
249                 return smb_raw_ioctl(private->tree, req, io);
250         }
251
252         c_req = smb_raw_ioctl_send(private->tree, io);
253
254         ASYNC_RECV_TAIL(io, async_ioctl);
255 }
256
257 /*
258   check if a directory exists
259 */
260 static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, 
261                                 struct smbsrv_request *req, struct smb_chkpath *cp)
262 {
263         struct cvfs_private *private = ntvfs->private_data;
264         struct smbcli_request *c_req;
265
266         if (!req->async.send_fn) {
267                 return smb_raw_chkpath(private->tree, cp);
268         }
269
270         c_req = smb_raw_chkpath_send(private->tree, cp);
271
272         SIMPLE_ASYNC_TAIL;
273 }
274
275 /*
276   a handler for async qpathinfo replies
277  */
278 static void async_qpathinfo(struct smbcli_request *c_req)
279 {
280         struct async_info *async = c_req->async.private;
281         struct smbsrv_request *req = async->req;
282         req->async.status = smb_raw_pathinfo_recv(c_req, req, async->parms);
283         req->async.send_fn(req);
284 }
285
286 /*
287   return info on a pathname
288 */
289 static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, 
290                                 struct smbsrv_request *req, union smb_fileinfo *info)
291 {
292         struct cvfs_private *private = ntvfs->private_data;
293         struct smbcli_request *c_req;
294
295         if (!req->async.send_fn) {
296                 return smb_raw_pathinfo(private->tree, req, info);
297         }
298
299         c_req = smb_raw_pathinfo_send(private->tree, info);
300
301         ASYNC_RECV_TAIL(info, async_qpathinfo);
302 }
303
304 /*
305   a handler for async qfileinfo replies
306  */
307 static void async_qfileinfo(struct smbcli_request *c_req)
308 {
309         struct async_info *async = c_req->async.private;
310         struct smbsrv_request *req = async->req;
311         req->async.status = smb_raw_fileinfo_recv(c_req, req, async->parms);
312         req->async.send_fn(req);
313 }
314
315 /*
316   query info on a open file
317 */
318 static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, 
319                                 struct smbsrv_request *req, union smb_fileinfo *info)
320 {
321         struct cvfs_private *private = ntvfs->private_data;
322         struct smbcli_request *c_req;
323
324         if (!req->async.send_fn) {
325                 return smb_raw_fileinfo(private->tree, req, info);
326         }
327
328         c_req = smb_raw_fileinfo_send(private->tree, info);
329
330         ASYNC_RECV_TAIL(info, async_qfileinfo);
331 }
332
333
334 /*
335   set info on a pathname
336 */
337 static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, 
338                                 struct smbsrv_request *req, union smb_setfileinfo *st)
339 {
340         struct cvfs_private *private = ntvfs->private_data;
341         struct smbcli_request *c_req;
342
343         if (!req->async.send_fn) {
344                 return smb_raw_setpathinfo(private->tree, st);
345         }
346
347         c_req = smb_raw_setpathinfo_send(private->tree, st);
348
349         SIMPLE_ASYNC_TAIL;
350 }
351
352
353 /*
354   a handler for async open replies
355  */
356 static void async_open(struct smbcli_request *c_req)
357 {
358         struct async_info *async = c_req->async.private;
359         struct smbsrv_request *req = async->req;
360         req->async.status = smb_raw_open_recv(c_req, req, async->parms);
361         req->async.send_fn(req);
362 }
363
364 /*
365   open a file
366 */
367 static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, 
368                                 struct smbsrv_request *req, union smb_open *io)
369 {
370         struct cvfs_private *private = ntvfs->private_data;
371         struct smbcli_request *c_req;
372
373         if (!req->async.send_fn) {
374                 return smb_raw_open(private->tree, req, io);
375         }
376
377         c_req = smb_raw_open_send(private->tree, io);
378
379         ASYNC_RECV_TAIL(io, async_open);
380 }
381
382 /*
383   create a directory
384 */
385 static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, 
386                                 struct smbsrv_request *req, union smb_mkdir *md)
387 {
388         struct cvfs_private *private = ntvfs->private_data;
389         struct smbcli_request *c_req;
390
391         if (!req->async.send_fn) {
392                 return smb_raw_mkdir(private->tree, md);
393         }
394
395         c_req = smb_raw_mkdir_send(private->tree, md);
396
397         SIMPLE_ASYNC_TAIL;
398 }
399
400 /*
401   remove a directory
402 */
403 static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, 
404                                 struct smbsrv_request *req, struct smb_rmdir *rd)
405 {
406         struct cvfs_private *private = ntvfs->private_data;
407         struct smbcli_request *c_req;
408
409         if (!req->async.send_fn) {
410                 return smb_raw_rmdir(private->tree, rd);
411         }
412         c_req = smb_raw_rmdir_send(private->tree, rd);
413
414         SIMPLE_ASYNC_TAIL;
415 }
416
417 /*
418   rename a set of files
419 */
420 static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, 
421                                 struct smbsrv_request *req, union smb_rename *ren)
422 {
423         struct cvfs_private *private = ntvfs->private_data;
424         struct smbcli_request *c_req;
425
426         if (!req->async.send_fn) {
427                 return smb_raw_rename(private->tree, ren);
428         }
429
430         c_req = smb_raw_rename_send(private->tree, ren);
431
432         SIMPLE_ASYNC_TAIL;
433 }
434
435 /*
436   copy a set of files
437 */
438 static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs, 
439                                 struct smbsrv_request *req, struct smb_copy *cp)
440 {
441         return NT_STATUS_NOT_SUPPORTED;
442 }
443
444 /*
445   a handler for async read replies
446  */
447 static void async_read(struct smbcli_request *c_req)
448 {
449         struct async_info *async = c_req->async.private;
450         struct smbsrv_request *req = async->req;
451         req->async.status = smb_raw_read_recv(c_req, async->parms);
452         req->async.send_fn(req);
453 }
454
455 /*
456   read from a file
457 */
458 static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, 
459                                 struct smbsrv_request *req, union smb_read *rd)
460 {
461         struct cvfs_private *private = ntvfs->private_data;
462         struct smbcli_request *c_req;
463
464         if (!req->async.send_fn) {
465                 return smb_raw_read(private->tree, rd);
466         }
467
468         c_req = smb_raw_read_send(private->tree, rd);
469
470         ASYNC_RECV_TAIL(rd, async_read);
471 }
472
473 /*
474   a handler for async write replies
475  */
476 static void async_write(struct smbcli_request *c_req)
477 {
478         struct async_info *async = c_req->async.private;
479         struct smbsrv_request *req = async->req;
480         req->async.status = smb_raw_write_recv(c_req, async->parms);
481         req->async.send_fn(req);
482 }
483
484 /*
485   write to a file
486 */
487 static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, 
488                                 struct smbsrv_request *req, union smb_write *wr)
489 {
490         struct cvfs_private *private = ntvfs->private_data;
491         struct smbcli_request *c_req;
492
493         if (!req->async.send_fn) {
494                 return smb_raw_write(private->tree, wr);
495         }
496
497         c_req = smb_raw_write_send(private->tree, wr);
498
499         ASYNC_RECV_TAIL(wr, async_write);
500 }
501
502 /*
503   seek in a file
504 */
505 static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs, 
506                                 struct smbsrv_request *req, struct smb_seek *io)
507 {
508         return NT_STATUS_NOT_SUPPORTED;
509 }
510
511 /*
512   flush a file
513 */
514 static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, 
515                                 struct smbsrv_request *req, struct smb_flush *io)
516 {
517         return NT_STATUS_OK;
518 }
519
520 /*
521   close a file
522 */
523 static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, 
524                                 struct smbsrv_request *req, union smb_close *io)
525 {
526         struct cvfs_private *private = ntvfs->private_data;
527         struct smbcli_request *c_req;
528
529         if (!req->async.send_fn) {
530                 return smb_raw_close(private->tree, io);
531         }
532
533         c_req = smb_raw_close_send(private->tree, io);
534
535         SIMPLE_ASYNC_TAIL;
536 }
537
538 /*
539   exit - closing files open by the pid
540 */
541 static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs, 
542                                 struct smbsrv_request *req)
543 {
544         struct cvfs_private *private = ntvfs->private_data;
545         struct smbcli_request *c_req;
546
547         if (!req->async.send_fn) {
548                 return smb_raw_exit(private->tree->session);
549         }
550
551         c_req = smb_raw_exit_send(private->tree->session);
552
553         SIMPLE_ASYNC_TAIL;
554 }
555
556 /*
557   logoff - closing files open by the user
558 */
559 static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs, 
560                                 struct smbsrv_request *req)
561 {
562         /* we can't do this right in the cifs backend .... */
563         return NT_STATUS_OK;
564 }
565
566 /*
567   setup for an async call - nothing to do yet
568 */
569 static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, 
570                                  struct smbsrv_request *req, 
571                                  void *private)
572 {
573         return NT_STATUS_OK;
574 }
575
576 /*
577   lock a byte range
578 */
579 static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs, 
580                                 struct smbsrv_request *req, union smb_lock *lck)
581 {
582         struct cvfs_private *private = ntvfs->private_data;
583         struct smbcli_request *c_req;
584
585         if (!req->async.send_fn) {
586                 return smb_raw_lock(private->tree, lck);
587         }
588
589         c_req = smb_raw_lock_send(private->tree, lck);
590         SIMPLE_ASYNC_TAIL;
591 }
592
593 /*
594   set info on a open file
595 */
596 static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, 
597                                  struct smbsrv_request *req, 
598                                  union smb_setfileinfo *info)
599 {
600         struct cvfs_private *private = ntvfs->private_data;
601         struct smbcli_request *c_req;
602
603         if (!req->async.send_fn) {
604                 return smb_raw_setfileinfo(private->tree, info);
605         }
606         c_req = smb_raw_setfileinfo_send(private->tree, info);
607
608         SIMPLE_ASYNC_TAIL;
609 }
610
611
612 /*
613   a handler for async fsinfo replies
614  */
615 static void async_fsinfo(struct smbcli_request *c_req)
616 {
617         struct async_info *async = c_req->async.private;
618         struct smbsrv_request *req = async->req;
619         req->async.status = smb_raw_fsinfo_recv(c_req, req, async->parms);
620         req->async.send_fn(req);
621 }
622
623 /*
624   return filesystem space info
625 */
626 static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, 
627                                 struct smbsrv_request *req, union smb_fsinfo *fs)
628 {
629         struct cvfs_private *private = ntvfs->private_data;
630         struct smbcli_request *c_req;
631
632         if (!req->async.send_fn) {
633                 return smb_raw_fsinfo(private->tree, req, fs);
634         }
635
636         c_req = smb_raw_fsinfo_send(private->tree, req, fs);
637
638         ASYNC_RECV_TAIL(fs, async_fsinfo);
639 }
640
641 /*
642   return print queue info
643 */
644 static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs, 
645                                 struct smbsrv_request *req, union smb_lpq *lpq)
646 {
647         return NT_STATUS_NOT_SUPPORTED;
648 }
649
650 /* 
651    list files in a directory matching a wildcard pattern
652 */
653 static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, 
654                                   struct smbsrv_request *req, union smb_search_first *io, 
655                                   void *search_private, 
656                                   BOOL (*callback)(void *, union smb_search_data *))
657 {
658         struct cvfs_private *private = ntvfs->private_data;
659
660         return smb_raw_search_first(private->tree, req, io, search_private, callback);
661 }
662
663 /* continue a search */
664 static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs, 
665                                  struct smbsrv_request *req, union smb_search_next *io, 
666                                  void *search_private, 
667                                  BOOL (*callback)(void *, union smb_search_data *))
668 {
669         struct cvfs_private *private = ntvfs->private_data;
670
671         return smb_raw_search_next(private->tree, req, io, search_private, callback);
672 }
673
674 /* close a search */
675 static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs, 
676                                   struct smbsrv_request *req, union smb_search_close *io)
677 {
678         struct cvfs_private *private = ntvfs->private_data;
679
680         return smb_raw_search_close(private->tree, io);
681 }
682
683 /*
684   a handler for async trans2 replies
685  */
686 static void async_trans2(struct smbcli_request *c_req)
687 {
688         struct async_info *async = c_req->async.private;
689         struct smbsrv_request *req = async->req;
690         req->async.status = smb_raw_trans2_recv(c_req, req, async->parms);
691         req->async.send_fn(req);
692 }
693
694 /* raw trans2 */
695 static NTSTATUS cvfs_trans2(struct ntvfs_module_context *ntvfs, 
696                                 struct smbsrv_request *req, struct smb_trans2 *trans2)
697 {
698         struct cvfs_private *private = ntvfs->private_data;
699         struct smbcli_request *c_req;
700
701         if (!req->async.send_fn) {
702                 return smb_raw_trans2(private->tree, req, trans2);
703         }
704
705         c_req = smb_raw_trans2_send(private->tree, trans2);
706
707         ASYNC_RECV_TAIL(trans2, async_trans2);
708 }
709
710
711 /* SMBtrans - not used on file shares */
712 static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs, 
713                                 struct smbsrv_request *req, struct smb_trans2 *trans2)
714 {
715         return NT_STATUS_ACCESS_DENIED;
716 }
717
718 /*
719   initialise the CIFS->CIFS backend, registering ourselves with the ntvfs subsystem
720  */
721 NTSTATUS ntvfs_cifs_init(void)
722 {
723         NTSTATUS ret;
724         struct ntvfs_ops ops;
725
726         ZERO_STRUCT(ops);
727
728         /* fill in the name and type */
729         ops.name = "cifs";
730         ops.type = NTVFS_DISK;
731         
732         /* fill in all the operations */
733         ops.connect = cvfs_connect;
734         ops.disconnect = cvfs_disconnect;
735         ops.unlink = cvfs_unlink;
736         ops.chkpath = cvfs_chkpath;
737         ops.qpathinfo = cvfs_qpathinfo;
738         ops.setpathinfo = cvfs_setpathinfo;
739         ops.open = cvfs_open;
740         ops.mkdir = cvfs_mkdir;
741         ops.rmdir = cvfs_rmdir;
742         ops.rename = cvfs_rename;
743         ops.copy = cvfs_copy;
744         ops.ioctl = cvfs_ioctl;
745         ops.read = cvfs_read;
746         ops.write = cvfs_write;
747         ops.seek = cvfs_seek;
748         ops.flush = cvfs_flush; 
749         ops.close = cvfs_close;
750         ops.exit = cvfs_exit;
751         ops.lock = cvfs_lock;
752         ops.setfileinfo = cvfs_setfileinfo;
753         ops.qfileinfo = cvfs_qfileinfo;
754         ops.fsinfo = cvfs_fsinfo;
755         ops.lpq = cvfs_lpq;
756         ops.search_first = cvfs_search_first;
757         ops.search_next = cvfs_search_next;
758         ops.search_close = cvfs_search_close;
759         ops.trans = cvfs_trans;
760         ops.logoff = cvfs_logoff;
761         ops.async_setup = cvfs_async_setup;
762
763         if (lp_parm_bool(-1, "cifs", "maptrans2", False)) {
764                 ops.trans2 = cvfs_trans2;
765         }
766
767         /* register ourselves with the NTVFS subsystem. We register
768            under the name 'cifs'. */
769         ret = register_backend("ntvfs", &ops);
770
771         if (!NT_STATUS_IS_OK(ret)) {
772                 DEBUG(0,("Failed to register CIFS backend!\n"));
773         }
774         
775         return ret;
776 }