s3: Convert some callers of vfs_stat_smb_fname to SMB_VFS_STAT()
authorTim Prouty <tprouty@samba.org>
Tue, 21 Jul 2009 20:57:56 +0000 (13:57 -0700)
committerTim Prouty <tprouty@samba.org>
Wed, 22 Jul 2009 16:51:17 +0000 (09:51 -0700)
source3/smbd/globals.h
source3/smbd/posix_acls.c
source3/smbd/smb2_getinfo.c
source3/smbd/trans2.c

index cd3e054d1a89e59e3a17f12f14e7a833622e2fdc..434204b60de706d68f1af69e0900b1fe8e22ef12 100644 (file)
@@ -213,7 +213,6 @@ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn,
 NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
                         TALLOC_CTX *mem_ctx,
                         uint16_t info_level,
-                        SMB_STRUCT_STAT st,
                         uint16_t flags2,
                         unsigned int max_data_bytes,
                         char **ppdata,
index fb2cda40ce0019e68aa2103df802ececf47aa426..0a3b0dff7597a22d9da813465e9113262881252a 100644 (file)
@@ -3372,33 +3372,45 @@ NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
 NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
                          uint32_t security_info, SEC_DESC **ppdesc)
 {
-       SMB_STRUCT_STAT sbuf;
        SMB_ACL_T posix_acl = NULL;
        SMB_ACL_T def_acl = NULL;
        struct pai_val *pal;
+       struct smb_filename *smb_fname = NULL;
+       NTSTATUS status;
 
        *ppdesc = NULL;
 
        DEBUG(10,("posix_get_nt_acl: called for file %s\n", name ));
 
+       status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL,
+                                           &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
        /* Get the stat struct for the owner info. */
-       if(vfs_stat_smb_fname(conn, name, &sbuf) != 0) {
-               return map_nt_error_from_unix(errno);
+       if(SMB_VFS_STAT(conn, smb_fname) != 0) {
+               status = map_nt_error_from_unix(errno);
+               goto out;
        }
 
        /* Get the ACL from the path. */
        posix_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name, SMB_ACL_TYPE_ACCESS);
 
        /* If it's a directory get the default POSIX ACL. */
-       if(S_ISDIR(sbuf.st_ex_mode)) {
+       if(S_ISDIR(smb_fname->st.st_ex_mode)) {
                def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name, SMB_ACL_TYPE_DEFAULT);
                def_acl = free_empty_sys_acl(conn, def_acl);
        }
 
        pal = load_inherited_info(conn, name);
 
-       return posix_get_nt_acl_common(conn, name, &sbuf, pal, posix_acl,
-                                      def_acl, security_info, ppdesc);
+       status = posix_get_nt_acl_common(conn, name, &smb_fname->st, pal,
+                                        posix_acl, def_acl, security_info,
+                                        ppdesc);
+ out:
+       TALLOC_FREE(smb_fname);
+       return status;
 }
 
 /****************************************************************************
index dda79c209f329549e0132d17bf0a704174dd8030..5a6e3d7ecbf40088864e917db9591f4e757ad16c 100644 (file)
@@ -367,22 +367,12 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                char *data = NULL;
                int data_size = 0;
                NTSTATUS status;
-               SMB_STRUCT_STAT st;
 
                /* the levels directly map to the passthru levels */
                file_info_level = in_file_info_class + 1000;
 
-               if (vfs_stat_smb_fname(conn,".",&st)!=0) {
-                       DEBUG(2,("call_trans2qfsinfo: stat of . failed (%s)\n",
-                               strerror(errno)));
-                       status = map_nt_error_from_unix(errno);
-                       tevent_req_nterror(req, status);
-                       return tevent_req_post(req, ev);
-               }
-
                status = smbd_do_qfsinfo(conn, state,
                                         file_info_level,
-                                        st,
                                         STR_UNICODE,
                                         in_output_buffer_length,
                                         &data,
index cac0147c4d2e959ad4ebdc44b4300e7c5a1bb573..856fd9432d072cc924b6eddffe6815a9e9b13692 100644 (file)
@@ -2682,7 +2682,6 @@ static void samba_extended_info_version(struct smb_extended_info *extended_info)
 NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
                         TALLOC_CTX *mem_ctx,
                         uint16_t info_level,
-                        SMB_STRUCT_STAT st,
                         uint16_t flags2,
                         unsigned int max_data_bytes,
                         char **ppdata,
@@ -2694,6 +2693,9 @@ NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
        int snum = SNUM(conn);
        char *fstype = lp_fstype(SNUM(conn));
        uint32 additional_flags = 0;
+       struct smb_filename *smb_fname_dot = NULL;
+       SMB_STRUCT_STAT st;
+       NTSTATUS status;
 
        if (IS_IPC(conn)) {
                if (info_level != SMB_QUERY_CIFS_UNIX_INFO) {
@@ -2706,6 +2708,21 @@ NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
 
        DEBUG(3,("smbd_do_qfsinfo: level = %d\n", info_level));
 
+       status = create_synthetic_smb_fname(talloc_tos(), ".", NULL, NULL,
+                                           &smb_fname_dot);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       if(SMB_VFS_STAT(conn, smb_fname_dot) != 0) {
+               DEBUG(2,("stat of . failed (%s)\n", strerror(errno)));
+               TALLOC_FREE(smb_fname_dot);
+               return map_nt_error_from_unix(errno);
+       }
+
+       st = smb_fname_dot->st;
+       TALLOC_FREE(smb_fname_dot);
+
        *ppdata = (char *)SMB_REALLOC(
                *ppdata, max_data_bytes + DIR_ENTRY_SAFETY_MARGIN);
        if (*ppdata == NULL) {
@@ -3228,7 +3245,6 @@ static void call_trans2qfsinfo(connection_struct *conn,
        char *params = *pparams;
        uint16_t info_level;
        int data_len = 0;
-       SMB_STRUCT_STAT st;
        NTSTATUS status;
 
        if (total_params < 2) {
@@ -3251,14 +3267,8 @@ static void call_trans2qfsinfo(connection_struct *conn,
 
        DEBUG(3,("call_trans2qfsinfo: level = %d\n", info_level));
 
-       if(vfs_stat_smb_fname(conn,".",&st)!=0) {
-               DEBUG(2,("call_trans2qfsinfo: stat of . failed (%s)\n", strerror(errno)));
-               reply_doserror(req, ERRSRV, ERRinvdevice);
-               return;
-       }
-
        status = smbd_do_qfsinfo(conn, req,
-                                info_level, st,
+                                info_level,
                                 req->flags2,
                                 max_data_bytes,
                                 ppdata, &data_len);