Index: /trunk/include/iprt/lockvalidator.h
===================================================================
--- /trunk/include/iprt/lockvalidator.h	(revision 25907)
+++ /trunk/include/iprt/lockvalidator.h	(revision 25908)
@@ -718,4 +718,15 @@
 
 /**
+ * Checks if the specified thread is one of the owners.
+ *
+ * @returns true if it is, false if not.
+ *
+ * @param   pRec                The validator record.
+ * @param   hThread             The thread handle of the owner.  NIL_RTTHREAD is
+ *                              an alias for the current thread.
+ */
+RTDECL(bool) RTLockValidatorRecSharedIsOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread);
+
+/**
  * Check the exit order and release (unset) the shared ownership.
  *
Index: /trunk/include/iprt/semaphore.h
===================================================================
--- /trunk/include/iprt/semaphore.h	(revision 25907)
+++ /trunk/include/iprt/semaphore.h	(revision 25908)
@@ -850,4 +850,25 @@
  */
 RTDECL(bool)  RTSemRWIsWriteOwner(RTSEMRW hRWSem);
+
+/**
+ * Checks if the caller is one of the read owners of the sempahore.
+ *
+ * @note    !CAUTION!  This API doesn't work reliably if lock validation isn't
+ *          enabled. Meaning, the answer is not trustworhty unless
+ *          RT_LOCK_STRICT or RTSEMRW_STRICT was defined at build time.  Also,
+ *          make sure you do not use RTSEMRW_FLAGS_NO_LOCK_VAL when creating
+ *          the semaphore.  And finally, if you used a locking class, don't
+ *          disable deadlock detection by setting cMsMinDeadlock to
+ *          RT_INDEFINITE_WAIT.
+ *
+ *          In short, only use this for assertions.
+ *
+ * @returns true if reader, false if not.
+ * @param   hRWSem              Handle to the read/write semaphore.
+ * @param   fWannaHear          What you'd like to hear when lock validation is
+ *                              not available.  (For avoiding asserting all over
+ *                              the place.)
+ */
+RTDECL(bool)  RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear);
 
 /**
Index: /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 25907)
+++ /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 25908)
@@ -4018,5 +4018,9 @@
     if (!pRec->fEnabled)
         return;
-    AssertReturnVoid(hThread != NIL_RTTHREAD);
+    if (hThread == NIL_RTTHREAD)
+    {
+        hThread = RTThreadSelfAutoAdopt();
+        AssertReturnVoid(hThread != NIL_RTTHREAD);
+    }
     AssertReturnVoid(hThread->u32Magic == RTTHREADINT_MAGIC);
 
@@ -4043,4 +4047,24 @@
 }
 RT_EXPORT_SYMBOL(RTLockValidatorRecSharedRemoveOwner);
+
+
+RTDECL(bool) RTLockValidatorRecSharedIsOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread)
+{
+    /* Validate and resolve input. */
+    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, false);
+    if (!pRec->fEnabled)
+        return false;
+    if (hThread == NIL_RTTHREAD)
+    {
+        hThread = RTThreadSelfAutoAdopt();
+        AssertReturn(hThread != NIL_RTTHREAD, false);
+    }
+    AssertReturn(hThread->u32Magic == RTTHREADINT_MAGIC, false);
+
+    /* Do the job. */
+    PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
+    return pEntry != NULL;
+}
+RT_EXPORT_SYMBOL(RTLockValidatorRecSharedIsOwner);
 
 
Index: /trunk/src/VBox/Runtime/generic/RTFileReadAll-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/generic/RTFileReadAll-generic.cpp	(revision 25907)
+++ /trunk/src/VBox/Runtime/generic/RTFileReadAll-generic.cpp	(revision 25908)
@@ -39,5 +39,5 @@
 RTDECL(int) RTFileReadAll(const char *pszFilename, void **ppvFile, size_t *pcbFile)
 {
-    return RTFileReadAllEx(pszFilename, 0, RTFOFF_MAX, 0, ppvFile, pcbFile);
+    return RTFileReadAllEx(pszFilename, 0, RTFOFF_MAX, RTFILE_RDALL_O_DENY_WRITE, ppvFile, pcbFile);
 }
 RT_EXPORT_SYMBOL(RTFileReadAll);
Index: /trunk/src/VBox/Runtime/generic/semrw-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/generic/semrw-generic.cpp	(revision 25907)
+++ /trunk/src/VBox/Runtime/generic/semrw-generic.cpp	(revision 25908)
@@ -869,9 +869,8 @@
 RTDECL(bool) RTSemRWIsWriteOwner(RTSEMRW hRWSem)
 {
+    /*
+     * Validate handle.
+     */
     struct RTSEMRWINTERNAL *pThis = hRWSem;
-
-    /*
-     * Validate handle.
-     */
     AssertPtrReturn(pThis, false);
     AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false);
@@ -886,4 +885,42 @@
 }
 RT_EXPORT_SYMBOL(RTSemRWIsWriteOwner);
+
+
+RTDECL(bool)  RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear)
+{
+    /*
+     * Validate handle.
+     */
+    struct RTSEMRWINTERNAL *pThis = hRWSem;
+    AssertPtrReturn(pThis, false);
+    AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false);
+
+    /*
+     * Check write ownership.  The writer is also a valid reader.
+     */
+    RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
+    RTNATIVETHREAD hWriter;
+    ASMAtomicUoReadHandle(&pThis->hWriter, &hWriter);
+    if (hWriter == hNativeSelf)
+        return true;
+    if (hWriter != NIL_RTNATIVETHREAD)
+        return false;
+
+#ifdef RTSEMRW_STRICT
+    /*
+     * Ask the lock validator.
+     */
+    return RTLockValidatorRecSharedIsOwner(&pThis->ValidatorRead, NIL_RTTHREAD);
+#else
+    /*
+     * If there are no reads we cannot be one of them... But if there are we
+     * cannot know and can only return what the caller want to hear.
+     */
+    if (pThis->cReads == 0)
+        return false;
+    return fWannaHear;
+#endif
+}
+RT_EXPORT_SYMBOL(RTSemRWIsReadOwner);
 
 
Index: /trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp	(revision 25907)
+++ /trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp	(revision 25908)
@@ -876,4 +876,50 @@
 
 
+RTDECL(bool)  RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear)
+{
+    /*
+     * Validate handle.
+     */
+    struct RTSEMRWINTERNAL *pThis = hRWSem;
+    AssertPtrReturn(pThis, false);
+    AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false);
+
+    /*
+     * Inspect the state.
+     */
+    uint64_t u64State = ASMAtomicReadU64(&pThis->u64State);
+    if ((u64State & RTSEMRW_DIR_MASK) == (RTSEMRW_DIR_WRITE << RTSEMRW_DIR_SHIFT))
+    {
+        /*
+         * It's in write mode, so we can only be a reader if we're also the
+         * current writer.
+         */
+        RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
+        RTNATIVETHREAD hWriter;
+        ASMAtomicUoReadHandle(&pThis->hWriter, &hWriter);
+        return hWriter == hNativeSelf;
+    }
+
+    /*
+     * Read mode.  If there are no current readers, then we cannot be a reader.
+     */
+    if (!(u64State & RTSEMRW_CNT_RD_MASK))
+        return false;
+
+#ifdef RTSEMRW_STRICT
+    /*
+     * Ask the lock validator.
+     */
+    return RTLockValidatorRecSharedIsOwner(&pThis->ValidatorRead, NIL_RTTHREAD);
+#else
+    /*
+     * Ok, we don't know, just tell the caller what he want to hear.
+     */
+    return fWannaHear;
+#endif
+}
+RT_EXPORT_SYMBOL(RTSemRWIsReadOwner);
+
+
 RTDECL(uint32_t) RTSemRWGetWriteRecursion(RTSEMRW hRWSem)
 {
Index: /trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp	(revision 25907)
+++ /trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp	(revision 25908)
@@ -638,4 +638,45 @@
 
 
+RTDECL(bool)  RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear)
+{
+    /*
+     * Validate handle.
+     */
+    struct RTSEMRWINTERNAL *pThis = hRWSem;
+    AssertPtrReturn(pThis, false);
+    AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false);
+
+    /*
+     * Check write ownership.  The writer is also a valid reader.
+     */
+    pthread_t Self = pthread_self();
+    pthread_t Writer;
+    ATOMIC_GET_PTHREAD_T(&pThis->Writer, &Writer);
+    if (Writer == Self)
+        return true;
+    if (Writer != (pthread_t)-1)
+        return false;
+
+    /*
+     * If there are no readers, we cannot be one of them, can we?
+     */
+    if (ASMAtomicReadU32(&pThis->cReaders) == 0)
+        return false;
+
+#ifdef RTSEMRW_STRICT
+    /*
+     * Ask the lock validator.
+     */
+    return RTLockValidatorRecSharedIsOwner(&pThis->ValidatorRead, NIL_RTTHREAD);
+#else
+    /*
+     * Just tell the caller what he want to hear.
+     */
+    return fWannaHear;
+#endif
+}
+RT_EXPORT_SYMBOL(RTSemRWIsReadOwner);
+
+
 RTDECL(uint32_t) RTSemRWGetWriteRecursion(RTSEMRW hRWSem)
 {
