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.

145 lines
4.3 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 = _T("grovel.ini");
  15. static const _TCHAR *disks_ini_section = _T("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. _TCHAR *ini_file_partition_path = new _TCHAR[SIS_CSDIR_STRING_NCHARS
  36. + _tcslen(disks_ini_filename) + MAX_PATH];
  37. _tcscpy(ini_file_partition_path, drive_name);
  38. int drive_name_length = _tcslen(drive_name);
  39. _tcscpy(&ini_file_partition_path[drive_name_length - 1], SIS_CSDIR_STRING);
  40. _tcscat(ini_file_partition_path, 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. };
  71. for (int index = 0; index < registry_entry_count; index++)
  72. {
  73. this->registry_entries[index] = registry_entries[index];
  74. }
  75. ini_file_partition_path = new _TCHAR[SIS_CSDIR_STRING_NCHARS
  76. + _tcslen(disks_ini_filename) + MAX_PATH];
  77. _tcscpy(ini_file_partition_path, drive_name);
  78. int drive_name_length = _tcslen(drive_name);
  79. _tcscpy(&ini_file_partition_path[drive_name_length - 1], SIS_CSDIR_STRING);
  80. _tcscat(ini_file_partition_path, disks_ini_filename);
  81. IniFile::read(ini_file_partition_path, disks_ini_section,
  82. registry_entry_count, registry_entries);
  83. if (backup_interval > 0)
  84. {
  85. backup((void *)this);
  86. }
  87. }
  88. WriteDiskInformation::~WriteDiskInformation()
  89. {
  90. ASSERT(this != 0);
  91. ASSERT(backup_interval >= 0);
  92. ASSERT(ini_file_partition_path != 0);
  93. backup((void *)this);
  94. delete[] ini_file_partition_path;
  95. ini_file_partition_path = 0;
  96. }
  97. void
  98. WriteDiskInformation::backup(
  99. void *context)
  100. {
  101. ASSERT(context != 0);
  102. unsigned int invokation_time = GET_TICK_COUNT();
  103. WriteDiskInformation *me = (WriteDiskInformation *)context;
  104. ASSERT(me->backup_interval >= 0);
  105. ASSERT(me->ini_file_partition_path != 0);
  106. bool ini_file_overwrite_ok =
  107. IniFile::overwrite(me->ini_file_partition_path, disks_ini_section,
  108. registry_entry_count, me->registry_entries);
  109. if (!ini_file_overwrite_ok)
  110. {
  111. PRINT_DEBUG_MSG((_T("GROVELER: IniFile::overwrite() failed\n")));
  112. }
  113. event_timer.schedule(invokation_time + me->backup_interval,
  114. context, backup);
  115. }