summaryrefslogtreecommitdiffstats
path: root/source3/smbd/vfs.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-10-02 13:45:38 -0700
committerJeremy Allison <jra@samba.org>2009-10-02 13:45:38 -0700
commit6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9 (patch)
treee1a873d8586b5386f9ddecc5bf46e961a4d634c7 /source3/smbd/vfs.c
parente218a529e0affd22118ab8f541474e600be5769a (diff)
downloadsamba-6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9.tar.gz
samba-6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9.tar.xz
samba-6f22cd10ad30bd9077916c4fecbc8f7bb08c68b9.zip
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.
Diffstat (limited to 'source3/smbd/vfs.c')
-rw-r--r--source3/smbd/vfs.c25
1 files changed, 25 insertions, 0 deletions
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
*/