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 initialialise the POSIX disk backend, registering ourselves with the ntvfs subsystem
77 NTSTATUS ntvfs_posix_init(void)
85 ops.type = NTVFS_DISK;
87 /* fill in all the operations */
88 ops.connect = pvfs_connect;
89 ops.disconnect = pvfs_disconnect;
91 /* register ourselves with the NTVFS subsystem. We register under the name 'default'
92 as we wish to be the default backend */
93 ret = register_backend("ntvfs", &ops);
95 if (!NT_STATUS_IS_OK(ret)) {
96 DEBUG(0,("Failed to register POSIX backend!\n"));