From 9094694db7d7f36785d1d8916bab6dda96d1fb78 Mon Sep 17 00:00:00 2001 From: Frank Lahm Date: Wed, 31 Aug 2011 11:24:28 +0200 Subject: [PATCH 2/2] Add support for VFS op streaminfo chaining in all relevant VFS modules --- source3/modules/onefs_streams.c | 17 +++-------------- source3/modules/vfs_default.c | 27 +++++++++------------------ source3/modules/vfs_streams_depot.c | 18 +++--------------- source3/modules/vfs_streams_xattr.c | 18 ++++-------------- 4 files changed, 19 insertions(+), 61 deletions(-) diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c index 85ab256..ac88573 100644 --- a/source3/modules/onefs_streams.c +++ b/source3/modules/onefs_streams.c @@ -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); } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 4d06a10..5b07da2 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -1182,8 +1182,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; int ret; if ((fsp != NULL) && (fsp->is_directory)) { @@ -1218,25 +1217,17 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, goto done; } - streams = talloc(mem_ctx, struct stream_struct); - - if (streams == NULL) { + if ((tmp = TALLOC_REALLOC_ARRAY(mem_ctx, *pstreams, struct stream_struct, + (*pnum_streams) + 1)) == 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); + if ((tmp[*pnum_streams].name = talloc_strdup(tmp, "::$DATA")) == NULL) return NT_STATUS_NO_MEMORY; - } - - num_streams = 1; + tmp[*pnum_streams].size = sbuf.st_ex_size; + tmp[*pnum_streams].alloc_size = SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, &sbuf); + + *pnum_streams += 1; + *pstreams = tmp; done: - *pnum_streams = num_streams; - *pstreams = streams; return NT_STATUS_OK; } diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 01851cd..708a90b 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -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); diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 34e01b0..08d8d14 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -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, -- 1.7.0.5