2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 this implements most of the POSIX NTVFS backend
24 This is the default backend
27 #include "include/includes.h"
28 #include "vfs_posix.h"
32 connect to a share - used when a tree_connect operation comes
33 in. For a disk based backend we needs to ensure that the base
34 directory exists (tho it doesn't need to be accessible by the user,
37 static NTSTATUS pvfs_connect(struct smbsrv_request *req, const char *sharename)
39 struct smbsrv_tcon *tcon = req->tcon;
40 struct pvfs_state *pvfs;
43 DEBUG(0,("WARNING: the posix vfs handler is incomplete - you probably want \"ntvfs handler = simple\"\n"));
45 pvfs = talloc_named(tcon, sizeof(struct pvfs_state), "pvfs_connect(%s)", sharename);
47 return NT_STATUS_NO_MEMORY;
50 pvfs->base_directory = talloc_strdup(pvfs, lp_pathname(tcon->service));
52 /* the directory must exist. Note that we deliberately don't
53 check that it is readable */
54 if (stat(pvfs->base_directory, &st) != 0 || !S_ISDIR(st.st_mode)) {
55 DEBUG(0,("pvfs_connect: '%s' is not a directory, when connecting to [%s]\n",
56 pvfs->base_directory, sharename));
57 return NT_STATUS_BAD_NETWORK_NAME;
60 tcon->fs_type = talloc_strdup(tcon, "NTFS");
61 tcon->dev_type = talloc_strdup(tcon, "A:");
67 disconnect from a share
69 static NTSTATUS pvfs_disconnect(struct smbsrv_tcon *tcon)
75 delete a file - the dirtype specifies the file types to include in the search.
76 The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
78 static NTSTATUS pvfs_unlink(struct smbsrv_request *req, struct smb_unlink *unl)
80 return NT_STATUS_NOT_IMPLEMENTED;
85 ioctl interface - we don't do any
87 static NTSTATUS pvfs_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
89 return NT_STATUS_INVALID_PARAMETER;
93 check if a directory exists
95 static NTSTATUS pvfs_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp)
97 return NT_STATUS_NOT_IMPLEMENTED;
101 return info on a pathname
103 static NTSTATUS pvfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info)
105 return NT_STATUS_NOT_IMPLEMENTED;
109 query info on a open file
111 static NTSTATUS pvfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info)
113 return NT_STATUS_NOT_IMPLEMENTED;
120 static NTSTATUS pvfs_open(struct smbsrv_request *req, union smb_open *io)
122 return NT_STATUS_NOT_IMPLEMENTED;
128 static NTSTATUS pvfs_mkdir(struct smbsrv_request *req, union smb_mkdir *md)
130 return NT_STATUS_NOT_IMPLEMENTED;
136 static NTSTATUS pvfs_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd)
138 return NT_STATUS_NOT_IMPLEMENTED;
142 rename a set of files
144 static NTSTATUS pvfs_rename(struct smbsrv_request *req, union smb_rename *ren)
146 return NT_STATUS_NOT_IMPLEMENTED;
152 static NTSTATUS pvfs_copy(struct smbsrv_request *req, struct smb_copy *cp)
154 return NT_STATUS_NOT_SUPPORTED;
160 static NTSTATUS pvfs_read(struct smbsrv_request *req, union smb_read *rd)
162 return NT_STATUS_NOT_IMPLEMENTED;
168 static NTSTATUS pvfs_write(struct smbsrv_request *req, union smb_write *wr)
170 return NT_STATUS_NOT_IMPLEMENTED;
176 static NTSTATUS pvfs_seek(struct smbsrv_request *req, struct smb_seek *io)
178 return NT_STATUS_NOT_SUPPORTED;
184 static NTSTATUS pvfs_flush(struct smbsrv_request *req, struct smb_flush *io)
186 return NT_STATUS_NOT_IMPLEMENTED;
192 static NTSTATUS pvfs_close(struct smbsrv_request *req, union smb_close *io)
194 return NT_STATUS_NOT_IMPLEMENTED;
198 exit - closing files?
200 static NTSTATUS pvfs_exit(struct smbsrv_request *req)
202 return NT_STATUS_NOT_SUPPORTED;
208 static NTSTATUS pvfs_lock(struct smbsrv_request *req, union smb_lock *lck)
210 return NT_STATUS_NOT_IMPLEMENTED;
214 set info on a pathname
216 static NTSTATUS pvfs_setpathinfo(struct smbsrv_request *req, union smb_setfileinfo *st)
218 return NT_STATUS_NOT_SUPPORTED;
222 set info on a open file
224 static NTSTATUS pvfs_setfileinfo(struct smbsrv_request *req,
225 union smb_setfileinfo *info)
227 return NT_STATUS_NOT_IMPLEMENTED;
232 return filesystem space info
234 static NTSTATUS pvfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
236 return NT_STATUS_NOT_IMPLEMENTED;
240 return print queue info
242 static NTSTATUS pvfs_lpq(struct smbsrv_request *req, union smb_lpq *lpq)
244 return NT_STATUS_NOT_SUPPORTED;
248 list files in a directory matching a wildcard pattern
250 static NTSTATUS pvfs_search_first(struct smbsrv_request *req, union smb_search_first *io,
251 void *search_private,
252 BOOL (*callback)(void *, union smb_search_data *))
254 return NT_STATUS_NOT_IMPLEMENTED;
257 /* continue a search */
258 static NTSTATUS pvfs_search_next(struct smbsrv_request *req, union smb_search_next *io,
259 void *search_private,
260 BOOL (*callback)(void *, union smb_search_data *))
262 return NT_STATUS_NOT_IMPLEMENTED;
266 static NTSTATUS pvfs_search_close(struct smbsrv_request *req, union smb_search_close *io)
268 return NT_STATUS_NOT_IMPLEMENTED;
271 /* SMBtrans - not used on file shares */
272 static NTSTATUS pvfs_trans(struct smbsrv_request *req, struct smb_trans2 *trans2)
274 return NT_STATUS_ACCESS_DENIED;
278 initialialise the POSIX disk backend, registering ourselves with the ntvfs subsystem
280 NTSTATUS ntvfs_posix_init(void)
283 struct ntvfs_ops ops;
287 ops.name = "default";
288 ops.type = NTVFS_DISK;
290 /* fill in all the operations */
291 ops.connect = pvfs_connect;
292 ops.disconnect = pvfs_disconnect;
293 ops.unlink = pvfs_unlink;
294 ops.chkpath = pvfs_chkpath;
295 ops.qpathinfo = pvfs_qpathinfo;
296 ops.setpathinfo = pvfs_setpathinfo;
297 ops.open = pvfs_open;
298 ops.mkdir = pvfs_mkdir;
299 ops.rmdir = pvfs_rmdir;
300 ops.rename = pvfs_rename;
301 ops.copy = pvfs_copy;
302 ops.ioctl = pvfs_ioctl;
303 ops.read = pvfs_read;
304 ops.write = pvfs_write;
305 ops.seek = pvfs_seek;
306 ops.flush = pvfs_flush;
307 ops.close = pvfs_close;
308 ops.exit = pvfs_exit;
309 ops.lock = pvfs_lock;
310 ops.setfileinfo = pvfs_setfileinfo;
311 ops.qfileinfo = pvfs_qfileinfo;
312 ops.fsinfo = pvfs_fsinfo;
314 ops.search_first = pvfs_search_first;
315 ops.search_next = pvfs_search_next;
316 ops.search_close = pvfs_search_close;
317 ops.trans = pvfs_trans;
319 /* register ourselves with the NTVFS subsystem. We register
320 under the name 'default' as we wish to be the default
321 backend, and also register as 'posix' */
323 ret = register_backend("ntvfs", &ops);
325 ret = register_backend("ntvfs", &ops);
327 if (!NT_STATUS_IS_OK(ret)) {
328 DEBUG(0,("Failed to register POSIX backend!\n"));