[NPFS_NEW]

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
This commit is contained in:
Hermès Bélusca-Maïto 2013-09-12 00:05:54 +00:00
parent 9a9573505b
commit 479489298b
21 changed files with 137 additions and 15 deletions

View 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

View 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

View 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

View 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

View 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
{

View 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;
}
}

View 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

View 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];

View 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;

View 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)
//
@ -45,6 +58,51 @@
#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 */

View 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);

View 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;

View 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

View 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

View 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

View 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;

View 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;

View 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;

View 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

View 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;

View 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