NTSTATUS status;
unsigned int i, num_streams = 0;
struct stream_struct *streams = NULL;
+ struct smb_filename *pathref = NULL;
if (SMB_VFS_STAT(conn, smb_fname) == 0) {
DEBUG(10, ("'%s' exists\n", smb_fname_str_dbg(smb_fname)));
goto fail;
}
+ if (smb_fname->fsp == NULL) {
+ status = synthetic_pathref(mem_ctx,
+ conn->cwd_fsp,
+ smb_fname->base_name,
+ NULL,
+ NULL,
+ smb_fname->twrp,
+ smb_fname->flags,
+ &pathref);
+ if (!NT_STATUS_IS_OK(status)) {
+ if (NT_STATUS_EQUAL(status,
+ NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ TALLOC_FREE(pathref);
+ SET_STAT_INVALID(smb_fname->st);
+ return NT_STATUS_OK;
+ }
+ DBG_DEBUG("synthetic_pathref failed: %s\n",
+ nt_errstr(status));
+ goto fail;
+ }
+ } else {
+ pathref = smb_fname;
+ }
+
/* Fall back to a case-insensitive scan of all streams on the file. */
- status = vfs_streaminfo(conn, NULL, smb_fname, mem_ctx,
+ status = vfs_streaminfo(conn, NULL, pathref, mem_ctx,
&num_streams, &streams);
-
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
SET_STAT_INVALID(smb_fname->st);
+ TALLOC_FREE(pathref);
return NT_STATUS_OK;
}
/* Couldn't find the stream. */
if (i == num_streams) {
SET_STAT_INVALID(smb_fname->st);
+ TALLOC_FREE(pathref);
TALLOC_FREE(streams);
return NT_STATUS_OK;
}
}
status = NT_STATUS_OK;
fail:
+ TALLOC_FREE(pathref);
TALLOC_FREE(streams);
return status;
}