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.

103 lines
2.5 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1995, Microsoft Corporation
  4. //
  5. // File: upgrade.cxx
  6. //
  7. // Contents: Code to handle version upgrades of Dfs Volume Objects
  8. //
  9. // Classes: None
  10. //
  11. // Functions: CDfsVolume::UpgradeObject
  12. //
  13. // History: May 15, 1995 Milans created
  14. //
  15. //-----------------------------------------------------------------------------
  16. #include "headers.hxx"
  17. #pragma hdrstop
  18. #include <dfsmrshl.h>
  19. #include "cdfsvol.hxx"
  20. #include "marshal.hxx"
  21. #include "recon.hxx"
  22. #include "svclist.hxx"
  23. //+----------------------------------------------------------------------------
  24. //
  25. // Function: CDfsVolume::UpgradeObject
  26. //
  27. // Synopsis: This routine is called everytime a volume object is loaded
  28. // and takes care of any version upgrades that need to be done.
  29. //
  30. // Arguments: None
  31. //
  32. // Returns: ERROR_SUCCESS if successfully upgraded object.
  33. //
  34. // Error code from property operation if unable to upgrade object
  35. //
  36. //-----------------------------------------------------------------------------
  37. DWORD
  38. CDfsVolume::UpgradeObject()
  39. {
  40. DWORD dwErr;
  41. DWORD dwCurrentVersion;
  42. BOOLEAN fUpgraded = FALSE;
  43. IDfsVolInlineDebOut((DEB_TRACE, "CDfsVolume::UpgradeObject()\n"));
  44. dwErr = GetVersion(&dwCurrentVersion);
  45. if (dwErr == ERROR_SUCCESS) {
  46. //
  47. // Version 1 had the name of the current machine included in the
  48. // ServiceList. This prevented Dfs from working when the machine got
  49. // renamed. We upgrade by simply reading in the old service list,
  50. // and saving it out again. The save process will replace the local
  51. // machine name with a ".". See CDfsServiceList::Serialize().
  52. //
  53. if (dwCurrentVersion == 1) {
  54. CDfsServiceList dfsSvcList;
  55. dwErr = dfsSvcList.InitializeServiceList(_pStorage);
  56. if (dwErr == ERROR_SUCCESS) {
  57. dwErr = dfsSvcList.SerializeSvcList();
  58. if (dwErr == ERROR_SUCCESS) {
  59. dwErr = dfsSvcList.SetServiceListProperty( FALSE );
  60. }
  61. }
  62. fUpgraded = (dwErr == ERROR_SUCCESS);
  63. }
  64. }
  65. //
  66. // If an upgrade was needed and it succeeded, then update the version
  67. // number.
  68. //
  69. if ((dwErr == ERROR_SUCCESS) && fUpgraded) {
  70. (VOID) SetVersion( FALSE );
  71. }
  72. IDfsVolInlineDebOut((DEB_TRACE, "CDfsVolume::UpgradeObject() exit\n"));
  73. return( dwErr );
  74. }