summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-16 14:37:42 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-16 15:25:40 +1000
commit43255a1d18b714ab108b21f5a1065a82e44e3490 (patch)
tree4f22f2ce13db1a29496c337195936867dd180644
parent1157db293f5db7909f84f021581ddb916cfd8c7e (diff)
downloadsamba-43255a1d18b714ab108b21f5a1065a82e44e3490.tar.gz
samba-43255a1d18b714ab108b21f5a1065a82e44e3490.tar.bz2
samba-43255a1d18b714ab108b21f5a1065a82e44e3490.zip
s3-torture: Initialise fsp fully in vfstest open
-rw-r--r--source3/torture/cmd_vfs.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 0869e0b066..268e5c1135 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -242,6 +242,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
files_struct *fsp;
struct smb_filename *smb_fname = NULL;
NTSTATUS status;
+ int ret;
mode = 00400;
@@ -347,6 +348,39 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
return NT_STATUS_UNSUCCESSFUL;
}
+ ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
+ if (ret == -1) {
+ /* If we have an fd, this stat should succeed. */
+ DEBUG(0,("Error doing fstat on open file %s "
+ "(%s)\n",
+ smb_fname_str_dbg(smb_fname),
+ strerror(errno) ));
+ status = map_nt_error_from_unix(errno);
+ } else if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+ errno = EISDIR;
+ status = NT_STATUS_FILE_IS_A_DIRECTORY;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ SMB_VFS_CLOSE(fsp);
+ SAFE_FREE(fsp->fh);
+ SAFE_FREE(fsp);
+ TALLOC_FREE(smb_fname);
+ return status;
+ }
+
+ fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st);
+ fsp->vuid = UID_FIELD_INVALID;
+ fsp->file_pid = 0;
+ fsp->can_lock = True;
+ fsp->can_read = True;
+ fsp->can_write =
+ CAN_WRITE(vfs->conn);
+ fsp->print_file = NULL;
+ fsp->modified = False;
+ fsp->sent_oplock_break = NO_BREAK_SENT;
+ fsp->is_directory = False;
+
vfs->files[fsp->fh->fd] = fsp;
printf("open: fd=%d\n", fsp->fh->fd);
return NT_STATUS_OK;