Add support for VFS op streaminfo chaining in all relevant VFS modules.
authorFrank Lahm <franklahm@googlemail.com>
Thu, 13 Oct 2011 22:41:53 +0000 (15:41 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 14 Oct 2011 01:26:06 +0000 (03:26 +0200)
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Oct 14 03:26:06 CEST 2011 on sn-devel-104

source3/modules/onefs_streams.c
source3/modules/vfs_default.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_streams_xattr.c
source3/smbd/close.c
source3/smbd/filename.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/trans2.c

index 78230bcad675d7de9685b4461b662bf7c211701e..a9b4066cc7ab0ea739e27d3d9c91e6b766de811c 100644 (file)
@@ -736,25 +736,14 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
                return map_nt_error_from_unix(errno);
        }
 
-       state.streams = NULL;
-       state.num_streams = 0;
+       state.streams = *pstreams;
+       state.num_streams = *pnum_streams;
 
        if (lp_parm_bool(SNUM(handle->conn), PARM_ONEFS_TYPE,
                PARM_IGNORE_STREAMS, PARM_IGNORE_STREAMS_DEFAULT)) {
                goto out;
        }
 
-       /* Add the default stream. */
-       if (S_ISREG(sbuf.st_ex_mode)) {
-               if (!add_one_stream(mem_ctx,
-                                   &state.num_streams, &state.streams,
-                                   "", sbuf.st_ex_size,
-                                   SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
-                                                          &sbuf))) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-       }
-
        state.mem_ctx = mem_ctx;
        state.handle = handle;
        state.status = NT_STATUS_OK;
@@ -778,5 +767,5 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
  out:
        *num_streams = state.num_streams;
        *streams = state.streams;
-       return NT_STATUS_OK;
+       return SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams);
 }
index 17200696b340858c81a4e713142049c024a591f7..4fd844a104e933cc2ad818e65affeca839213ed5 100644 (file)
@@ -1692,8 +1692,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
                                   struct stream_struct **pstreams)
 {
        SMB_STRUCT_STAT sbuf;
-       unsigned int num_streams = 0;
-       struct stream_struct *streams = NULL;
+       struct stream_struct *tmp_streams = NULL;
        int ret;
 
        if ((fsp != NULL) && (fsp->is_directory)) {
@@ -1728,25 +1727,21 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
                goto done;
        }
 
-       streams = talloc(mem_ctx, struct stream_struct);
-
-       if (streams == NULL) {
+       tmp_streams = talloc_realloc(mem_ctx, *pstreams, struct stream_struct,
+                                       (*pnum_streams) + 1);
+       if (tmp_streams == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
-
-       streams->size = sbuf.st_ex_size;
-       streams->alloc_size = SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, &sbuf);
-
-       streams->name = talloc_strdup(streams, "::$DATA");
-       if (streams->name == NULL) {
-               TALLOC_FREE(streams);
+       tmp_streams[*pnum_streams].name = talloc_strdup(tmp_streams, "::$DATA");
+       if (tmp_streams[*pnum_streams].name == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
+       tmp_streams[*pnum_streams].size = sbuf.st_ex_size;
+       tmp_streams[*pnum_streams].alloc_size = SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, &sbuf);
 
-       num_streams = 1;
+       *pnum_streams += 1;
+       *pstreams = tmp_streams;
  done:
-       *pnum_streams = num_streams;
-       *pstreams = streams;
        return NT_STATUS_OK;
 }
 
index 3569405da305e7fa3ce89df82f457c0d9cc51b2f..e1ba6510059423d2da1a2e43dcd9390435f37ee4 100644 (file)
@@ -827,20 +827,8 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
                goto out;
        }
 
-       state.streams = NULL;
-       state.num_streams = 0;
-
-       if (!S_ISDIR(smb_fname_base->st.st_ex_mode)) {
-               if (!add_one_stream(mem_ctx,
-                                   &state.num_streams, &state.streams,
-                                   "::$DATA", smb_fname_base->st.st_ex_size,
-                                   SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
-                                                      &smb_fname_base->st))) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-       }
-
+       state.streams = *pstreams;
+       state.num_streams = *pnum_streams;
        state.mem_ctx = mem_ctx;
        state.handle = handle;
        state.status = NT_STATUS_OK;
@@ -861,7 +849,7 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
 
        *pnum_streams = state.num_streams;
        *pstreams = state.streams;
-       status = NT_STATUS_OK;
+       status = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams);
 
  out:
        TALLOC_FREE(smb_fname_base);
index 2772c96c4d8f1f938cd4151d0922985a86e76561..85647603535e8e31e619a7b6c4e3a76120cf9c57 100644 (file)
@@ -810,19 +810,8 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
                return map_nt_error_from_unix(errno);
        }
 
-       state.streams = NULL;
-       state.num_streams = 0;
-
-       if (!S_ISDIR(sbuf.st_ex_mode)) {
-               if (!add_one_stream(mem_ctx,
-                                   &state.num_streams, &state.streams,
-                                   "::$DATA", sbuf.st_ex_size,
-                                   SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
-                                                          &sbuf))) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-       }
-
+       state.streams = *pstreams;
+       state.num_streams = *pnum_streams;
        state.mem_ctx = mem_ctx;
        state.handle = handle;
        state.status = NT_STATUS_OK;
@@ -842,7 +831,8 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
 
        *pnum_streams = state.num_streams;
        *pstreams = state.streams;
-       return NT_STATUS_OK;
+
+       return SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, pnum_streams, pstreams);
 }
 
 static uint32_t streams_xattr_fs_capabilities(struct vfs_handle_struct *handle,
index a1b6fd8f2531a5da46197e992d24e99c2b9d6f60..33e497c598517da35e4f6b2e92f133095409be8b 100644 (file)
@@ -206,9 +206,9 @@ static void notify_deferred_opens(struct messaging_context *msg_ctx,
 
 NTSTATUS delete_all_streams(connection_struct *conn, const char *fname)
 {
-       struct stream_struct *stream_info;
+       struct stream_struct *stream_info = NULL;
        int i;
-       unsigned int num_streams;
+       unsigned int num_streams = 0;
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
 
index 610a4ce42aad5c08b23e04442e20ad5fd5b9561a..7fe7cc8063b1f71ba2ba29b536f481efed87accd 100644 (file)
@@ -1169,7 +1169,7 @@ static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
                                  struct smb_filename *smb_fname)
 {
        NTSTATUS status;
-       unsigned int i, num_streams;
+       unsigned int i, num_streams = 0;
        struct stream_struct *streams = NULL;
 
        if (SMB_VFS_STAT(conn, smb_fname) == 0) {
index c69aa6ae2fdb2551bb591026b45ea102c77e5548..2d6fa264cc67b0d08d6529d8c447e219800312ce 100644 (file)
@@ -693,7 +693,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
                uint16_t file_status = (NO_EAS|NO_SUBSTREAMS|NO_REPARSETAG);
                size_t num_names = 0;
-               unsigned int num_streams;
+               unsigned int num_streams = 0;
                struct stream_struct *streams = NULL;
 
                /* Do we have any EA's ? */
@@ -1274,7 +1274,7 @@ static void call_nt_transact_create(connection_struct *conn,
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
                uint16_t file_status = (NO_EAS|NO_SUBSTREAMS|NO_REPARSETAG);
                size_t num_names = 0;
-               unsigned int num_streams;
+               unsigned int num_streams = 0;
                struct stream_struct *streams = NULL;
 
                /* Do we have any EA's ? */
index a44f15f0cc5a41b88ea2f2fb7c508f3a49e01f83..b897c8aa2565b9856f5ff78613262924ffa5cc65 100644 (file)
@@ -2965,10 +2965,10 @@ void msg_file_was_renamed(struct messaging_context *msg,
 NTSTATUS open_streams_for_delete(connection_struct *conn,
                                        const char *fname)
 {
-       struct stream_struct *stream_info;
-       files_struct **streams;
+       struct stream_struct *stream_info = NULL;
+       files_struct **streams = NULL;
        int i;
-       unsigned int num_streams;
+       unsigned int num_streams = 0;
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
 
index fbb450476079f0b651e9b34bf6bc13c06b3a3e23..6ef7156c8e01501f22f0335da6f6b4f32c082783 100644 (file)
@@ -4671,8 +4671,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                 */
                case SMB_QUERY_FILE_STREAM_INFO:
                case SMB_FILE_STREAM_INFORMATION: {
-                       unsigned int num_streams;
-                       struct stream_struct *streams;
+                       unsigned int num_streams = 0;
+                       struct stream_struct *streams = NULL;
 
                        DEBUG(10,("smbd_do_qfilepathinfo: "
                                  "SMB_FILE_STREAM_INFORMATION\n"));