From 87f2dd82ee1d937aaeaa57f38d4598d860ebb46c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 1 May 2015 12:50:51 -0700 Subject: [PATCH] s3: smbd: VFS: Add vfs_stat_smb_basename() - to be called when we *know* stream name parsing has already been done. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11249 Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit 044dabfd92d09de4f168a36a07ac3232f5647a1d) --- source3/smbd/proto.h | 2 ++ source3/smbd/vfs.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 9980d031325..259a10989cf 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1176,6 +1176,8 @@ int vfs_stat_smb_fname(struct connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf); int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf); +int vfs_stat_smb_basename(struct connection_struct *conn, const char *fname, + SMB_STRUCT_STAT *psbuf); NTSTATUS vfs_stat_fsp(files_struct *fsp); NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid); NTSTATUS vfs_streaminfo(connection_struct *conn, diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index d10e0d67e90..885f24cd6e5 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1330,6 +1330,32 @@ int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname, return ret; } +/** + * XXX: This is temporary and there should be no callers of this once + * smb_filename is plumbed through all path based operations. + * + * Called when we know stream name parsing has already been done. + */ +int vfs_stat_smb_basename(struct connection_struct *conn, const char *fname, + SMB_STRUCT_STAT *psbuf) +{ + struct smb_filename smb_fname = { + .base_name = discard_const_p(char, fname) + }; + int ret; + + if (lp_posix_pathnames()) { + ret = SMB_VFS_LSTAT(conn, &smb_fname); + } else { + ret = SMB_VFS_STAT(conn, &smb_fname); + } + + if (ret != -1) { + *psbuf = smb_fname.st; + } + return ret; +} + /** * Ensure LSTAT is called for POSIX paths. */ -- 2.34.1