Esempio n. 1
0
int Unmount(LPCWSTR MountPoint, BOOL ForceUnmount) {
  int status = EXIT_SUCCESS;
  DOKAN_CONTROL control;
  ZeroMemory(&control, sizeof(DOKAN_CONTROL));

  if (wcslen(MountPoint) == 1 && L'0' <= MountPoint[0] &&
      MountPoint[0] <= L'9') {
    control.Type = DOKAN_CONTROL_LIST;
    control.Option = MountPoint[0] - L'0';
    DokanMountControl(&control);

    if (control.Status != DOKAN_CONTROL_SUCCESS ||
        (control.Status == DOKAN_CONTROL_SUCCESS &&
         !DokanRemoveMountPoint(control.MountPoint))) {
      fwprintf(stderr, L"Mount entry %d not found\n", control.Option);
      status = EXIT_FAILURE;
    }
  } else if (ForceUnmount) {
    control.Type = DOKAN_CONTROL_UNMOUNT;
    control.Option = DOKAN_CONTROL_OPTION_FORCE_UNMOUNT;
    wcscpy_s(control.MountPoint, sizeof(control.MountPoint) / sizeof(WCHAR),
             MountPoint);
    DokanMountControl(&control);

    if (control.Status != DOKAN_CONTROL_SUCCESS)
      status = EXIT_FAILURE;

    fwprintf(stderr, L"Unmount status %d - %s\tn", status, MountPoint);

  } else if (!DokanRemoveMountPoint(MountPoint))
    status = EXIT_FAILURE;

  fwprintf(stderr, L"Unmount status = %d\n", status);
  return status;
}
Esempio n. 2
0
BOOL DOKANAPI
DokanUnmount(
	WCHAR	DriveLetter)
{
	WCHAR mountPoint[] = L"M:\\";
	mountPoint[0] = DriveLetter;
	return DokanRemoveMountPoint(mountPoint);
}
Esempio n. 3
0
int Unmount(LPCWSTR MountPoint) {
  int status = EXIT_SUCCESS;

  if (!DokanRemoveMountPoint(MountPoint)) {
    status = EXIT_FAILURE;
  }

  fwprintf(stdout, L"Unmount status = %d\n", status);
  return status;
}
Esempio n. 4
0
int Unmount(LPCWSTR MountPoint, BOOL ForceUnmount) {
  int status = EXIT_SUCCESS;

  UNREFERENCED_PARAMETER(ForceUnmount);

  if (!DokanRemoveMountPoint(MountPoint)) {
    status = EXIT_FAILURE;
  }

  fwprintf(stdout, L"Unmount status = %d\n", status);
  return status;
}
Esempio n. 5
0
/*
 * Class:     net_decasdev_dokan_Dokan
 * Method:    removeMountPoint
 * Signature: (Ljava/lang/String;)J
 */
JNIEXPORT jboolean JNICALL Java_net_decasdev_dokan_Dokan_removeMountPoint
( JNIEnv* env, jclass, jstring jMountPoint ) {
	int len = env->GetStringLength( jMountPoint );
	const jchar* chars = env->GetStringChars( jMountPoint, NULL );
	wchar_t* wsz = new wchar_t[len+1];
	memcpy( wsz, chars, len*2 );
	wsz[len] = 0;
	BOOL result = DokanRemoveMountPoint( wsz );
	env->ReleaseStringChars( jMountPoint, chars );
	env->DeleteGlobalRef( gOperations );
	gOperations = NULL;
	return result;
}
Esempio n. 6
0
int Unmount(LPCWSTR	MountPoint, BOOL ForceUnmount)
{
	int status = 0;
	DOKAN_CONTROL control;
	ZeroMemory(&control, sizeof(DOKAN_CONTROL));

	if (wcslen(MountPoint) == 1 && L'0' <= MountPoint[0] && MountPoint[0] <= L'9') {
		control.Type = DOKAN_CONTROL_LIST;
		control.Option = MountPoint[0] - L'0';
		DokanMountControl(&control);

		if (control.Status == DOKAN_CONTROL_SUCCESS) {
			status = DokanRemoveMountPoint(control.MountPoint);
		} else {
			fwprintf(stderr, L"Mount entry %d not found\n", control.Option);
			status = -1;
		}
	} else if (ForceUnmount) {
		control.Type = DOKAN_CONTROL_UNMOUNT;
		control.Option = DOKAN_CONTROL_OPTION_FORCE_UNMOUNT;
		wcscpy_s(control.MountPoint, sizeof(control.MountPoint) / sizeof(WCHAR), MountPoint);
		DokanMountControl(&control);

		if (control.Status == DOKAN_CONTROL_SUCCESS) {
			fwprintf(stderr, L"Unmount success: %s", MountPoint);
			status = 0;
		} else {
			fwprintf(stderr, L"Unmount failed: %s", MountPoint);
			status = -1;
		}

	} else {
		status = DokanRemoveMountPoint(MountPoint);
	}

	fwprintf(stderr, L"Unmount status = %d\n", status);
	return status;
}
Esempio n. 7
0
BOOL WINAPI DllMain(
	HINSTANCE	Instance,
	DWORD		Reason,
	LPVOID		Reserved)
{
    UNREFERENCED_PARAMETER(Reserved);
    UNREFERENCED_PARAMETER(Instance);

	switch(Reason) {
		case DLL_PROCESS_ATTACH:
			{
#if _MSC_VER < 1300
				InitializeCriticalSection(&g_InstanceCriticalSection);
#else
				InitializeCriticalSectionAndSpinCount(
					&g_InstanceCriticalSection, 0x80000400);
#endif
				
				InitializeListHead(&g_InstanceList);
			}
			break;			
		case DLL_PROCESS_DETACH:
			{
				EnterCriticalSection(&g_InstanceCriticalSection);

				while(!IsListEmpty(&g_InstanceList)) {
					PLIST_ENTRY entry = RemoveHeadList(&g_InstanceList);
					PDOKAN_INSTANCE instance =
						CONTAINING_RECORD(entry, DOKAN_INSTANCE, ListEntry);
					
					DokanRemoveMountPoint(instance->MountPoint);
					free(instance);
				}

				LeaveCriticalSection(&g_InstanceCriticalSection);
				DeleteCriticalSection(&g_InstanceCriticalSection);
			}
			break;
	}
	return TRUE;
}
Esempio n. 8
0
	void WINBTRFSLIB_API terminate()
	{
		cleanUp();
		DokanRemoveMountPoint(volumeInfo.mountPoint); // DokanUnmount only allows drive letters
		exit(0);
	}