Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.4 KiB

  1. /*
  2. * SERVICE.C
  3. *
  4. *
  5. * DRIVEARB.DLL - Shared Drive Aribiter for shared disks and libraries
  6. * - inter-machine sharing client
  7. * - inter-app sharing service
  8. *
  9. * Author: ErvinP
  10. *
  11. * (c) 2000 Microsoft Corporation
  12. *
  13. */
  14. #include <windows.h>
  15. #include <stdlib.h>
  16. #include <wtypes.h>
  17. #include <dlmhdr.h> // BUGBUG - get a common DLM header from Cluster team
  18. #include <drivearb.h>
  19. #include "internal.h"
  20. HANDLE __stdcall RegisterSharedDrive(LPSTR driveName)
  21. {
  22. driveContext *drive;
  23. WaitForSingleObject(g_hSharedGlobalMutex, INFINITE);
  24. drive = NewDriveContext(driveName);
  25. if (drive){
  26. drive->state = DRIVESTATE_UNAVAILABLE_LOCALLY;
  27. }
  28. ReleaseMutex(g_hSharedGlobalMutex);
  29. return (HANDLE)drive;
  30. }
  31. BOOL __stdcall UnRegisterSharedDrive(HANDLE hDrive)
  32. {
  33. driveContext *drive = (driveContext *)hDrive;
  34. BOOL ok = FALSE;
  35. WaitForSingleObject(g_hSharedGlobalMutex, INFINITE);
  36. if (drive->sig == DRIVEARB_SIG){ // sanity check
  37. if (drive->sessionReferenceCount == 0){
  38. FreeDriveContext(drive);
  39. ok = TRUE;
  40. }
  41. else {
  42. // BUGBUG FINISH - forcefully invalidate handles, etc.
  43. ASSERT(drive->sessionReferenceCount == 0);
  44. }
  45. }
  46. else {
  47. ASSERT(drive->sig == DRIVEARB_SIG);
  48. }
  49. ReleaseMutex(g_hSharedGlobalMutex);
  50. return ok;
  51. }