2 Unix SMB/CIFS implementation.
4 CIFS-on-CIFS NTVFS filesystem backend
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) James J Myers 2003 <myersjj@samba.org>
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.
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.
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.
24 this implements a CIFS->CIFS NTVFS filesystem backend.
29 #include "libcli/raw/libcliraw.h"
30 #include "libcli/smb_composite/smb_composite.h"
31 #include "auth/auth.h"
32 #include "ntvfs/ntvfs.h"
33 #include "include/dlinklist.h"
35 /* this is stored in ntvfs_private */
37 struct smbcli_tree *tree;
38 struct smbcli_transport *transport;
39 struct ntvfs_module_context *ntvfs;
40 struct async_info *pending;
45 /* a structure used to pass information to an async handler */
47 struct async_info *next, *prev;
48 struct cvfs_private *cvfs;
49 struct ntvfs_request *req;
50 struct smbcli_request *c_req;
54 #define SETUP_PID private->tree->session->pid = req->smbpid
57 a handler for oplock break events from the server - these need to be passed
60 static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
62 struct cvfs_private *private = p_private;
65 DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum));
66 status = ntvfs_send_oplock_break(private->ntvfs, fnum, level);
67 if (!NT_STATUS_IS_OK(status)) return False;
72 connect to a share - used when a tree_connect operation comes in.
74 static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
75 struct ntvfs_request *req, const char *sharename)
78 struct cvfs_private *private;
79 const char *host, *user, *pass, *domain, *remote_share;
80 struct smb_composite_connect io;
81 struct composite_context *creq;
82 int snum = ntvfs->ctx->config.snum;
84 struct cli_credentials *credentials;
87 /* Here we need to determine which server to connect to.
88 * For now we use parametric options, type cifs.
89 * Later we will use security=server and auth_server.c.
91 host = lp_parm_string(snum, "cifs", "server");
92 user = lp_parm_string(snum, "cifs", "user");
93 pass = lp_parm_string(snum, "cifs", "password");
94 domain = lp_parm_string(snum, "cifs", "domain");
95 remote_share = lp_parm_string(snum, "cifs", "share");
97 remote_share = sharename;
100 machine_account = lp_parm_bool(snum, "cifs", "use_machine_account", False);
102 private = talloc_zero(ntvfs, struct cvfs_private);
104 return NT_STATUS_NO_MEMORY;
107 ntvfs->private_data = private;
110 DEBUG(1,("CIFS backend: You must supply server\n"));
111 return NT_STATUS_INVALID_PARAMETER;
115 DEBUG(5, ("CIFS backend: Using specified password\n"));
116 credentials = cli_credentials_init(private);
118 return NT_STATUS_NO_MEMORY;
120 cli_credentials_set_conf(credentials);
121 cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
123 cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
125 cli_credentials_set_password(credentials, pass, CRED_SPECIFIED);
126 } else if (machine_account) {
127 DEBUG(5, ("CIFS backend: Using machine account\n"));
128 credentials = cli_credentials_init(private);
129 cli_credentials_set_conf(credentials);
131 cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
133 status = cli_credentials_set_machine_account(credentials);
134 if (!NT_STATUS_IS_OK(status)) {
137 } else if (req->session_info->credentials) {
138 DEBUG(5, ("CIFS backend: Using delegated credentials\n"));
139 credentials = req->session_info->credentials;
141 DEBUG(1,("CIFS backend: You must supply server, user and password and or have delegated credentials\n"));
142 return NT_STATUS_INVALID_PARAMETER;
145 /* connect to the server, using the smbd event context */
146 io.in.dest_host = host;
148 io.in.called_name = host;
149 io.in.credentials = credentials;
150 io.in.fallback_to_anonymous = False;
151 io.in.workgroup = lp_workgroup();
152 io.in.service = remote_share;
153 io.in.service_type = "?????";
155 creq = smb_composite_connect_send(&io, private, ntvfs->ctx->event_ctx);
156 status = smb_composite_connect_recv(creq, private);
157 NT_STATUS_NOT_OK_RETURN(status);
159 private->tree = io.out.tree;
161 private->transport = private->tree->session->transport;
163 private->ntvfs = ntvfs;
165 ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
166 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
167 ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:");
168 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
170 /* we need to receive oplock break requests from the server */
171 smbcli_oplock_handler(private->transport, oplock_handler, private);
173 private->map_generic = lp_parm_bool(ntvfs->ctx->config.snum,
174 "cifs", "mapgeneric", False);
180 disconnect from a share
182 static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs)
184 struct cvfs_private *private = ntvfs->private_data;
185 struct async_info *a, *an;
187 /* first cleanup pending requests */
188 for (a=private->pending; a; a = an) {
190 smbcli_request_destroy(a->c_req);
194 talloc_free(private);
195 ntvfs->private_data = NULL;
201 destroy an async info structure
203 static int async_info_destructor(void *p)
205 struct async_info *async = talloc_get_type(p, struct async_info);
206 DLIST_REMOVE(async->cvfs->pending, async);
211 a handler for simple async replies
212 this handler can only be used for functions that don't return any
213 parameters (those that just return a status code)
215 static void async_simple(struct smbcli_request *c_req)
217 struct async_info *async = c_req->async.private;
218 struct ntvfs_request *req = async->req;
219 req->async_states->status = smbcli_request_simple_recv(c_req);
221 req->async_states->send_fn(req);
225 /* save some typing for the simple functions */
226 #define ASYNC_RECV_TAIL(io, async_fn) do { \
227 if (!c_req) return NT_STATUS_UNSUCCESSFUL; \
229 struct async_info *async; \
230 async = talloc(req, struct async_info); \
231 if (!async) return NT_STATUS_NO_MEMORY; \
234 async->cvfs = private; \
235 async->c_req = c_req; \
236 DLIST_ADD(private->pending, async); \
237 c_req->async.private = async; \
238 talloc_set_destructor(async, async_info_destructor); \
240 c_req->async.fn = async_fn; \
241 req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; \
242 return NT_STATUS_OK; \
245 #define SIMPLE_ASYNC_TAIL ASYNC_RECV_TAIL(NULL, async_simple)
248 delete a file - the dirtype specifies the file types to include in the search.
249 The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
251 static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs,
252 struct ntvfs_request *req, union smb_unlink *unl)
254 struct cvfs_private *private = ntvfs->private_data;
255 struct smbcli_request *c_req;
259 /* see if the front end will allow us to perform this
260 function asynchronously. */
261 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
262 return smb_raw_unlink(private->tree, unl);
265 c_req = smb_raw_unlink_send(private->tree, unl);
271 a handler for async ioctl replies
273 static void async_ioctl(struct smbcli_request *c_req)
275 struct async_info *async = c_req->async.private;
276 struct ntvfs_request *req = async->req;
277 req->async_states->status = smb_raw_ioctl_recv(c_req, req, async->parms);
279 req->async_states->send_fn(req);
285 static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs,
286 struct ntvfs_request *req, union smb_ioctl *io)
288 struct cvfs_private *private = ntvfs->private_data;
289 struct smbcli_request *c_req;
293 /* see if the front end will allow us to perform this
294 function asynchronously. */
295 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
296 return smb_raw_ioctl(private->tree, req, io);
299 c_req = smb_raw_ioctl_send(private->tree, io);
301 ASYNC_RECV_TAIL(io, async_ioctl);
305 check if a directory exists
307 static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs,
308 struct ntvfs_request *req, union smb_chkpath *cp)
310 struct cvfs_private *private = ntvfs->private_data;
311 struct smbcli_request *c_req;
315 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
316 return smb_raw_chkpath(private->tree, cp);
319 c_req = smb_raw_chkpath_send(private->tree, cp);
325 a handler for async qpathinfo replies
327 static void async_qpathinfo(struct smbcli_request *c_req)
329 struct async_info *async = c_req->async.private;
330 struct ntvfs_request *req = async->req;
331 req->async_states->status = smb_raw_pathinfo_recv(c_req, req, async->parms);
333 req->async_states->send_fn(req);
337 return info on a pathname
339 static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs,
340 struct ntvfs_request *req, union smb_fileinfo *info)
342 struct cvfs_private *private = ntvfs->private_data;
343 struct smbcli_request *c_req;
347 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
348 return smb_raw_pathinfo(private->tree, req, info);
351 c_req = smb_raw_pathinfo_send(private->tree, info);
353 ASYNC_RECV_TAIL(info, async_qpathinfo);
357 a handler for async qfileinfo replies
359 static void async_qfileinfo(struct smbcli_request *c_req)
361 struct async_info *async = c_req->async.private;
362 struct ntvfs_request *req = async->req;
363 req->async_states->status = smb_raw_fileinfo_recv(c_req, req, async->parms);
365 req->async_states->send_fn(req);
369 query info on a open file
371 static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
372 struct ntvfs_request *req, union smb_fileinfo *info)
374 struct cvfs_private *private = ntvfs->private_data;
375 struct smbcli_request *c_req;
379 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
380 return smb_raw_fileinfo(private->tree, req, info);
383 c_req = smb_raw_fileinfo_send(private->tree, info);
385 ASYNC_RECV_TAIL(info, async_qfileinfo);
390 set info on a pathname
392 static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
393 struct ntvfs_request *req, union smb_setfileinfo *st)
395 struct cvfs_private *private = ntvfs->private_data;
396 struct smbcli_request *c_req;
400 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
401 return smb_raw_setpathinfo(private->tree, st);
404 c_req = smb_raw_setpathinfo_send(private->tree, st);
411 a handler for async open replies
413 static void async_open(struct smbcli_request *c_req)
415 struct async_info *async = c_req->async.private;
416 struct ntvfs_request *req = async->req;
417 req->async_states->status = smb_raw_open_recv(c_req, req, async->parms);
419 req->async_states->send_fn(req);
425 static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
426 struct ntvfs_request *req, union smb_open *io)
428 struct cvfs_private *private = ntvfs->private_data;
429 struct smbcli_request *c_req;
433 if (io->generic.level != RAW_OPEN_GENERIC &&
434 private->map_generic) {
435 return ntvfs_map_open(ntvfs, req, io);
438 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
439 return smb_raw_open(private->tree, req, io);
442 c_req = smb_raw_open_send(private->tree, io);
444 ASYNC_RECV_TAIL(io, async_open);
450 static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs,
451 struct ntvfs_request *req, union smb_mkdir *md)
453 struct cvfs_private *private = ntvfs->private_data;
454 struct smbcli_request *c_req;
458 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
459 return smb_raw_mkdir(private->tree, md);
462 c_req = smb_raw_mkdir_send(private->tree, md);
470 static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs,
471 struct ntvfs_request *req, struct smb_rmdir *rd)
473 struct cvfs_private *private = ntvfs->private_data;
474 struct smbcli_request *c_req;
478 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
479 return smb_raw_rmdir(private->tree, rd);
481 c_req = smb_raw_rmdir_send(private->tree, rd);
487 rename a set of files
489 static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs,
490 struct ntvfs_request *req, union smb_rename *ren)
492 struct cvfs_private *private = ntvfs->private_data;
493 struct smbcli_request *c_req;
497 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
498 return smb_raw_rename(private->tree, ren);
501 c_req = smb_raw_rename_send(private->tree, ren);
509 static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs,
510 struct ntvfs_request *req, struct smb_copy *cp)
512 return NT_STATUS_NOT_SUPPORTED;
516 a handler for async read replies
518 static void async_read(struct smbcli_request *c_req)
520 struct async_info *async = c_req->async.private;
521 struct ntvfs_request *req = async->req;
522 req->async_states->status = smb_raw_read_recv(c_req, async->parms);
524 req->async_states->send_fn(req);
530 static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs,
531 struct ntvfs_request *req, union smb_read *rd)
533 struct cvfs_private *private = ntvfs->private_data;
534 struct smbcli_request *c_req;
538 if (rd->generic.level != RAW_READ_GENERIC &&
539 private->map_generic) {
540 return ntvfs_map_read(ntvfs, req, rd);
543 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
544 return smb_raw_read(private->tree, rd);
547 c_req = smb_raw_read_send(private->tree, rd);
549 ASYNC_RECV_TAIL(rd, async_read);
553 a handler for async write replies
555 static void async_write(struct smbcli_request *c_req)
557 struct async_info *async = c_req->async.private;
558 struct ntvfs_request *req = async->req;
559 req->async_states->status = smb_raw_write_recv(c_req, async->parms);
561 req->async_states->send_fn(req);
567 static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs,
568 struct ntvfs_request *req, union smb_write *wr)
570 struct cvfs_private *private = ntvfs->private_data;
571 struct smbcli_request *c_req;
575 if (wr->generic.level != RAW_WRITE_GENERIC &&
576 private->map_generic) {
577 return ntvfs_map_write(ntvfs, req, wr);
580 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
581 return smb_raw_write(private->tree, wr);
584 c_req = smb_raw_write_send(private->tree, wr);
586 ASYNC_RECV_TAIL(wr, async_write);
590 a handler for async seek replies
592 static void async_seek(struct smbcli_request *c_req)
594 struct async_info *async = c_req->async.private;
595 struct ntvfs_request *req = async->req;
596 req->async_states->status = smb_raw_seek_recv(c_req, async->parms);
598 req->async_states->send_fn(req);
604 static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs,
605 struct ntvfs_request *req,
608 struct cvfs_private *private = ntvfs->private_data;
609 struct smbcli_request *c_req;
613 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
614 return smb_raw_seek(private->tree, io);
617 c_req = smb_raw_seek_send(private->tree, io);
619 ASYNC_RECV_TAIL(io, async_seek);
625 static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs,
626 struct ntvfs_request *req,
629 struct cvfs_private *private = ntvfs->private_data;
630 struct smbcli_request *c_req;
634 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
635 return smb_raw_flush(private->tree, io);
638 c_req = smb_raw_flush_send(private->tree, io);
646 static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
647 struct ntvfs_request *req, union smb_close *io)
649 struct cvfs_private *private = ntvfs->private_data;
650 struct smbcli_request *c_req;
654 if (io->generic.level != RAW_CLOSE_GENERIC &&
655 private->map_generic) {
656 return ntvfs_map_close(ntvfs, req, io);
659 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
660 return smb_raw_close(private->tree, io);
663 c_req = smb_raw_close_send(private->tree, io);
669 exit - closing files open by the pid
671 static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs,
672 struct ntvfs_request *req)
674 struct cvfs_private *private = ntvfs->private_data;
675 struct smbcli_request *c_req;
679 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
680 return smb_raw_exit(private->tree->session);
683 c_req = smb_raw_exit_send(private->tree->session);
689 logoff - closing files open by the user
691 static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs,
692 struct ntvfs_request *req)
694 /* we can't do this right in the cifs backend .... */
699 setup for an async call - nothing to do yet
701 static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs,
702 struct ntvfs_request *req,
711 static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs,
712 struct ntvfs_request *req)
714 struct cvfs_private *private = ntvfs->private_data;
715 struct async_info *a;
717 /* find the matching request */
718 for (a=private->pending;a;a=a->next) {
719 if (a->req->smbmid == req->smbmid) {
725 return NT_STATUS_INVALID_PARAMETER;
728 return smb_raw_ntcancel(a->c_req);
734 static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs,
735 struct ntvfs_request *req, union smb_lock *lck)
737 struct cvfs_private *private = ntvfs->private_data;
738 struct smbcli_request *c_req;
742 if (lck->generic.level != RAW_LOCK_GENERIC &&
743 private->map_generic) {
744 return ntvfs_map_lock(ntvfs, req, lck);
747 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
748 return smb_raw_lock(private->tree, lck);
751 c_req = smb_raw_lock_send(private->tree, lck);
756 set info on a open file
758 static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
759 struct ntvfs_request *req,
760 union smb_setfileinfo *info)
762 struct cvfs_private *private = ntvfs->private_data;
763 struct smbcli_request *c_req;
767 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
768 return smb_raw_setfileinfo(private->tree, info);
770 c_req = smb_raw_setfileinfo_send(private->tree, info);
777 a handler for async fsinfo replies
779 static void async_fsinfo(struct smbcli_request *c_req)
781 struct async_info *async = c_req->async.private;
782 struct ntvfs_request *req = async->req;
783 req->async_states->status = smb_raw_fsinfo_recv(c_req, req, async->parms);
785 req->async_states->send_fn(req);
789 return filesystem space info
791 static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs,
792 struct ntvfs_request *req, union smb_fsinfo *fs)
794 struct cvfs_private *private = ntvfs->private_data;
795 struct smbcli_request *c_req;
799 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
800 return smb_raw_fsinfo(private->tree, req, fs);
803 c_req = smb_raw_fsinfo_send(private->tree, req, fs);
805 ASYNC_RECV_TAIL(fs, async_fsinfo);
809 return print queue info
811 static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs,
812 struct ntvfs_request *req, union smb_lpq *lpq)
814 return NT_STATUS_NOT_SUPPORTED;
818 list files in a directory matching a wildcard pattern
820 static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
821 struct ntvfs_request *req, union smb_search_first *io,
822 void *search_private,
823 BOOL (*callback)(void *, union smb_search_data *))
825 struct cvfs_private *private = ntvfs->private_data;
829 return smb_raw_search_first(private->tree, req, io, search_private, callback);
832 /* continue a search */
833 static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs,
834 struct ntvfs_request *req, union smb_search_next *io,
835 void *search_private,
836 BOOL (*callback)(void *, union smb_search_data *))
838 struct cvfs_private *private = ntvfs->private_data;
842 return smb_raw_search_next(private->tree, req, io, search_private, callback);
846 static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs,
847 struct ntvfs_request *req, union smb_search_close *io)
849 struct cvfs_private *private = ntvfs->private_data;
853 return smb_raw_search_close(private->tree, io);
857 a handler for async trans2 replies
859 static void async_trans2(struct smbcli_request *c_req)
861 struct async_info *async = c_req->async.private;
862 struct ntvfs_request *req = async->req;
863 req->async_states->status = smb_raw_trans2_recv(c_req, req, async->parms);
865 req->async_states->send_fn(req);
869 static NTSTATUS cvfs_trans2(struct ntvfs_module_context *ntvfs,
870 struct ntvfs_request *req,
871 struct smb_trans2 *trans2)
873 struct cvfs_private *private = ntvfs->private_data;
874 struct smbcli_request *c_req;
878 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
879 return smb_raw_trans2(private->tree, req, trans2);
882 c_req = smb_raw_trans2_send(private->tree, trans2);
884 ASYNC_RECV_TAIL(trans2, async_trans2);
888 /* SMBtrans - not used on file shares */
889 static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs,
890 struct ntvfs_request *req,
891 struct smb_trans2 *trans2)
893 return NT_STATUS_ACCESS_DENIED;
897 a handler for async change notify replies
899 static void async_changenotify(struct smbcli_request *c_req)
901 struct async_info *async = c_req->async.private;
902 struct ntvfs_request *req = async->req;
903 req->async_states->status = smb_raw_changenotify_recv(c_req, req, async->parms);
905 req->async_states->send_fn(req);
908 /* change notify request - always async */
909 static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs,
910 struct ntvfs_request *req,
911 struct smb_notify *info)
913 struct cvfs_private *private = ntvfs->private_data;
914 struct smbcli_request *c_req;
915 int saved_timeout = private->transport->options.request_timeout;
919 /* this request doesn't make sense unless its async */
920 if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
921 return NT_STATUS_INVALID_PARAMETER;
924 /* we must not timeout on notify requests - they wait
926 private->transport->options.request_timeout = 0;
928 c_req = smb_raw_changenotify_send(private->tree, info);
930 private->transport->options.request_timeout = saved_timeout;
932 ASYNC_RECV_TAIL(info, async_changenotify);
936 initialise the CIFS->CIFS backend, registering ourselves with the ntvfs subsystem
938 NTSTATUS ntvfs_cifs_init(void)
941 struct ntvfs_ops ops;
945 /* fill in the name and type */
947 ops.type = NTVFS_DISK;
949 /* fill in all the operations */
950 ops.connect = cvfs_connect;
951 ops.disconnect = cvfs_disconnect;
952 ops.unlink = cvfs_unlink;
953 ops.chkpath = cvfs_chkpath;
954 ops.qpathinfo = cvfs_qpathinfo;
955 ops.setpathinfo = cvfs_setpathinfo;
956 ops.open = cvfs_open;
957 ops.mkdir = cvfs_mkdir;
958 ops.rmdir = cvfs_rmdir;
959 ops.rename = cvfs_rename;
960 ops.copy = cvfs_copy;
961 ops.ioctl = cvfs_ioctl;
962 ops.read = cvfs_read;
963 ops.write = cvfs_write;
964 ops.seek = cvfs_seek;
965 ops.flush = cvfs_flush;
966 ops.close = cvfs_close;
967 ops.exit = cvfs_exit;
968 ops.lock = cvfs_lock;
969 ops.setfileinfo = cvfs_setfileinfo;
970 ops.qfileinfo = cvfs_qfileinfo;
971 ops.fsinfo = cvfs_fsinfo;
973 ops.search_first = cvfs_search_first;
974 ops.search_next = cvfs_search_next;
975 ops.search_close = cvfs_search_close;
976 ops.trans = cvfs_trans;
977 ops.logoff = cvfs_logoff;
978 ops.async_setup = cvfs_async_setup;
979 ops.cancel = cvfs_cancel;
980 ops.notify = cvfs_notify;
982 if (lp_parm_bool(-1, "cifs", "maptrans2", False)) {
983 ops.trans2 = cvfs_trans2;
986 /* register ourselves with the NTVFS subsystem. We register
987 under the name 'cifs'. */
988 ret = ntvfs_register(&ops);
990 if (!NT_STATUS_IS_OK(ret)) {
991 DEBUG(0,("Failed to register CIFS backend!\n"));