summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-04-22 17:30:53 +0000
committerJeremy Allison <jra@samba.org>2003-04-22 17:30:53 +0000
commit2aa7b1573c940d7a0381ac33f97ee5bd185c16bd (patch)
treeec5dc4435a51be3cd844c7accafb7a542755e17c /source3/smbd/open.c
parent2595d6f94bee592ac4bd2756af6fdf54d0b5cd56 (diff)
downloadsamba-2aa7b1573c940d7a0381ac33f97ee5bd185c16bd.tar.gz
samba-2aa7b1573c940d7a0381ac33f97ee5bd185c16bd.tar.bz2
samba-2aa7b1573c940d7a0381ac33f97ee5bd185c16bd.zip
Add runtime tests for "impossible" case with -DDEVELOPER. Trying to catch logic
error on Linux. Jeremy. (This used to be commit 546d1a941b63a538702f2fb668019d2b89f63bdc)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r--source3/smbd/open.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 6b3dcbe71b..5e4f3caca7 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -532,6 +532,29 @@ existing desired access (0x%x).\n", fname, (unsigned int)desired_access, (unsign
return True;
}
+
+#if defined(DEVELOPER)
+static void validate_my_share_entries(share_mode_entry *share_entry)
+{
+ files_struct *fsp;
+
+ if (share_entry->pid != sys_getpid())
+ return;
+
+ fsp = file_find_dif(share_entry->dev, share_entry->inode, share_entry->share_file_id);
+ if (!fsp) {
+ smb_panic("validate_my_share_entries: Cannot match a share entry with an open file\n");
+ }
+
+ if (((uint16)fsp->oplock_type) != share_entry->op_type) {
+ pstring str;
+ slprintf(str, sizeof(str)-1, "validate_my_share_entries: file %s, oplock_type = 0x%x, op_type = 0x%x\n",
+ fsp->fsp_name, (unsigned int)fsp->oplock_type, (unsigned int)share_entry->op_type );
+ smb_panic(str);
+ }
+}
+#endif
+
/****************************************************************************
Deal with open deny mode and oplock break processing.
Invarient: Share mode must be locked on entry and exit.
@@ -572,6 +595,10 @@ static int open_mode_check(connection_struct *conn, const char *fname, SMB_DEV_T
for(i = 0; i < num_share_modes; i++) {
share_mode_entry *share_entry = &old_shares[i];
+#if defined(DEVELOPER)
+ validate_my_share_entries(share_entry);
+#endif
+
/*
* By observation of NetBench, oplocks are broken *before* share
* modes are checked. This allows a file to be closed by the client