s3: Modify direct callers of open_file_ntcreate and open_directory to call SMB_VFS_CR...
authorTim Prouty <tprouty@samba.org>
Fri, 21 Nov 2008 02:55:24 +0000 (18:55 -0800)
committerTim Prouty <tprouty@samba.org>
Thu, 4 Dec 2008 01:51:16 +0000 (17:51 -0800)
source3/printing/nt_printing.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/posix_acls.c
source3/smbd/reply.c
source3/smbd/trans2.c

index 244b3aee03e9f34cfc2e8283539d1b8cc8c1ef1d..0c54c6452abc3d24f289482ae41f96dec1bb9c8d 100644 (file)
@@ -1344,14 +1344,24 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
                goto error_exit;
        }
 
                goto error_exit;
        }
 
-       status = open_file_ntcreate(conn, NULL, filepath, &stat_buf,
-                               FILE_GENERIC_READ,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE,
-                               FILE_OPEN,
-                               0,
-                               FILE_ATTRIBUTE_NORMAL,
-                               INTERNAL_OPEN_ONLY,
-                               NULL, &fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               NULL,                                   /* req */
+               0,                                      /* root_dir_fid */
+               filepath,                               /* fname */
+               false,                                  /* is_dos_path */
+               FILE_GENERIC_READ,                      /* access_mask */
+               FILE_SHARE_READ | FILE_SHARE_WRITE,     /* share_access */
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               NULL,                                   /* pinfo */
+               &stat_buf);                             /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* Old file not found, so by definition new file is in fact newer */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* Old file not found, so by definition new file is in fact newer */
@@ -1385,14 +1395,24 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
                goto error_exit;
        }
 
                goto error_exit;
        }
 
-       status = open_file_ntcreate(conn, NULL, filepath, &stat_buf,
-                               FILE_GENERIC_READ,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE,
-                               FILE_OPEN,
-                               0,
-                               FILE_ATTRIBUTE_NORMAL,
-                               INTERNAL_OPEN_ONLY,
-                               NULL, &fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               NULL,                                   /* req */
+               0,                                      /* root_dir_fid */
+               filepath,                               /* fname */
+               false,                                  /* is_dos_path */
+               FILE_GENERIC_READ,                      /* access_mask */
+               FILE_SHARE_READ | FILE_SHARE_WRITE,     /* share_access */
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               NULL,                                   /* pinfo */
+               &stat_buf);                             /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* New file not found, this shouldn't occur if the caller did its job */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* New file not found, this shouldn't occur if the caller did its job */
@@ -1528,14 +1548,24 @@ static uint32 get_correct_cversion(struct pipes_struct *p,
                goto error_exit;
        }
 
                goto error_exit;
        }
 
-       status = open_file_ntcreate(conn, NULL, driverpath, &st,
-                               FILE_GENERIC_READ,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE,
-                               FILE_OPEN,
-                               0,
-                               FILE_ATTRIBUTE_NORMAL,
-                               INTERNAL_OPEN_ONLY,
-                               NULL, &fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               NULL,                                   /* req */
+               0,                                      /* root_dir_fid */
+               driverpath,                             /* fname */
+               false,                                  /* is_dos_path */
+               FILE_GENERIC_READ,                      /* access_mask */
+               FILE_SHARE_READ | FILE_SHARE_WRITE,     /* share_access */
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               NULL,                                   /* pinfo */
+               &st);                                   /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(3,("get_correct_cversion: Can't open file [%s], errno = %d\n",
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(3,("get_correct_cversion: Can't open file [%s], errno = %d\n",
index b66aba5aac444f1232ebe72988cab8e4a422861e..a7b2cb6c3123adfc2eaa350cd21b47f05da8ab80 100644 (file)
@@ -1186,27 +1186,49 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
        DEBUG(10,("copy_internals: doing file copy %s to %s\n",
                                oldname, newname));
 
        DEBUG(10,("copy_internals: doing file copy %s to %s\n",
                                oldname, newname));
 
-        status = open_file_ntcreate(conn, req, oldname, &sbuf1,
-                       FILE_READ_DATA, /* Read-only. */
-                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                       FILE_OPEN,
-                       0, /* No create options. */
-                       FILE_ATTRIBUTE_NORMAL,
-                       NO_OPLOCK,
-                       &info, &fsp1);
+        status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               oldname,                                /* fname */
+               false,                                  /* is_dos_path */
+               FILE_READ_DATA,                         /* access_mask */
+               (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
+                   FILE_SHARE_DELETE),
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               NO_OPLOCK,                              /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp1,                                  /* result */
+               &info,                                  /* pinfo */
+               &sbuf1);                                /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
 
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
 
-        status = open_file_ntcreate(conn, req, newname, &sbuf2,
-                       FILE_WRITE_DATA, /* Read-only. */
-                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                       FILE_CREATE,
-                       0, /* No create options. */
-                       fattr,
-                       NO_OPLOCK,
-                       &info, &fsp2);
+        status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               newname,                                /* fname */
+               false,                                  /* is_dos_path */
+               FILE_WRITE_DATA,                        /* access_mask */
+               (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
+                   FILE_SHARE_DELETE),
+               FILE_CREATE,                            /* create_disposition*/
+               0,                                      /* create_options */
+               fattr,                                  /* file_attributes */
+               NO_OPLOCK,                              /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp2,                                  /* result */
+               &info,                                  /* pinfo */
+               &sbuf2);                                /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                close_file(NULL, fsp1, ERROR_CLOSE);
 
        if (!NT_STATUS_IS_OK(status)) {
                close_file(NULL, fsp1, ERROR_CLOSE);
index 989024f553d100b8fa62411f451a24a5e7bbcca6..62d4827bb25576130fda4caf2d8d2141753585b9 100644 (file)
@@ -2493,14 +2493,24 @@ NTSTATUS create_directory(connection_struct *conn, struct smb_request *req, cons
 
        SET_STAT_INVALID(sbuf);
        
 
        SET_STAT_INVALID(sbuf);
        
-       status = open_directory(conn, req, directory, &sbuf,
-                               FILE_READ_ATTRIBUTES, /* Just a stat open */
-                               FILE_SHARE_NONE, /* Ignored for stat opens */
-                               FILE_CREATE,
-                               0,
-                               FILE_ATTRIBUTE_DIRECTORY,
-                               NULL,
-                               &fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               directory,                              /* fname */
+               false,                                  /* is_dos_path */
+               FILE_READ_ATTRIBUTES,                   /* access_mask */
+               FILE_SHARE_NONE,                        /* share_access */
+               FILE_CREATE,                            /* create_disposition*/
+               FILE_DIRECTORY_FILE,                    /* create_options */
+               FILE_ATTRIBUTE_DIRECTORY,               /* file_attributes */
+               0,                                      /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               NULL,                                   /* pinfo */
+               &sbuf);                                 /* psbuf */
 
        if (NT_STATUS_IS_OK(status)) {
                close_file(req, fsp, NORMAL_CLOSE);
 
        if (NT_STATUS_IS_OK(status)) {
                close_file(req, fsp, NORMAL_CLOSE);
index 97fd3b2bbe9aa26f374c0ec5a41945dab5fcf017..78a5d548c26159ad061656596cb8dd92fbcd2cdb 100644 (file)
@@ -3248,17 +3248,24 @@ NTSTATUS append_parent_acl(files_struct *fsp,
                return NT_STATUS_NO_MEMORY;
        }
 
                return NT_STATUS_NO_MEMORY;
        }
 
-       status = open_directory(fsp->conn,
-                               NULL,
-                               parent_name,
-                               &sbuf,
-                               FILE_READ_ATTRIBUTES, /* Just a stat open */
-                               FILE_SHARE_NONE, /* Ignored for stat opens */
-                               FILE_OPEN,
-                               0,
-                               INTERNAL_OPEN_ONLY,
-                               &info,
-                               &parent_fsp);
+       status = SMB_VFS_CREATE_FILE(
+               fsp->conn,                              /* conn */
+               NULL,                                   /* req */
+               0,                                      /* root_dir_fid */
+               parent_name,                            /* fname */
+               false,                                  /* is_dos_path */
+               FILE_READ_ATTRIBUTES,                   /* access_mask */
+               FILE_SHARE_NONE,                        /* share_access */
+               FILE_OPEN,                              /* create_disposition*/
+               FILE_DIRECTORY_FILE,                    /* create_options */
+               0,                                      /* file_attributes */
+               INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &parent_fsp,                            /* result */
+               &info,                                  /* pinfo */
+               &sbuf);                                 /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
index 2465e73a18c8c934337285b8b00cd7fb70f8e253..728753bc3b72d9f629077c9740541936c87875e1 100644 (file)
@@ -2123,14 +2123,24 @@ void reply_ctemp(struct smb_request *req)
        SMB_VFS_STAT(conn,fname,&sbuf);
 
        /* We should fail if file does not exist. */
        SMB_VFS_STAT(conn,fname,&sbuf);
 
        /* We should fail if file does not exist. */
-       status = open_file_ntcreate(conn, req, fname, &sbuf,
-                               FILE_GENERIC_READ | FILE_GENERIC_WRITE,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE,
-                               FILE_OPEN,
-                               0,
-                               fattr,
-                               oplock_request,
-                               NULL, &fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               fname,                                  /* fname */
+               false,                                  /* is_dos_path */
+               FILE_GENERIC_READ | FILE_GENERIC_WRITE, /* access_mask */
+               FILE_SHARE_READ | FILE_SHARE_WRITE,     /* share_access */
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               fattr,                                  /* file_attributes */
+               oplock_request,                         /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               NULL,                                   /* pinfo */
+               &sbuf);                                 /* psbuf */
 
        /* close fd from smb_mkstemp() */
        close(tmpfd);
 
        /* close fd from smb_mkstemp() */
        close(tmpfd);
@@ -5631,6 +5641,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
        struct smb_Dir *dir_hnd = NULL;
        const char *dname;
        long offset = 0;
        struct smb_Dir *dir_hnd = NULL;
        const char *dname;
        long offset = 0;
+       int create_options = 0;
 
        ZERO_STRUCT(sbuf1);
        ZERO_STRUCT(sbuf2);
 
        ZERO_STRUCT(sbuf1);
        ZERO_STRUCT(sbuf2);
@@ -5744,17 +5755,29 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                ZERO_STRUCT(sbuf1);
                SMB_VFS_STAT(conn, directory, &sbuf1);
 
                ZERO_STRUCT(sbuf1);
                SMB_VFS_STAT(conn, directory, &sbuf1);
 
-               status = S_ISDIR(sbuf1.st_mode) ?
-                       open_directory(conn, req, directory, &sbuf1,
-                                      access_mask,
-                                      FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                      FILE_OPEN, 0, 0, NULL,
-                                      &fsp)
-                       : open_file_ntcreate(conn, req, directory, &sbuf1,
-                                            access_mask,
-                                            FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                            FILE_OPEN, 0, 0, 0, NULL,
-                                            &fsp);
+               if (S_ISDIR(sbuf1.st_mode)) {
+                       create_options |= FILE_DIRECTORY_FILE;
+               }
+
+               status = SMB_VFS_CREATE_FILE(
+                       conn,                           /* conn */
+                       req,                            /* req */
+                       0,                              /* root_dir_fid */
+                       directory,                      /* fname */
+                       false,                          /* is_dos_path */
+                       access_mask,                    /* access_mask */
+                       (FILE_SHARE_READ |              /* share_access */
+                           FILE_SHARE_WRITE),
+                       FILE_OPEN,                      /* create_disposition*/
+                       create_options,                 /* create_options */
+                       0,                              /* file_attributes */
+                       0,                              /* oplock_request */
+                       0,                              /* allocation_size */
+                       NULL,                           /* sd */
+                       NULL,                           /* ea_list */
+                       &fsp,                           /* result */
+                       NULL,                           /* pinfo */
+                       &sbuf1);                        /* psbuf */
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(3, ("Could not open rename source %s: %s\n",
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(3, ("Could not open rename source %s: %s\n",
@@ -5848,20 +5871,34 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                ZERO_STRUCT(sbuf1);
                SMB_VFS_STAT(conn, fname, &sbuf1);
 
                ZERO_STRUCT(sbuf1);
                SMB_VFS_STAT(conn, fname, &sbuf1);
 
-               status = S_ISDIR(sbuf1.st_mode) ?
-                       open_directory(conn, req, fname, &sbuf1,
-                                      access_mask,
-                                      FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                      FILE_OPEN, 0, 0, NULL,
-                                      &fsp)
-                       : open_file_ntcreate(conn, req, fname, &sbuf1,
-                                            access_mask,
-                                            FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                            FILE_OPEN, 0, 0, 0, NULL,
-                                            &fsp);
+               create_options = 0;
+
+               if (S_ISDIR(sbuf1.st_mode)) {
+                       create_options |= FILE_DIRECTORY_FILE;
+               }
+
+               status = SMB_VFS_CREATE_FILE(
+                       conn,                           /* conn */
+                       req,                            /* req */
+                       0,                              /* root_dir_fid */
+                       fname,                          /* fname */
+                       false,                          /* is_dos_path */
+                       access_mask,                    /* access_mask */
+                       (FILE_SHARE_READ |              /* share_access */
+                           FILE_SHARE_WRITE),
+                       FILE_OPEN,                      /* create_disposition*/
+                       create_options,                 /* create_options */
+                       0,                              /* file_attributes */
+                       0,                              /* oplock_request */
+                       0,                              /* allocation_size */
+                       NULL,                           /* sd */
+                       NULL,                           /* ea_list */
+                       &fsp,                           /* result */
+                       NULL,                           /* pinfo */
+                       &sbuf1);                        /* psbuf */
 
                if (!NT_STATUS_IS_OK(status)) {
 
                if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(3,("rename_internals: open_file_ntcreate "
+                       DEBUG(3,("rename_internals: SMB_VFS_CREATE_FILE "
                                 "returned %s rename %s -> %s\n",
                                 nt_errstr(status), directory, newname));
                        break;
                                 "returned %s rename %s -> %s\n",
                                 nt_errstr(status), directory, newname));
                        break;
@@ -6052,14 +6089,24 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                }
        }
 
                }
        }
 
-       status = open_file_ntcreate(conn, NULL, src, &src_sbuf,
-                       FILE_GENERIC_READ,
-                       FILE_SHARE_READ|FILE_SHARE_WRITE,
-                       FILE_OPEN,
-                       0,
-                       FILE_ATTRIBUTE_NORMAL,
-                       INTERNAL_OPEN_ONLY,
-                       NULL, &fsp1);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               NULL,                                   /* req */
+               0,                                      /* root_dir_fid */
+               src,                                    /* fname */
+               false,                                  /* is_dos_path */
+               FILE_GENERIC_READ,                      /* access_mask */
+               FILE_SHARE_READ | FILE_SHARE_WRITE,     /* share_access */
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp1,                                  /* result */
+               NULL,                                   /* pinfo */
+               &src_sbuf);                             /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(dest);
 
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(dest);
@@ -6071,14 +6118,24 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                ZERO_STRUCTP(&sbuf2);
        }
 
                ZERO_STRUCTP(&sbuf2);
        }
 
-       status = open_file_ntcreate(conn, NULL, dest, &sbuf2,
-                       FILE_GENERIC_WRITE,
-                       FILE_SHARE_READ|FILE_SHARE_WRITE,
-                       new_create_disposition,
-                       0,
-                       dosattrs,
-                       INTERNAL_OPEN_ONLY,
-                       NULL, &fsp2);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               NULL,                                   /* req */
+               0,                                      /* root_dir_fid */
+               dest,                                   /* fname */
+               false,                                  /* is_dos_path */
+               FILE_GENERIC_WRITE,                     /* access_mask */
+               FILE_SHARE_READ | FILE_SHARE_WRITE,     /* share_access */
+               new_create_disposition,                 /* create_disposition*/
+               0,                                      /* create_options */
+               dosattrs,                               /* file_attributes */
+               INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp2,                                  /* result */
+               NULL,                                   /* pinfo */
+               &sbuf2);                                /* psbuf */
 
        TALLOC_FREE(dest);
 
 
        TALLOC_FREE(dest);
 
index 9ba6d198c4cd8f96ecde0f7856442ade1bb25c1f..b9a04e9b4f66c1f301ccc26f3bfaa33c81614864 100644 (file)
@@ -5059,15 +5059,26 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                return NT_STATUS_OK;
        }
 
                return NT_STATUS_OK;
        }
 
-       status = open_file_ntcreate(conn, req, fname, psbuf,
-                               FILE_WRITE_ATTRIBUTES,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                               FILE_OPEN,
-                               0,
-                               FILE_ATTRIBUTE_NORMAL,
-                               FORCE_OPLOCK_BREAK_TO_NONE,
-                               NULL, &new_fsp);
-       
+        status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               fname,                                  /* fname */
+               false,                                  /* is_dos_path */
+               FILE_WRITE_ATTRIBUTES,                  /* access_mask */
+               (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
+                   FILE_SHARE_DELETE),
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               FORCE_OPLOCK_BREAK_TO_NONE,             /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &new_fsp,                               /* result */
+               NULL,                                   /* pinfo */
+               psbuf);                                 /* psbuf */
+
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
                return status;
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
                return status;
@@ -5828,14 +5839,25 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
 
        /* Pathname or stat or directory file. */
 
 
        /* Pathname or stat or directory file. */
 
-       status = open_file_ntcreate(conn, req, fname, psbuf,
-                               FILE_WRITE_DATA,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                               FILE_OPEN,
-                               0,
-                               FILE_ATTRIBUTE_NORMAL,
-                               FORCE_OPLOCK_BREAK_TO_NONE,
-                               NULL, &new_fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               fname,                                  /* fname */
+               false,                                  /* is_dos_path */
+               FILE_WRITE_DATA,                        /* access_mask */
+               (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
+                   FILE_SHARE_DELETE),
+               FILE_OPEN,                              /* create_disposition*/
+               0,                                      /* create_options */
+               FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
+               FORCE_OPLOCK_BREAK_TO_NONE,             /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &new_fsp,                               /* result */
+               NULL,                                   /* pinfo */
+               psbuf);                                 /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
@@ -6259,16 +6281,24 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
        DEBUG(10,("smb_posix_mkdir: file %s, mode 0%o\n",
                fname, (unsigned int)unixmode ));
 
        DEBUG(10,("smb_posix_mkdir: file %s, mode 0%o\n",
                fname, (unsigned int)unixmode ));
 
-       status = open_directory(conn, req,
-                               fname,
-                               psbuf,
-                               FILE_READ_ATTRIBUTES, /* Just a stat open */
-                               FILE_SHARE_NONE, /* Ignored for stat opens */
-                               FILE_CREATE,
-                               0,
-                               mod_unixmode,
-                               &info,
-                               &fsp);
+       status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               fname,                                  /* fname */
+               false,                                  /* is_dos_path */
+               FILE_READ_ATTRIBUTES,                   /* access_mask */
+               FILE_SHARE_NONE,                        /* share_access */
+               FILE_CREATE,                            /* create_disposition*/
+               FILE_DIRECTORY_FILE,                    /* create_options */
+               mod_unixmode,                           /* file_attributes */
+               0,                                      /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               &info,                                  /* pinfo */
+               psbuf);                                 /* psbuf */
 
         if (NT_STATUS_IS_OK(status)) {
                 close_file(req, fsp, NORMAL_CLOSE);
 
         if (NT_STATUS_IS_OK(status)) {
                 close_file(req, fsp, NORMAL_CLOSE);
@@ -6425,17 +6455,25 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                (unsigned int)wire_open_mode,
                (unsigned int)unixmode ));
 
                (unsigned int)wire_open_mode,
                (unsigned int)unixmode ));
 
-       status = open_file_ntcreate(conn, req,
-                               fname,
-                               psbuf,
-                               access_mask,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                               create_disp,
-                               0,              /* no create options yet. */
-                               mod_unixmode,
-                               oplock_request,
-                               &info,
-                               &fsp);
+        status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               fname,                                  /* fname */
+               false,                                  /* is_dos_path */
+               access_mask,                            /* access_mask */
+               (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
+                   FILE_SHARE_DELETE),
+               create_disp,                            /* create_disposition*/
+               0,                                      /* create_options */
+               mod_unixmode,                           /* file_attributes */
+               oplock_request,                         /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               &info,                                  /* pinfo */
+               psbuf);                                 /* psbuf */
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -6520,6 +6558,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
        uint16 flags = 0;
        char del = 1;
        int info = 0;
        uint16 flags = 0;
        char del = 1;
        int info = 0;
+       int create_options = 0;
        int i;
        struct share_mode_lock *lck = NULL;
 
        int i;
        struct share_mode_lock *lck = NULL;
 
@@ -6543,31 +6582,29 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                fname));
 
        if (VALID_STAT_OF_DIR(*psbuf)) {
                fname));
 
        if (VALID_STAT_OF_DIR(*psbuf)) {
-               status = open_directory(conn, req,
-                                       fname,
-                                       psbuf,
-                                       DELETE_ACCESS,
-                                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                                       FILE_OPEN,
-                                       0,
-                                       FILE_FLAG_POSIX_SEMANTICS|0777,
-                                       &info,
-                                       &fsp);
-       } else {
-
-               status = open_file_ntcreate(conn, req,
-                               fname,
-                               psbuf,
-                               DELETE_ACCESS,
-                               FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-                               FILE_OPEN,
-                               0,
-                               FILE_FLAG_POSIX_SEMANTICS|0777,
-                               0, /* No oplock, but break existing ones. */
-                               &info,
-                               &fsp);
+               create_options |= FILE_DIRECTORY_FILE;
        }
 
        }
 
+        status = SMB_VFS_CREATE_FILE(
+               conn,                                   /* conn */
+               req,                                    /* req */
+               0,                                      /* root_dir_fid */
+               fname,                                  /* fname */
+               false,                                  /* is_dos_path */
+               DELETE_ACCESS,                          /* access_mask */
+               (FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
+                   FILE_SHARE_DELETE),
+               FILE_OPEN,                              /* create_disposition*/
+               create_options,                         /* create_options */
+               FILE_FLAG_POSIX_SEMANTICS|0777,         /* file_attributes */
+               0,                                      /* oplock_request */
+               0,                                      /* allocation_size */
+               NULL,                                   /* sd */
+               NULL,                                   /* ea_list */
+               &fsp,                                   /* result */
+               &info,                                  /* pinfo */
+               psbuf);                                 /* psbuf */
+
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }