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.

133 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. hardlink.h
  5. Abstract:
  6. The class that manages hardlinks for one volume. Assumes one class object
  7. will be created per volume.
  8. Author:
  9. Stefan R. Steiner [ssteiner] 3-30-2000
  10. Revision History:
  11. --*/
  12. #ifndef __H_HARDLINK_
  13. #define __H_HARDLINK_
  14. #include "extattr.h"
  15. //
  16. // Structure is defined to reduce the amount of space required
  17. // to store the file names in the hard-link linked-list with
  18. // the assumption that a number of hard-linked files exist in
  19. // a directory. Uses CBsString ref counting.
  20. //
  21. struct SFsdHLFileName
  22. {
  23. CBsString cwsDirPath;
  24. CBsString cwsFileName;
  25. };
  26. //
  27. // Manages one set of hard-linked files
  28. //
  29. class CFsdHardLinkListEntry
  30. {
  31. public:
  32. // Create link entry and add the first file name
  33. CFsdHardLinkListEntry(
  34. IN const CBsString& cwsDirPath,
  35. IN const CBsString& cwsFileName,
  36. IN WIN32_FILE_ATTRIBUTE_DATA *psFileAttributeData,
  37. IN SFileExtendedInfo *psExtendedInfo
  38. ) : m_sFileAttributeData( *psFileAttributeData ),
  39. m_sExtendedInfo( *psExtendedInfo )
  40. {
  41. AddFile( cwsDirPath, cwsFileName );
  42. }
  43. virtual ~CFsdHardLinkListEntry() {}
  44. // Adds an additional file name to the link
  45. VOID AddFile(
  46. IN const CBsString& cwsDirPath,
  47. IN const CBsString& cwsFileName
  48. );
  49. inline VOID GetAttributes(
  50. OUT WIN32_FILE_ATTRIBUTE_DATA *psFileAttribData,
  51. OUT SFileExtendedInfo *psExtInfo
  52. )
  53. {
  54. *psFileAttribData = m_sFileAttributeData;
  55. *psExtInfo = m_sExtendedInfo;
  56. }
  57. VOID PrintEntry(
  58. IN FILE *fpOut,
  59. IN INT cVolMountPointOffset
  60. );
  61. CVssDLList< SFsdHLFileName > m_cFilesLinkedTogetherList;
  62. private:
  63. WIN32_FILE_ATTRIBUTE_DATA m_sFileAttributeData;
  64. SFileExtendedInfo m_sExtendedInfo;
  65. };
  66. typedef TBsHashMap< ULONGLONG, CFsdHardLinkListEntry * > FSD_HARD_LINK_LIST;
  67. //
  68. // Manages all of the hard-link files in one volume
  69. //
  70. class CFsdHardLinkManager
  71. {
  72. public:
  73. CFsdHardLinkManager(
  74. IN CDumpParameters *pcParams,
  75. IN INT cVolMountPointOffset
  76. ) : m_pcParams( pcParams ),
  77. m_cVolMountPointOffset( cVolMountPointOffset ),
  78. m_cHardLinkFilesList( BSHASHMAP_HUGE) {}
  79. virtual ~CFsdHardLinkManager();
  80. // Dumps all hardlink information out to dump file
  81. VOID PrintHardLinkInfo();
  82. // Looks to see if the hardlink is already in the list, if
  83. // so, adds the file name to the list
  84. BOOL IsHardLinkInList(
  85. IN ULONGLONG ullFileIndex,
  86. IN const CBsString& cwsDirPath,
  87. IN const CBsString& cwsFileName,
  88. OUT WIN32_FILE_ATTRIBUTE_DATA *psFileAttributeData,
  89. OUT SFileExtendedInfo *psExtendedInfo
  90. );
  91. // Adds a new link to the list
  92. VOID AddHardLinkToList(
  93. IN ULONGLONG ullFileIndex,
  94. IN const CBsString& cwsDirPath,
  95. IN const CBsString& cwsFileName,
  96. IN WIN32_FILE_ATTRIBUTE_DATA *psFileAttributeData,
  97. IN SFileExtendedInfo *psExtendedInfo
  98. );
  99. private:
  100. CDumpParameters *m_pcParams;
  101. INT m_cVolMountPointOffset;
  102. FSD_HARD_LINK_LIST m_cHardLinkFilesList;
  103. };
  104. #endif // __H_HARDLINK_