char *path,uint16 spid);
NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, bool expect_close,uint16 spid,
const char *wcard, bool wcard_has_wild, uint32 attr, struct dptr_struct **dptr_ret);
-int dptr_CloseDir(struct dptr_struct *dptr);
+void dptr_CloseDir(files_struct *fsp);
void dptr_SeekDir(struct dptr_struct *dptr, long offset);
long dptr_TellDir(struct dptr_struct *dptr);
bool dptr_has_wild(struct dptr_struct *dptr);
strerror(errno)));
}
- if (fsp->dptr) {
- dptr_CloseDir(fsp->dptr);
- }
-
/*
* Do the code common to files and directories.
*/
Wrapper functions to access the lower level directory handles.
****************************************************************************/
-int dptr_CloseDir(struct dptr_struct *dptr)
+void dptr_CloseDir(files_struct *fsp)
{
- dptr_close_internal(dptr);
- return 0;
+ if (fsp->dptr) {
+ if (fsp->fh->fd == dirfd(fsp->dptr->dir_hnd->dir)) {
+ /* The call below closes the underlying fd. */
+ fsp->fh->fd = -1;
+ }
+ dptr_close_internal(fsp->dptr);
+ fsp->dptr = NULL;
+ }
}
void dptr_SeekDir(struct dptr_struct *dptr, long offset)
{
int ret;
+ if (fsp->dptr) {
+ dptr_CloseDir(fsp);
+ }
if (fsp->fh->fd == -1) {
return NT_STATUS_OK; /* What we used to call a stat open. */
}
}
if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) {
- if (fsp->dptr) {
- dptr_CloseDir(fsp->dptr);
- fsp->dptr = NULL;
- }
+ dptr_CloseDir(fsp);
}
if (fsp->dptr == NULL) {