s3: Prepare open.c to switch fsp_name to an smb_filename struct
authorTim Prouty <tprouty@samba.org>
Wed, 8 Jul 2009 23:53:01 +0000 (16:53 -0700)
committerTim Prouty <tprouty@samba.org>
Thu, 9 Jul 2009 04:36:04 +0000 (21:36 -0700)
source3/modules/onefs_open.c
source3/smbd/open.c

index 52324f81815240b4762d7db84e2709823291278d..b51d516956c9791da6f9a3ae27aba6bee79db501 100644 (file)
@@ -93,12 +93,6 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
        fsp->fh->fd = -1;
        errno = EPERM;
 
-       status = get_full_smb_filename(talloc_tos(), smb_fname,
-                                      &path);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
        /* Check permissions */
 
        /*
@@ -165,7 +159,7 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
                 */
                wild = fsp->base_fsp->fsp_name;
        } else {
-               wild = path;
+               wild = smb_fname->base_name;
        }
        if ((local_flags & O_CREAT) && !file_existed &&
            ms_has_wild(wild))  {
@@ -257,8 +251,8 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
 
                /* Inherit the ACL if required */
                if (lp_inherit_perms(SNUM(conn))) {
-                       inherit_access_posix_acl(conn, parent_dir, path,
-                           unx_mode);
+                       inherit_access_posix_acl(conn, parent_dir,
+                           smb_fname->base_name, unx_mode);
                }
 
                /* Change the owner if required. */
@@ -268,7 +262,7 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
                }
 
                notify_fname(conn, NOTIFY_ACTION_ADDED,
-                   FILE_NOTIFY_CHANGE_FILE_NAME, path);
+                   FILE_NOTIFY_CHANGE_FILE_NAME, smb_fname->base_name);
        }
 
        if (!file_existed) {
@@ -324,16 +318,25 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->is_directory = False;
        if (conn->aio_write_behind_list &&
-           is_in_path(path, conn->aio_write_behind_list, conn->case_sensitive)) {
+           is_in_path(smb_fname->base_name, conn->aio_write_behind_list,
+                      conn->case_sensitive)) {
                fsp->aio_write_behind = True;
        }
 
+       status = get_full_smb_filename(talloc_tos(), smb_fname,
+                                      &path);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
        string_set(&fsp->fsp_name, path);
+       TALLOC_FREE(path);
+
        fsp->wcp = NULL; /* Write cache pointer. */
 
        DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d)\n",
                 conn->server_info->unix_name,
-                fsp->fsp_name,
+                smb_fname_str_dbg(smb_fname),
                 BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write),
                 conn->num_files_open));
 
index 3e7b9d2657f592d475d1e6ba6589adac5498db7f..e01350f2bf32a8da6956afd55159f0b013eeb86f 100644 (file)
@@ -358,12 +358,6 @@ static NTSTATUS open_file(files_struct *fsp,
        fsp->fh->fd = -1;
        errno = EPERM;
 
-       status = get_full_smb_filename(talloc_tos(), smb_fname,
-                                      &path);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
        /* Check permissions */
 
        /*
@@ -442,7 +436,7 @@ static NTSTATUS open_file(files_struct *fsp,
                         */
                        wild = fsp->base_fsp->fsp_name;
                } else {
-                       wild = path;
+                       wild = smb_fname->base_name;
                }
                if ((local_flags & O_CREAT) && !file_existed &&
                    ms_has_wild(wild))  {
@@ -462,8 +456,9 @@ static NTSTATUS open_file(files_struct *fsp,
 
                        /* Inherit the ACL if required */
                        if (lp_inherit_perms(SNUM(conn))) {
-                               inherit_access_posix_acl(conn, parent_dir, path,
-                                                  unx_mode);
+                               inherit_access_posix_acl(conn, parent_dir,
+                                                        smb_fname->base_name,
+                                                        unx_mode);
                        }
 
                        /* Change the owner if required. */
@@ -473,7 +468,8 @@ static NTSTATUS open_file(files_struct *fsp,
                        }
 
                        notify_fname(conn, NOTIFY_ACTION_ADDED,
-                                    FILE_NOTIFY_CHANGE_FILE_NAME, path);
+                                    FILE_NOTIFY_CHANGE_FILE_NAME,
+                                    smb_fname->base_name);
                }
 
        } else {
@@ -619,12 +615,20 @@ static NTSTATUS open_file(files_struct *fsp,
                fsp->aio_write_behind = True;
        }
 
+       status = get_full_smb_filename(talloc_tos(), smb_fname,
+                                      &path);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
        string_set(&fsp->fsp_name, path);
+       TALLOC_FREE(path);
+
        fsp->wcp = NULL; /* Write cache pointer. */
 
        DEBUG(2,("%s opened file %s read=%s write=%s (numopen=%d)\n",
                 conn->server_info->unix_name,
-                fsp->fsp_name,
+                smb_fname_str_dbg(smb_fname),
                 BOOLSTR(fsp->can_read), BOOLSTR(fsp->can_write),
                 conn->num_files_open));