r4242: added support for storing xattrs in a tdb. This allows all advanced NT
[kamenim/samba.git] / source4 / ntvfs / posix / vfs_posix.c
index 5e7a605c9fa81071d197d1a2d48e9ce029fdbe28..6f4de1e0388b4439ec199bb5ef0213d8531cf86c 100644 (file)
@@ -24,7 +24,7 @@
   This is the default backend
 */
 
-#include "include/includes.h"
+#include "includes.h"
 #include "vfs_posix.h"
 
 
@@ -34,6 +34,8 @@
 static void pvfs_setup_options(struct pvfs_state *pvfs)
 {
        int snum = pvfs->tcon->service;
+       int delay;
+       const char *eadb;
 
        if (lp_map_hidden(snum))     pvfs->flags |= PVFS_FLAG_MAP_HIDDEN;
        if (lp_map_archive(snum))    pvfs->flags |= PVFS_FLAG_MAP_ARCHIVE;
@@ -41,8 +43,51 @@ static void pvfs_setup_options(struct pvfs_state *pvfs)
        if (lp_readonly(snum))       pvfs->flags |= PVFS_FLAG_READONLY;
        if (lp_strict_sync(snum))    pvfs->flags |= PVFS_FLAG_STRICT_SYNC;
        if (lp_strict_locking(snum)) pvfs->flags |= PVFS_FLAG_STRICT_LOCKING;
+       if (lp_ci_filesystem(snum))  pvfs->flags |= PVFS_FLAG_CI_FILESYSTEM;
+
+       if (lp_parm_bool(snum, "posix", "fakeoplocks", False)) {
+               pvfs->flags |= PVFS_FLAG_FAKE_OPLOCKS;
+       }
+
+#if HAVE_XATTR_SUPPORT
+       if (lp_parm_bool(snum, "posix", "xattr", True)) pvfs->flags |= PVFS_FLAG_XATTR_ENABLE;
+#endif
+
+       pvfs->sharing_violation_delay = 1000000;
+       delay = lp_parm_int(snum, "posix", "sharedelay");
+       if (delay != -1) {
+               pvfs->sharing_violation_delay = delay;
+       }
 
        pvfs->share_name = talloc_strdup(pvfs, lp_servicename(snum));
+
+       pvfs->fs_attribs = 
+               FS_ATTR_CASE_SENSITIVE_SEARCH | 
+               FS_ATTR_CASE_PRESERVED_NAMES |
+               FS_ATTR_UNICODE_ON_DISK |
+               FS_ATTR_SPARSE_FILES;
+
+       /* allow xattrs to be stored in a external tdb */
+       eadb = lp_parm_string(snum, "posix", "eadb");
+       if (eadb != NULL) {
+               pvfs->ea_db = tdb_wrap_open(pvfs, eadb, 50000,  
+                                           TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+               if (pvfs->ea_db != NULL) {
+                       pvfs->flags |= PVFS_FLAG_XATTR_ENABLE;
+               } else {
+                       DEBUG(0,("Failed to open eadb '%s' - %s\n",
+                                eadb, strerror(errno)));
+                       pvfs->flags &= ~PVFS_FLAG_XATTR_ENABLE;
+               }
+       }
+
+
+       if (pvfs->flags & PVFS_FLAG_XATTR_ENABLE) {
+               pvfs->fs_attribs |= FS_ATTR_NAMED_STREAMS;
+       }
+       if (pvfs->flags & PVFS_FLAG_XATTR_ENABLE) {
+               pvfs->fs_attribs |= FS_ATTR_PERSISTANT_ACLS;
+       }
 }
 
 
@@ -61,11 +106,10 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
        char *base_directory;
        NTSTATUS status;
 
-       pvfs = talloc_p(tcon, struct pvfs_state);
+       pvfs = talloc_zero_p(tcon, struct pvfs_state);
        if (pvfs == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
-       ZERO_STRUCTP(pvfs);
 
        /* for simplicity of path construction, remove any trailing slash now */
        base_directory = talloc_strdup(pvfs, lp_pathname(tcon->service));
@@ -89,11 +133,36 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
 
        pvfs->brl_context = brl_init(pvfs, 
                                     pvfs->tcon->smb_conn->connection->server_id,  
-                                    pvfs->tcon->service);
+                                    pvfs->tcon->service,
+                                    pvfs->tcon->smb_conn->connection->messaging_ctx);
        if (pvfs->brl_context == NULL) {
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
+       pvfs->odb_context = odb_init(pvfs, 
+                                    pvfs->tcon->smb_conn->connection->server_id,  
+                                    pvfs->tcon->smb_conn->connection->messaging_ctx);
+       if (pvfs->odb_context == NULL) {
+               return NT_STATUS_INTERNAL_DB_CORRUPTION;
+       }
+
+       pvfs->sidmap = sidmap_open(pvfs);
+       if (pvfs->sidmap == NULL) {
+               return NT_STATUS_INTERNAL_DB_CORRUPTION;
+       }
+
+       /* allocate the fnum id -> ptr tree */
+       pvfs->idtree_fnum = idr_init(pvfs);
+       if (pvfs->idtree_fnum == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       /* allocate the search handle -> ptr tree */
+       pvfs->idtree_search = idr_init(pvfs);
+       if (pvfs->idtree_search == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
        status = pvfs_mangle_init(pvfs);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -101,6 +170,12 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
 
        pvfs_setup_options(pvfs);
 
+#ifdef SIGXFSZ
+       /* who had the stupid idea to generate a signal on a large
+          file write instead of just failing it!? */
+       BlockSignals(True, SIGXFSZ);
+#endif
+
        return NT_STATUS_OK;
 }
 
@@ -113,15 +188,6 @@ static NTSTATUS pvfs_disconnect(struct ntvfs_module_context *ntvfs,
        return NT_STATUS_OK;
 }
 
-/*
-  ioctl interface - we don't do any
-*/
-static NTSTATUS pvfs_ioctl(struct ntvfs_module_context *ntvfs,
-                          struct smbsrv_request *req, union smb_ioctl *io)
-{
-       return NT_STATUS_INVALID_PARAMETER;
-}
-
 /*
   check if a directory exists
 */
@@ -159,26 +225,6 @@ static NTSTATUS pvfs_copy(struct ntvfs_module_context *ntvfs,
        return NT_STATUS_NOT_SUPPORTED;
 }
 
-/*
-  seek in a file
-*/
-static NTSTATUS pvfs_seek(struct ntvfs_module_context *ntvfs,
-                         struct smbsrv_request *req, struct smb_seek *io)
-{
-       DEBUG(0,("pvfs_seek not implemented\n"));
-       return NT_STATUS_NOT_SUPPORTED;
-}
-
-/*
-  set info on a pathname
-*/
-static NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
-                                struct smbsrv_request *req, union smb_setfileinfo *st)
-{
-       DEBUG(0,("pvfs_setpathinfo not implemented\n"));
-       return NT_STATUS_NOT_SUPPORTED;
-}
-
 /*
   return print queue info
 */
@@ -214,7 +260,7 @@ NTSTATUS ntvfs_posix_init(void)
        ops.chkpath = pvfs_chkpath;
        ops.qpathinfo = pvfs_qpathinfo;
        ops.setpathinfo = pvfs_setpathinfo;
-       ops.open = pvfs_open;
+       ops.openfile = pvfs_open;
        ops.mkdir = pvfs_mkdir;
        ops.rmdir = pvfs_rmdir;
        ops.rename = pvfs_rename;
@@ -236,15 +282,17 @@ NTSTATUS ntvfs_posix_init(void)
        ops.search_close = pvfs_search_close;
        ops.trans = pvfs_trans;
        ops.logoff = pvfs_logoff;
+       ops.async_setup = pvfs_async_setup;
+       ops.cancel = pvfs_cancel;
 
        /* register ourselves with the NTVFS subsystem. We register
           under the name 'default' as we wish to be the default
           backend, and also register as 'posix' */
        ops.name = "default";
-       ret = register_backend("ntvfs", &ops);
+       ret = ntvfs_register(&ops);
 
        ops.name = "posix";
-       ret = register_backend("ntvfs", &ops);
+       ret = ntvfs_register(&ops);
 
        if (!NT_STATUS_IS_OK(ret)) {
                DEBUG(0,("Failed to register POSIX backend!\n"));