[NPFS_NEW]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 12 Sep 2013 00:05:54 +0000 (00:05 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 12 Sep 2013 00:05:54 +0000 (00:05 +0000)
Don't hardcode the first parameter of the bugchecks. Instead, I introduce a NpBugCheck macro and file identifiers
(their names conform to the existing name convention of the driver) so that, when bugchecking, we report as the
first parameter of the NPFS_FILE_SYSTEM bugcheck the file ID (in the high word) and the line (in the low word)
where the bugcheck was emitted.
See the MSDN article "Bug Check 0x25: NPFS_FILE_SYSTEM" - http://msdn.microsoft.com/en-us/library/windows/hardware/ff557436(v=vs.85).aspx
for more information.

Inspired from the existing ext2 driver.

Should be done for the other filesystems (FAT, NTFS, CDFS, Redirector, Mailslot, etc...).

svn path=/trunk/; revision=60051

21 files changed:
reactos/drivers/filesystems/npfs_new/cleanup.c
reactos/drivers/filesystems/npfs_new/close.c
reactos/drivers/filesystems/npfs_new/create.c
reactos/drivers/filesystems/npfs_new/datasup.c
reactos/drivers/filesystems/npfs_new/fileinfo.c
reactos/drivers/filesystems/npfs_new/fileobsup.c
reactos/drivers/filesystems/npfs_new/flushbuf.c
reactos/drivers/filesystems/npfs_new/fsctrl.c
reactos/drivers/filesystems/npfs_new/main.c
reactos/drivers/filesystems/npfs_new/npfs.h
reactos/drivers/filesystems/npfs_new/prefxsup.c
reactos/drivers/filesystems/npfs_new/read.c
reactos/drivers/filesystems/npfs_new/readsup.c
reactos/drivers/filesystems/npfs_new/secursup.c
reactos/drivers/filesystems/npfs_new/seinfo.c
reactos/drivers/filesystems/npfs_new/statesup.c
reactos/drivers/filesystems/npfs_new/strucsup.c
reactos/drivers/filesystems/npfs_new/volinfo.c
reactos/drivers/filesystems/npfs_new/waitsup.c
reactos/drivers/filesystems/npfs_new/write.c
reactos/drivers/filesystems/npfs_new/writesup.c

index ec0d22a..872e656 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_CLEANUP)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
index 1771df1..ce3b444 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_CLOSE)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
index 32606c4..0450f25 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_CREATE)
+
 /* FUNCTIONS ******************************************************************/
 
 VOID
index 5f8f739..830be84 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_DATASUP)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
index e17b195..e39feb9 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_FILEINFO)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
@@ -42,7 +45,7 @@ NpSetPipeInfo(IN PNP_FCB Fcb,
     {
         if (NamedPipeEnd != FILE_PIPE_SERVER_END)
         {
-            KeBugCheckEx(NPFS_FILE_SYSTEM, 0xA04EFu, NamedPipeEnd, 0, 0);
+            NpBugCheck(NamedPipeEnd, 0, 0);
         }
         ReadQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
         WriteQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
@@ -234,7 +237,7 @@ NpQueryNameInfo(IN PNP_CCB Ccb,
     if (*Length < NameLength)
     {
         Status = STATUS_BUFFER_OVERFLOW;
-        NameLength = *Length;
+        NameLength = (USHORT)*Length;
     }
     else
     {
index 25b2856..4bbe1f7 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_FILEOBSUP)
+
 /* FUNCTIONS ******************************************************************/
 
 NODE_TYPE_CODE
@@ -46,7 +49,7 @@ NpDecodeFileObject(IN PFILE_OBJECT FileObject,
                 return NPFS_NTC_CCB;
 
             default:
-                KeBugCheckEx(NPFS_FILE_SYSTEM, 0xB0108, Node->NodeType, 0, 0);
+                NpBugCheck(Node->NodeType, 0, 0);
                 break;
             }
     }
index 47d9a9a..8ac62bf 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_FLUSHBUF)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
index 40da826..9abcc4f 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_FSCTRL)
+
 /* GLOBALS ********************************************************************/
 
 IO_STATUS_BLOCK NpUserIoStatusBlock;
@@ -212,7 +215,7 @@ NpPeek(IN PDEVICE_OBJECT DeviceObject,
     {
         if (NamedPipeEnd != FILE_PIPE_SERVER_END)
         {
-            KeBugCheckEx(NPFS_FILE_SYSTEM, 0xD02E5, NamedPipeEnd, 0, 0);
+            NpBugCheck(NamedPipeEnd, 0, 0);
         }
 
         DataQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
@@ -357,7 +360,7 @@ NpTransceive(IN PDEVICE_OBJECT DeviceObject,
     {
         if (NamedPipeEnd != FILE_PIPE_SERVER_END)
         {
-            KeBugCheckEx(NPFS_FILE_SYSTEM, 0xD0538, NamedPipeEnd, 0, 0);
+            NpBugCheck(NamedPipeEnd, 0, 0);
         }
         ReadQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
         WriteQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
index eecc125..d903975 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_MAIN)
+
 /* GLOBALS ********************************************************************/
 
 PDEVICE_OBJECT NpfsDeviceObject;
index cd3bd9f..77934f2 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * PROJECT:     ReactOS Named Pipe FileSystem
+ * LICENSE:     BSD - See COPYING.ARM in the top level directory
+ * FILE:        drivers/filesystems/npfs/npfs.h
+ * PURPOSE:     Named Pipe FileSystem Header
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
 //
 // System Headers
 //
@@ -16,6 +26,9 @@
 #pragma warning(disable:4100)
 #endif
 
+
+/* TYPEDEFS & DEFINES *********************************************************/
+
 //
 // Pool Tags for NPFS (from pooltag.txt)
 //
 #define NPFS_WAIT_BLOCK_TAG     'NpFt'
 #define NPFS_WRITE_BLOCK_TAG    'NpFw'
 
+//
+// NPFS bugchecking support
+//
+// We define the NpBugCheck macro which triggers a NPFS_FILE_SYSTEM bugcheck
+// containing the source file ID number and the line where it was emitted, as
+// described in the MSDN article "Bug Check 0x25: NPFS_FILE_SYSTEM".
+//
+// The bugcheck emits 4 ULONGs; the first one is made, in its high word, by
+// the current source file ID and in its low word, by the line number; the
+// three other ones are user-defined.
+//
+// In order to avoid redefinition of the same file ID in different source files,
+// we gather all of them here, so that you will have to add (or remove) a new
+// one as soon as you add (or remove) a source file from the NPFS driver code.
+//
+// To use the NpBugCheck macro in a source file, define at its beginning
+// the constant NPFS_BUGCHECK_FILE_ID with one of the following file IDs,
+// then use the bugcheck macro wherever you want.
+//
+#define NPFS_BUGCHECK_CLEANUP   0x0001
+#define NPFS_BUGCHECK_CLOSE     0x0002
+#define NPFS_BUGCHECK_CREATE    0x0003
+#define NPFS_BUGCHECK_DATASUP   0x0004
+#define NPFS_BUGCHECK_FILEINFO  0x0005
+#define NPFS_BUGCHECK_FILEOBSUP 0x0006
+#define NPFS_BUGCHECK_FLUSHBUF  0x0007
+#define NPFS_BUGCHECK_FSCTRL    0x0008
+#define NPFS_BUGCHECK_MAIN      0x0009
+#define NPFS_BUGCHECK_PREFXSUP  0x000a
+#define NPFS_BUGCHECK_READ      0x000b
+#define NPFS_BUGCHECK_READSUP   0x000c
+#define NPFS_BUGCHECK_SECURSUP  0x000d
+#define NPFS_BUGCHECK_SEINFO    0x000e
+#define NPFS_BUGCHECK_STATESUP  0x000f
+#define NPFS_BUGCHECK_STRUCSUP  0x0010
+#define NPFS_BUGCHECK_VOLINFO   0x0011
+#define NPFS_BUGCHECK_WAITSUP   0x0012
+#define NPFS_BUGCHECK_WRITE     0x0013
+#define NPFS_BUGCHECK_WRITESUP  0x0014
+
+#define NpBugCheck(p1, p2, p3)                              \
+    KeBugCheckEx(NPFS_FILE_SYSTEM,                          \
+                 (NPFS_BUGCHECK_FILE_ID << 16) | __LINE__,  \
+                 (p1), (p2), (p3))
+
 //
 // Node Type Codes for NPFS
 //
@@ -263,6 +321,9 @@ typedef struct _NP_VCB
 
 extern PNP_VCB NpVcb;
 
+
+/* FUNCTIONS ******************************************************************/
+
 //
 // Functions to lock/unlock the global VCB lock
 //
@@ -600,3 +661,4 @@ NTAPI
 NpFsdQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject,
                             IN PIRP Irp);
 
+/* EOF */
index 595b9bd..dfb4c8b 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_PREFXSUP)
+
 /* FUNCTIONS ******************************************************************/
 
 PNP_FCB
@@ -25,7 +28,7 @@ NpFindPrefix(IN PUNICODE_STRING Name,
     Entry = RtlFindUnicodePrefix(&NpVcb->PrefixTable,
                                  Name,
                                  CaseInsensitiveIndex);
-    if (!Entry) KeBugCheckEx(NPFS_FILE_SYSTEM, 0x100065u, 0, 0, 0);
+    if (!Entry) NpBugCheck(0, 0, 0);
 
     Fcb = CONTAINING_RECORD(Entry, NP_FCB, PrefixTableEntry);
 
index 3e5b16e..4189868 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_READ)
+
 /* GLOBALS ********************************************************************/
 
 LONG NpSlowReadCalls;
index 482ea5b..ebba120 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_READSUP)
+
 /* FUNCTIONS ******************************************************************/
 
 IO_STATUS_BLOCK
index a087795..b9cde6d 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_SECURSUP)
+
 /* FUNCTIONS ******************************************************************/
 
 VOID
index 44adff1..b2c50a4 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_SEINFO)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
index a208b9f..3eb3b1e 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_STATESUP)
+
 /* FUNCTIONS ******************************************************************/
 
 VOID
@@ -170,7 +173,7 @@ NpSetDisconnectedPipeState(IN PNP_CCB Ccb,
             break;
 
         default:
-            KeBugCheckEx(NPFS_FILE_SYSTEM, 0x1603DD, Ccb->NamedPipeState, 0, 0);
+            NpBugCheck(Ccb->NamedPipeState, 0, 0);
             break;
     }
 
@@ -228,7 +231,7 @@ NpSetListeningPipeState(IN PNP_CCB Ccb,
             break;
 
         default:
-            KeBugCheckEx(NPFS_FILE_SYSTEM, 0x160133, Ccb->NamedPipeState, 0, 0);
+            NpBugCheck(Ccb->NamedPipeState, 0, 0);
             break;
     }
 
@@ -377,7 +380,7 @@ NpSetClosingPipeState(IN PNP_CCB Ccb,
             break;
 
         default:
-            KeBugCheckEx(NPFS_FILE_SYSTEM, 0x1602F9, Ccb->NamedPipeState, 0, 0);
+            NpBugCheck(Ccb->NamedPipeState, 0, 0);
             break;
     }
     return STATUS_SUCCESS;
index 9c13829..51f4565 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_STRUCSUP)
+
 /* GLOBALS ********************************************************************/
 
 #define UNIMPLEMENTED
@@ -67,7 +70,7 @@ NpDeleteFcb(IN PNP_FCB Fcb,
     PAGED_CODE();
 
     Dcb = Fcb->ParentDcb;
-    if (Fcb->CurrentInstances) KeBugCheckEx(NPFS_FILE_SYSTEM, 0x17025F, 0, 0, 0);
+    if (Fcb->CurrentInstances) NpBugCheck(0, 0, 0);
 
     NpCancelWaiter(&NpVcb->WaitQueue,
                    &Fcb->FullName,
@@ -169,7 +172,7 @@ NpCreateRootDcb(VOID)
 
     if (NpVcb->RootDcb)
     {
-        KeBugCheckEx(NPFS_FILE_SYSTEM, 0x1700F3, 0, 0, 0);
+        NpBugCheck(0, 0, 0);
     }
 
     NpVcb->RootDcb = ExAllocatePoolWithTag(PagedPool, sizeof(*Dcb), NPFS_DCB_TAG);
@@ -199,7 +202,7 @@ NpCreateRootDcb(VOID)
                                 &Dcb->FullName,
                                 &Dcb->PrefixTableEntry))
     {
-        KeBugCheckEx(NPFS_FILE_SYSTEM, 0x170128, 0, 0, 0);
+        NpBugCheck(0, 0, 0);
     }
 
     return STATUS_SUCCESS;
@@ -284,7 +287,7 @@ NpCreateFcb(IN PNP_DCB Dcb,
                                 &Fcb->FullName,
                                 &Fcb->PrefixTableEntry))
     {
-        KeBugCheckEx(NPFS_FILE_SYSTEM, 0x170222, 0, 0, 0);
+        NpBugCheck(0, 0, 0);
     }
 
     Fcb->NamedPipeConfiguration = NamedPipeConfiguration;
index 792c8e2..1985ff6 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_VOLINFO)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS
@@ -33,7 +36,7 @@ NpQueryFsVolumeInfo(IN PVOID Buffer,
 
     if (NameLength < 18)
     {
-        NameLength = *Length;
+        NameLength = (USHORT)*Length;
         Status = STATUS_BUFFER_OVERFLOW;
     }
     else
@@ -96,7 +99,7 @@ NpQueryFsAttributeInfo(IN PVOID Buffer,
     NTSTATUS Status;
     USHORT NameLength;
 
-    NameLength = *Length - 12;
+    NameLength = (USHORT)(*Length - 12);
     if (NameLength < 8)
     {
         *Length = 0;
index b950795..52d67f9 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_WAITSUP)
+
 /* FUNCTIONS ******************************************************************/
 
 VOID
index b9d9293..b1f65ed 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_WRITE)
+
 /* GLOBALS ********************************************************************/
 
 LONG NpSlowWriteCalls;
index 1fd7d4d..29c3507 100644 (file)
@@ -10,6 +10,9 @@
 
 #include "npfs.h"
 
+// File ID number for NPFS bugchecking support
+#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_WRITESUP)
+
 /* FUNCTIONS ******************************************************************/
 
 NTSTATUS