]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/smbd: add new toplevel vfs_fstreaminfo wrapper
authorNoel Power <noel.power@suse.com>
Wed, 28 Apr 2021 08:51:05 +0000 (09:51 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 11 May 2021 15:49:28 +0000 (15:49 +0000)
This will allow for calling SMB_VFS_FSTREAMINFO in a piecemeal
fashion, at the end of the patch set vfs_fstreaminfo will replace
vfs_streaminfo

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/proto.h
source3/smbd/vfs.c

index b0707356b8010397c0de94f57fabfe31052e67d7..05308393d64fca7f2c7b52cb30d6b9beb8478ec6 100644 (file)
@@ -1335,6 +1335,10 @@ NTSTATUS vfs_streaminfo(connection_struct *conn,
                        TALLOC_CTX *mem_ctx,
                        unsigned int *num_streams,
                        struct stream_struct **streams);
+NTSTATUS vfs_fstreaminfo(struct files_struct *fsp,
+                       TALLOC_CTX *mem_ctx,
+                       unsigned int *num_streams,
+                       struct stream_struct **streams);
 void init_smb_file_time(struct smb_file_time *ft);
 int vfs_fake_fd(void);
 int vfs_fake_fd_close(int fd);
index 9104db06690864daa815316f7ae8cf593487dd1a..9108ef2c8955d7db78bcb9d225e5d31ce2c9e2da 100644 (file)
@@ -1593,6 +1593,36 @@ NTSTATUS vfs_streaminfo(connection_struct *conn,
                        streams);
 }
 
+NTSTATUS vfs_fstreaminfo(struct files_struct *fsp,
+                       TALLOC_CTX *mem_ctx,
+                       unsigned int *num_streams,
+                       struct stream_struct **streams)
+{
+       *num_streams = 0;
+       *streams = NULL;
+
+       if (fsp == NULL) {
+               /*
+                * Callers may pass fsp == NULL when passing smb_fname->fsp of a
+                * symlink. This is ok, handle it here, by just return no
+                * streams on a symlink.
+                */
+                return NT_STATUS_OK;
+        }
+
+       if (fsp_get_pathref_fd(fsp) == -1) {
+               /*
+                * No streams on non-real files/directories.
+                */
+               return NT_STATUS_OK;
+       }
+
+       return SMB_VFS_FSTREAMINFO(fsp,
+                       mem_ctx,
+                       num_streams,
+                       streams);
+}
+
 int vfs_fake_fd(void)
 {
        int pipe_fds[2];