Skip to content

Commit

Permalink
add IOCTL_SET_DEBUG_MODE
Browse files Browse the repository at this point in the history
git-svn-id: http://dokan.googlecode.com/svn/trunk@118 53ea604a-054e-0410-8546-456bafaea6b0
  • Loading branch information
asakaw committed Mar 22, 2010
1 parent ffa039b commit 54550b9
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sys/create.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ Return Value:

if (fileObject->FileName.Length > 0 &&
fileObject->FileName.Buffer[0] == '\\') {
DbgPrint(" when RelatedFileObject is specified, the file name should be relative path\n");
DDbgPrint(" when RelatedFileObject is specified, the file name should be relative path\n");
status = STATUS_OBJECT_NAME_INVALID;
__leave;
}
Expand Down
11 changes: 10 additions & 1 deletion sys/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ GlobalDeviceControl(
case IOCTL_SERVICE_WAIT:
status = DokanRegisterPendingIrpForService(DeviceObject, Irp);
break;
case IOCTL_SET_DEBUG_MODE:
{
if (irpSp->Parameters.DeviceIoControl.InputBufferLength >= sizeof(ULONG)) {
g_Debug = *(ULONG*)Irp->AssociatedIrp.SystemBuffer;
status = STATUS_SUCCESS;
}
DDbgPrint(" IOCTL_SET_DEBUG_MODE: %d\n", g_Debug);
}
break;
case IOCTL_TEST:
if (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= sizeof(ULONG)) {
*(ULONG*)Irp->AssociatedIrp.SystemBuffer = DOKAN_VERSION;
Expand Down Expand Up @@ -447,7 +456,7 @@ Return Value:
break;
case IOCTL_REDIR_QUERY_PATH:
{
DbgPrint(" IOCTL_REDIR_QUERY_PATH\n");
DDbgPrint(" IOCTL_REDIR_QUERY_PATH\n");
}
break;
default:
Expand Down
6 changes: 4 additions & 2 deletions sys/dokan.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#endif


ULONG g_Debug = 1;

#if _WIN32_WINNT < 0x0501
PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS DokanFsRtlTeardownPerStreamContexts;
#endif
Expand Down Expand Up @@ -452,12 +454,12 @@ PrintIdType(
__in VOID* Id)
{
if (Id == NULL) {
DbgPrint(" IdType = NULL\n");
DDbgPrint(" IdType = NULL\n");
return;
}
switch (GetIdentifierType(Id)) {
case DGL:
DbgPrint(" IdType = DGL\n");
DDbgPrint(" IdType = DGL\n");
break;
case DCB:
DDbgPrint(" IdType = DCB\n");
Expand Down
9 changes: 6 additions & 3 deletions sys/dokan.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
//

int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
extern ULONG g_Debug;

#define NTDEVICE_NAME_STRING L"\\Device\\dokan"
#define SYMBOLIC_NAME_STRING L"\\DosDevices\\Global\\dokan"
Expand All @@ -63,13 +64,15 @@ int __cdecl swprintf(wchar_t *, const wchar_t *, ...);
#define USE_DBGPRINT 1

#ifdef USE_DBGPRINT
#define DDbgPrint(...) DbgPrint(__VA_ARGS__)
#define DDbgPrint(...) \
if (g_Debug) { DbgPrint("[DokanFS] " __VA_ARGS__); }
#else
#if _WIN32_WINNT >= 0x0501
#define DDbgPrint(...) \
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL, __VA_ARGS__ ))
if (g_Debug) { KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL, "[DokanFS] " __VA_ARGS__ )); }
#else
#define DDbgPrint(...) KdPrint((__VA_ARGS__))
#define DDbgPrint(...) \
if (g_Debug) { KdPrint(("[DokanFS] " __VA_ARGS__)); }
#endif
#endif

Expand Down
6 changes: 3 additions & 3 deletions sys/fileinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,19 +539,19 @@ DokanCompleteSetInformation(
if (!MmFlushImageSection(
&fcb->SectionObjectPointers,
MmFlushForDelete)) {
DbgPrint(" Cannot delete user mapped image\n");
DDbgPrint(" Cannot delete user mapped image\n");
status = STATUS_CANNOT_DELETE;
} else {
ccb->Flags |= DOKAN_DELETE_ON_CLOSE;
fcb->Flags |= DOKAN_DELETE_ON_CLOSE;
DbgPrint(" FileObject->DeletePending = TRUE\n");
DDbgPrint(" FileObject->DeletePending = TRUE\n");
IrpEntry->FileObject->DeletePending = TRUE;
}

} else {
ccb->Flags &= ~DOKAN_DELETE_ON_CLOSE;
fcb->Flags &= ~DOKAN_DELETE_ON_CLOSE;
DbgPrint(" FileObject->DeletePending = FALSE\n");
DDbgPrint(" FileObject->DeletePending = FALSE\n");
IrpEntry->FileObject->DeletePending = FALSE;
}
}
Expand Down
4 changes: 2 additions & 2 deletions sys/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ DokanCreateDiskDevice(
if (DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) {
status = FsRtlRegisterUncProvider(&(dcb->MupHandle), &deviceName, FALSE);
if (NT_SUCCESS(status)) {
DbgPrint(" FsRtlRegisterUncProvider success\n");
DDbgPrint(" FsRtlRegisterUncProvider success\n");
} else {
DbgPrint(" FsRtlRegisterUncProvider failed: 0x%x\n", status);
DDbgPrint(" FsRtlRegisterUncProvider failed: 0x%x\n", status);
dcb->MupHandle = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion sys/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ DokanDispatchLock(
if (irpSp->Parameters.LockControl.Length != NULL) {
eventContext->Lock.Length.QuadPart = irpSp->Parameters.LockControl.Length->QuadPart;
} else {
DbgPrint(" LockControl.Length = NULL\n");
DDbgPrint(" LockControl.Length = NULL\n");
}
eventContext->Lock.Key = irpSp->Parameters.LockControl.Key;

Expand Down
2 changes: 1 addition & 1 deletion sys/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ NotificationThread(

waitBlock = ExAllocatePool(sizeof(KWAIT_BLOCK) * 5);
if (waitBlock == NULL) {
DbgPrint(" Can't allocate WAIT_BLOCK\n");
DDbgPrint(" Can't allocate WAIT_BLOCK\n");
return;
}
events[0] = &Dcb->ReleaseEvent;
Expand Down
4 changes: 2 additions & 2 deletions sys/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ with this program. If not, see <http://www.gnu.org/licenses/>.

#include "devioctl.h"

#define DOKAN_VERSION 0x0000186
#define DOKAN_VERSION 0x0000187

#define EVENT_CONTEXT_MAX_SIZE (1024*32)

#define IOCTL_TEST \
CTL_CODE( FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS )

#define IOCTL_UNREGFS \
#define IOCTL_SET_DEBUG_MODE \
CTL_CODE( FILE_DEVICE_UNKNOWN, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS )

#define IOCTL_EVENT_WAIT \
Expand Down
2 changes: 1 addition & 1 deletion sys/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DokanUnmount(
// set drive letter
eventContext->Flags = Dcb->Mounted;

DbgPrint(" Send Unmount to Service : %wc\n", Dcb->Mounted);
DDbgPrint(" Send Unmount to Service : %wc\n", Dcb->Mounted);

DokanEventNotification(&Dcb->Global->NotifyService, eventContext);

Expand Down

0 comments on commit 54550b9

Please sign in to comment.