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.

127 lines
2.4 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation
  4. //
  5. // File: dfsinit.c
  6. //
  7. // Contents: Code to force dfs volume initialization and validation
  8. //
  9. // Classes:
  10. //
  11. // Functions: main
  12. //
  13. // History: March 24, 1994 Milans Created
  14. //
  15. //-----------------------------------------------------------------------------
  16. #include <stdio.h>
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <dfsfsctl.h>
  20. NTSTATUS
  21. DfsOpen(
  22. IN OUT PHANDLE DfsHandle,
  23. IN PUNICODE_STRING DfsName OPTIONAL);
  24. NTSTATUS
  25. DfsInitLocalPartitions();
  26. //+----------------------------------------------------------------------------
  27. //
  28. // Function: main
  29. //
  30. // Synopsis:
  31. //
  32. // Arguments:
  33. //
  34. // Returns:
  35. //
  36. //-----------------------------------------------------------------------------
  37. void _cdecl main(
  38. int argc,
  39. char *argv[])
  40. {
  41. NTSTATUS Status;
  42. Status = DfsInitLocalPartitions();
  43. }
  44. NTSTATUS
  45. DfsOpen(
  46. IN OUT PHANDLE DfsHandle,
  47. IN PUNICODE_STRING DfsName OPTIONAL
  48. )
  49. {
  50. NTSTATUS status;
  51. OBJECT_ATTRIBUTES objectAttributes;
  52. IO_STATUS_BLOCK ioStatus;
  53. UNICODE_STRING LocalDfsName;
  54. RtlInitUnicodeString( &LocalDfsName, DFS_SERVER_NAME );
  55. InitializeObjectAttributes(
  56. &objectAttributes,
  57. &LocalDfsName,
  58. OBJ_CASE_INSENSITIVE,
  59. NULL,
  60. NULL
  61. );
  62. status = NtCreateFile(
  63. DfsHandle,
  64. SYNCHRONIZE | FILE_WRITE_DATA,
  65. &objectAttributes,
  66. &ioStatus,
  67. NULL,
  68. FILE_ATTRIBUTE_NORMAL,
  69. FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  70. FILE_OPEN_IF,
  71. FILE_CREATE_TREE_CONNECTION | FILE_SYNCHRONOUS_IO_NONALERT,
  72. NULL,
  73. 0
  74. );
  75. if (NT_SUCCESS(status))
  76. status = ioStatus.Status;
  77. return status;
  78. }
  79. NTSTATUS
  80. DfsInitLocalPartitions()
  81. {
  82. NTSTATUS status;
  83. HANDLE dfsHandle;
  84. IO_STATUS_BLOCK ioStatus;
  85. WCHAR wszBuffer[128];
  86. status = DfsOpen(&dfsHandle, NULL);
  87. if(NT_SUCCESS(status)) {
  88. status = NtFsControlFile(
  89. dfsHandle,
  90. NULL, // Event,
  91. NULL, // ApcRoutine,
  92. NULL, // ApcContext,
  93. &ioStatus,
  94. FSCTL_DFS_INIT_LOCAL_PARTITIONS,
  95. NULL,
  96. 0,
  97. NULL,
  98. 0);
  99. NtClose( dfsHandle );
  100. }
  101. return( status );
  102. }