From 6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Oct 2009 13:45:38 -0700 Subject: Remove lots of duplicate code and move it into one function vfs_stat_fsp(). Stops code looking at fsp->posix_open except for exceptional circumstances. Jeremy. --- source3/smbd/vfs.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3/smbd/vfs.c') diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 171c8032043..966742a6d01 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1049,6 +1049,31 @@ int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname, return ret; } +/** + * Ensure LSTAT is called for POSIX paths. + */ + +NTSTATUS vfs_stat_fsp(files_struct *fsp) +{ + int ret; + + if(fsp->is_directory || fsp->fh->fd == -1) { + if (fsp->posix_open) { + ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name); + } else { + ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name); + } + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + } else { + if(SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) { + return map_nt_error_from_unix(errno); + } + } + return NT_STATUS_OK; +} + /* generate a file_id from a stat structure */ -- cgit