From 1b976d51928dd6fa923272d277e13e5267188869 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jan 2008 20:41:15 +0100 Subject: Add the STREAMINFO vfs call Based on jpeach's work, modified the streaminfo prototype Make use of it in trans2.c together with marshall_stream_info() (This used to be commit c34d729c7c0600a8f11bf7e489a634a4e37fe88e) --- source3/modules/vfs_default.c | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'source3/modules/vfs_default.c') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 31234f23ec..2e620d04cc 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -942,6 +942,63 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle, S return file_id_create_dev(dev, inode); } +static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, + struct files_struct *fsp, + const char *fname, + TALLOC_CTX *mem_ctx, + unsigned int *pnum_streams, + struct stream_struct **pstreams) +{ + SMB_STRUCT_STAT sbuf; + NTSTATUS status; + unsigned int num_streams = 0; + struct stream_struct *streams = NULL; + int ret; + + if ((fsp != NULL) && (fsp->is_directory)) { + /* + * No default streams on directories + */ + goto done; + } + + if ((fsp != NULL) && (fsp->fh->fd != -1)) { + ret = SMB_VFS_FSTAT(fsp, &sbuf); + } + else { + ret = SMB_VFS_STAT(handle->conn, fname, &sbuf); + } + + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + + if (S_ISDIR(sbuf.st_mode)) { + goto done; + } + + streams = talloc(mem_ctx, struct stream_struct); + + if (streams == NULL) { + return NT_STATUS_NO_MEMORY; + } + + streams->size = sbuf.st_size; + streams->alloc_size = get_allocation_size(handle->conn, fsp, &sbuf); + + streams->name = talloc_strdup(streams, "::$DATA"); + if (streams->name == NULL) { + TALLOC_FREE(streams); + return NT_STATUS_NO_MEMORY; + } + + num_streams = 1; + done: + *pnum_streams = num_streams; + *pstreams = streams; + return NT_STATUS_OK; +} + static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) @@ -1367,6 +1424,8 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_file_id_create), SMB_VFS_OP_FILE_ID_CREATE, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_streaminfo), SMB_VFS_OP_STREAMINFO, + SMB_VFS_LAYER_OPAQUE}, /* NT ACL operations. */ -- cgit From 9a226532221b88369b913bc9f9d6ec335620349f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jan 2008 15:10:44 +0100 Subject: Add SMB_VFS_FS_CAPABILITIES It turns out that this is a necessary operation, separate from statvfs. statvfs can fail during tcon, so conn->fs_capabilities would never see that we support streams on a particular share. James, can you check that I got the darwin variant right? Thanks! (This used to be commit 3ad798d803b3b023533bb48e6993885f22b96095) --- source3/modules/vfs_default.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source3/modules/vfs_default.c') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 2e620d04cc..17d0dfabaf 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -90,6 +90,17 @@ static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, return sys_statvfs(path, statbuf); } +static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle) +{ +#if defined(DARWINOS) + struct statfs sbuf; + ZERO_STRUCT(sbuf); + sys_statvfs(handle->conn->connectpath, &sbuf); + return sbuf.FsCapabilities; +#endif + return FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; +} + /* Directory operations */ static SMB_STRUCT_DIR *vfswrap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr) @@ -1330,6 +1341,8 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_statvfs), SMB_VFS_OP_STATVFS, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES, + SMB_VFS_LAYER_OPAQUE}, /* Directory operations */ -- cgit From 2dbbb375742e508dddf29f3f003d138e64f8e2d6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jan 2008 18:07:38 +0100 Subject: Attempt to fix the darwin build (This used to be commit 5b05e09daf18eaea5e86dfd607c8070228f7571b) --- source3/modules/vfs_default.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/modules/vfs_default.c') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 17d0dfabaf..9c5b644a50 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -93,10 +93,10 @@ static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle) { #if defined(DARWINOS) - struct statfs sbuf; - ZERO_STRUCT(sbuf); - sys_statvfs(handle->conn->connectpath, &sbuf); - return sbuf.FsCapabilities; + struct vfs_statvfs_struct statbuf; + ZERO_STRUCT(statbuf); + sys_statvfs(handle->conn->connectpath, &statbuf); + return statbuf.FsCapabilities; #endif return FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; } -- cgit From 5b35ecd930dc6267821c7a3d8b3a90c680ab71b1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Jan 2008 10:33:36 +0100 Subject: Remove two unused variables (This used to be commit f12ac1ecedd6634d8ccc54d8fce8382514e3322f) --- source3/modules/vfs_default.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/modules/vfs_default.c') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 9c5b644a50..cf135dfd03 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -961,7 +961,6 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, struct stream_struct **pstreams) { SMB_STRUCT_STAT sbuf; - NTSTATUS status; unsigned int num_streams = 0; struct stream_struct *streams = NULL; int ret; -- cgit