From: Jeremy Allison Date: Fri, 1 May 2015 19:50:51 +0000 (-0700) Subject: s3: smbd: VFS: Add vfs_stat_smb_basename() - to be called when we *know* stream name... X-Git-Tag: samba-4.1.19~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb22feab1631c15a3630f53b313824b510b85389;p=thirdparty%2Fsamba.git 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) --- diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 327b25d370e..2ff0f889edc 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1158,6 +1158,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 cdd5042d1f4..118f6c90b2b 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1324,6 +1324,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. */