smbd: Use fsp_is_alternate_stream() where an fsp is available
authorVolker Lendecke <vl@samba.org>
Fri, 11 Feb 2022 08:59:16 +0000 (09:59 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 11 Feb 2022 20:54:37 +0000 (20:54 +0000)
Make it clear that being an alternate data stream handle is much more
a fsp property than a file name property.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c
source3/modules/vfs_fruit.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_virusfilter.c
source3/smbd/durable.c
source3/smbd/file_access.c
source3/smbd/nttrans.c
source3/smbd/smb2_write.c
source3/smbd/trans2.c

index f3aec6c2bff2486ecce772b053867460403fdf80..49a73ab97f6f6220d6be2bdcc194ccb95bb71f7e 100644 (file)
@@ -2234,8 +2234,8 @@ static NTSTATUS vfswrap_offload_copy_file_range(struct tevent_req *req)
                return NT_STATUS_MORE_PROCESSING_REQUIRED;
        }
 
-       if (is_named_stream(state->src_fsp->fsp_name) ||
-           is_named_stream(state->dst_fsp->fsp_name))
+       if (fsp_is_alternate_stream(state->src_fsp) ||
+           fsp_is_alternate_stream(state->dst_fsp))
        {
                return NT_STATUS_MORE_PROCESSING_REQUIRED;
        }
@@ -2761,7 +2761,7 @@ static int vfswrap_fntimes(vfs_handle_struct *handle,
 
        START_PROFILE(syscall_fntimes);
 
-       if (is_named_stream(fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(fsp)) {
                errno = ENOENT;
                goto out;
        }
index 15491e52af6dce853a4ce7218c223339465aa067..e84c4c98d37eee9f789d2074b6eb4b80a53b7d60 100644 (file)
@@ -1870,7 +1870,7 @@ static int fruit_close(vfs_handle_struct *handle,
 
        DBG_DEBUG("Path [%s] fd [%d]\n", smb_fname_str_dbg(fsp->fsp_name), fd);
 
-       if (!is_named_stream(fsp->fsp_name)) {
+       if (!fsp_is_alternate_stream(fsp)) {
                return SMB_VFS_NEXT_CLOSE(handle, fsp);
        }
 
index f6f162b3b574bf372eede3fbf27ad64df354972d..52517ee008414d944979b05c59227408d12163a0 100644 (file)
@@ -178,7 +178,7 @@ static int vfs_gpfs_filesystem_sharemode(vfs_handle_struct *handle,
         * fd, so lacking a distinct fd for the stream we have to skip
         * set_gpfs_sharemode for stream.
         */
-       if (is_named_stream(fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(fsp)) {
                DBG_NOTICE("Not requesting GPFS sharemode on stream: %s/%s\n",
                           fsp->conn->connectpath,
                           fsp_str_dbg(fsp));
index 0f745c63fbd50692a93d881ecaf405789ef053f4..156a1d6513370656863e1196483758e95fa02598 100644 (file)
@@ -464,7 +464,7 @@ static int streams_xattr_close(vfs_handle_struct *handle,
        DBG_DEBUG("streams_xattr_close called [%s] fd [%d]\n",
                        smb_fname_str_dbg(fsp->fsp_name), fd);
 
-       if (!is_named_stream(fsp->fsp_name)) {
+       if (!fsp_is_alternate_stream(fsp)) {
                return SMB_VFS_NEXT_CLOSE(handle, fsp);
        }
 
index d1554967ad1d9348093d824fdd88d0e952157be4..cbb93161a8a1f6accd885ba57360d32af0f5d016 100644 (file)
@@ -1459,7 +1459,7 @@ static int virusfilter_vfs_close(
                return close_result;
        }
 
-       if (is_named_stream(fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(fsp)) {
                if (config->scan_on_open && fsp->fsp_flags.modified) {
                        if (config->cache) {
                                DBG_DEBUG("Removing cache entry (if existent)"
index a49bca6fd6192766bb90715e2f35fde0ba1cd95a..e5dc86a5a7d69a14a71d3cb06e25c4aecda5c4e3 100644 (file)
@@ -79,7 +79,7 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp,
                return NT_STATUS_NOT_SUPPORTED;
        }
 
-       if (is_ntfs_stream_smb_fname(fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(fsp)) {
                /*
                 * We do not support durable handles
                 * on streams for now.
index 9193c6503160678a17070f9297260b47f39ec2cc..e3c8a1e2b67edd3205b0dd7f88e7ca12c3679cac 100644 (file)
@@ -228,7 +228,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode)
 
        /* Don't allow delete on close for non-empty directories. */
        if (fsp->fsp_flags.is_directory) {
-               SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
+               SMB_ASSERT(!fsp_is_alternate_stream(fsp));
 
                /* Or the root of a share. */
                if (ISDOT(fsp->fsp_name->base_name)) {
index 546639e9b7805486c5894ea8cc25fbf74a9c1abd..af7a49646e9aec9b108eb7648209d6f8f4ec6c1e 100644 (file)
@@ -452,7 +452,7 @@ static NTSTATUS get_relative_fid_filename(connection_struct *conn,
                return NT_STATUS_INVALID_HANDLE;
        }
 
-       if (is_ntfs_stream_smb_fname(dir_fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(dir_fsp)) {
                return NT_STATUS_INVALID_HANDLE;
        }
 
index e4067f83c2ed523115dcfaa40473f297c37a3e98..ff99127b067cb07fad6f26ebc1fd2f49a2aaa3ee 100644 (file)
@@ -193,8 +193,7 @@ static NTSTATUS smb2_write_complete_internal(struct tevent_req *req,
        files_struct *fsp = state->fsp;
 
        if (nwritten == -1) {
-               if (err == EOVERFLOW &&
-                   is_ntfs_stream_smb_fname(fsp->fsp_name)) {
+               if (err == EOVERFLOW && fsp_is_alternate_stream(fsp)) {
                        status = NT_STATUS_FILE_SYSTEM_LIMITATION;
                } else {
                        status = map_nt_error_from_unix(err);
index 9e3f5406450047cb824074384c3adfabf3326706..9dc0d648cd8220c23cbca06d66d07577afe7fd8b 100644 (file)
@@ -427,7 +427,7 @@ static NTSTATUS get_ea_list_from_fsp(TALLOC_CTX *mem_ctx,
                return NT_STATUS_OK;
        }
 
-       if (is_ntfs_stream_smb_fname(fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(fsp)) {
                return NT_STATUS_INVALID_PARAMETER;
        }
 
@@ -759,7 +759,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
        }
 
        /* Setting EAs on streams isn't supported. */
-       if (is_ntfs_stream_smb_fname(fsp->fsp_name)) {
+       if (fsp_is_alternate_stream(fsp)) {
                return NT_STATUS_INVALID_PARAMETER;
        }