Leaked source code of windows server 2003
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.

161 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. diskinfo.cpp
  5. Abstract:
  6. SIS Groveler disk information class
  7. Authors:
  8. John Douceur, 1998
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include "all.hxx"
  14. static const _TCHAR disks_ini_filename[] = L"grovel.ini";
  15. static const _TCHAR disks_ini_section[] = L"Disk Info";
  16. ReadDiskInformation::ReadDiskInformation(
  17. const _TCHAR *drive_name)
  18. {
  19. ASSERT(this != 0);
  20. EntrySpec registry_entries[registry_entry_count] =
  21. {
  22. {_T("minimum merge file size"), entry_int, _T("32768"), &min_file_size},
  23. {_T("minimum merge file age"), entry_int, _T("0"), &min_file_age},
  24. {_T("enable groveling"), entry_bool, _T("1"), &enable_groveling},
  25. {_T("error retry log extraction"), entry_bool, _T("1"), &error_retry_log_extraction},
  26. {_T("error retry groveling"), entry_bool, _T("1"), &error_retry_groveling},
  27. {_T("merge compressed files"), entry_bool, _T("1"), &allow_compressed_files},
  28. {_T("merge encrypted files"), entry_bool, _T("0"), &allow_encrypted_files},
  29. {_T("merge hidden files"), entry_bool, _T("1"), &allow_hidden_files},
  30. {_T("merge offline files"), entry_bool, _T("0"), &allow_offline_files},
  31. {_T("merge temporary files"), entry_bool, _T("0"), &allow_temporary_files},
  32. {_T("base USN log size"), entry_int64, _T("1048576"), &base_usn_log_size},
  33. {_T("max USN log size"), entry_int64, _T("16777216"), &max_usn_log_size}
  34. };
  35. int bLen = _tcslen(disks_ini_filename) + _tcslen(drive_name) + SIS_CSDIR_STRING_NCHARS + (sizeof(_TCHAR)*2);
  36. _TCHAR *ini_file_partition_path = new _TCHAR[bLen];
  37. (void)StringCchCopy(ini_file_partition_path, bLen, drive_name);
  38. TrimTrailingChar(ini_file_partition_path,L'\\');
  39. (void)StringCchCat(ini_file_partition_path, bLen, SIS_CSDIR_STRING);
  40. (void)StringCchCat(ini_file_partition_path, bLen, disks_ini_filename);
  41. IniFile::read(ini_file_partition_path, disks_ini_section,
  42. registry_entry_count, registry_entries);
  43. #if WRITE_ALL_PARAMETERS
  44. bool ini_file_overwrite_ok =
  45. IniFile::overwrite(ini_file_partition_path, disks_ini_section,
  46. registry_entry_count, registry_entries);
  47. if (!ini_file_overwrite_ok)
  48. {
  49. PRINT_DEBUG_MSG((_T("GROVELER: IniFile::overwrite() failed\n")));
  50. }
  51. #endif // WRITE_ALL_PARAMETERS
  52. ASSERT(ini_file_partition_path != 0);
  53. delete[] ini_file_partition_path;
  54. ini_file_partition_path = 0;
  55. }
  56. WriteDiskInformation::WriteDiskInformation(
  57. const _TCHAR *drive_name,
  58. int backup_interval)
  59. {
  60. ASSERT(this != 0);
  61. ASSERT(backup_interval >= 0);
  62. this->backup_interval = backup_interval;
  63. EntrySpec registry_entries[registry_entry_count] =
  64. {
  65. {_T("hash read time estimate"), entry_double, _T("0.0"), &partition_hash_read_time_estimate},
  66. {_T("compare read time estimate"), entry_double, _T("0.0"), &partition_compare_read_time_estimate},
  67. {_T("mean file size"), entry_double, _T("65536.0"), &mean_file_size},
  68. {_T("read time confidence"), entry_double, _T("0.0"), &read_time_confidence},
  69. {_T("volume serial number"), entry_int, _T("0"), &volume_serial_number},
  70. {_T("GrovelAllPaths State"), entry_int, _T("1"), &grovelAllPathsState}
  71. };
  72. for (int index = 0; index < registry_entry_count; index++)
  73. {
  74. this->registry_entries[index] = registry_entries[index];
  75. }
  76. int bLen = _tcslen(disks_ini_filename) + _tcslen(drive_name) + SIS_CSDIR_STRING_NCHARS + (sizeof(_TCHAR)*2);
  77. ini_file_partition_path = new _TCHAR[bLen];
  78. (void)StringCchCopy(ini_file_partition_path, bLen, drive_name);
  79. TrimTrailingChar(ini_file_partition_path,L'\\');
  80. (void)StringCchCat(ini_file_partition_path, bLen, SIS_CSDIR_STRING);
  81. (void)StringCchCat(ini_file_partition_path, bLen, disks_ini_filename);
  82. IniFile::read(ini_file_partition_path, disks_ini_section,
  83. registry_entry_count, registry_entries);
  84. if (backup_interval > 0)
  85. {
  86. backup((void *)this);
  87. }
  88. }
  89. WriteDiskInformation::~WriteDiskInformation()
  90. {
  91. ASSERT(this != 0);
  92. ASSERT(backup_interval >= 0);
  93. ASSERT(ini_file_partition_path != 0);
  94. backup((void *)this);
  95. delete[] ini_file_partition_path;
  96. ini_file_partition_path = 0;
  97. }
  98. void
  99. WriteDiskInformation::flush()
  100. {
  101. bool ini_file_overwrite_ok =
  102. IniFile::overwrite(ini_file_partition_path, disks_ini_section,
  103. registry_entry_count, registry_entries);
  104. if (!ini_file_overwrite_ok)
  105. {
  106. PRINT_DEBUG_MSG((_T("GROVELER: IniFile::overwrite() failed\n")));
  107. }
  108. }
  109. void
  110. WriteDiskInformation::backup(
  111. void *context)
  112. {
  113. ASSERT(context != 0);
  114. unsigned int invokation_time = GET_TICK_COUNT();
  115. WriteDiskInformation *me = (WriteDiskInformation *)context;
  116. ASSERT(me->backup_interval >= 0);
  117. ASSERT(me->ini_file_partition_path != 0);
  118. bool ini_file_overwrite_ok =
  119. IniFile::overwrite(me->ini_file_partition_path, disks_ini_section,
  120. registry_entry_count, me->registry_entries);
  121. if (!ini_file_overwrite_ok)
  122. {
  123. PRINT_DEBUG_MSG((_T("GROVELER: IniFile::overwrite() failed\n")));
  124. }
  125. event_timer.schedule(invokation_time + me->backup_interval,
  126. context, backup);
  127. }