summaryrefslogtreecommitdiff
path: root/source3/smbd/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/files.c')
-rw-r--r--source3/smbd/files.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 65986e9612..181e17b11f 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -65,7 +65,7 @@ files_struct *file_new(connection_struct *conn)
{
int i;
static int first_file;
- files_struct *fsp, *next;
+ files_struct *fsp;
/* we want to give out file handles differently on each new
connection because of a common bug in MS clients where they try to
@@ -76,32 +76,21 @@ files_struct *file_new(connection_struct *conn)
first_file = (sys_getpid() ^ (int)time(NULL)) % real_max_open_files;
}
+ /* TODO: Port the id-tree implementation from Samba4 */
+
i = bitmap_find(file_bmap, first_file);
if (i == -1) {
- /*
- * Before we give up, go through the open files
- * and see if there are any files opened with a
- * batch oplock. If so break the oplock and then
- * re-use that entry (if it becomes closed).
- * This may help as NT/95 clients tend to keep
- * files batch oplocked for quite a long time
- * after they have finished with them.
- */
- for (fsp=Files;fsp;fsp=next) {
- next=fsp->next;
- if (attempt_close_oplocked_file(fsp)) {
- return file_new(conn);
- }
- }
-
DEBUG(0,("ERROR! Out of file structures\n"));
- set_saved_error_triple(ERRSRV, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES);
+ /* TODO: We have to unconditionally return a DOS error here,
+ * W2k3 even returns ERRDOS/ERRnofids for ntcreate&x with
+ * NTSTATUS negotiated */
+ set_saved_ntstatus(NT_STATUS_TOO_MANY_OPENED_FILES);
return NULL;
}
fsp = SMB_MALLOC_P(files_struct);
if (!fsp) {
- set_saved_error_triple(ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY);
+ set_saved_ntstatus(NT_STATUS_NO_MEMORY);
return NULL;
}
@@ -110,7 +99,7 @@ files_struct *file_new(connection_struct *conn)
fsp->fh = SMB_MALLOC_P(struct fd_handle);
if (!fsp->fh) {
SAFE_FREE(fsp);
- set_saved_error_triple(ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY);
+ set_saved_ntstatus(NT_STATUS_NO_MEMORY);
return NULL;
}
@@ -293,7 +282,9 @@ files_struct *file_find_dif(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_i
DLIST_PROMOTE(Files, fsp);
}
/* Paranoia check. */
- if (fsp->fh->fd == -1 && fsp->oplock_type != NO_OPLOCK) {
+ if ((fsp->fh->fd == -1) &&
+ (fsp->oplock_type != NO_OPLOCK) &&
+ (fsp->oplock_type != FAKE_LEVEL_II_OPLOCK)) {
DEBUG(0,("file_find_dif: file %s dev = %x, inode = %.0f, file_id = %u \
oplock_type = %u is a stat open with oplock type !\n", fsp->fsp_name, (unsigned int)fsp->dev,
(double)fsp->inode, (unsigned int)fsp->file_id,