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.

192 lines
7.2 KiB

  1. #ifndef _FSAITEM_
  2. #define _FSAITEM_
  3. /*++
  4. 1998 Seagate Software, Inc. All rights reserved.
  5. Module Name:
  6. fsaitem.cpp
  7. Abstract:
  8. This class contains represents a scan item (i.e. file or directory) for NTFS 5.0.
  9. Author:
  10. Chuck Bardeen [cbardeen] 1-Dec-1996
  11. Revision History:
  12. --*/
  13. #include "resource.h" // main symbols
  14. #include "wsb.h"
  15. #include "job.h"
  16. #include "mover.h"
  17. #include "fsa.h"
  18. #include "fsaprv.h"
  19. // Registry parameters
  20. #define FSA_MAX_SIZE_DISK_FULL OLESTR("MaxSizeDiskFullKB")
  21. // Usn journal defaults
  22. #define FSA_MAX_SIZE_DISK_FULL_DEFAULT (10 * 1024) // in KB (i.e. 10 MB)
  23. /*++
  24. Class Name:
  25. CFsaScanItem
  26. Class Description:
  27. --*/
  28. class CFsaScanItem :
  29. public CComObjectRoot,
  30. public IFsaScanItem,
  31. public IFsaScanItemPriv,
  32. public CComCoClass<CFsaScanItem,&CLSID_CFsaScanItemNTFS>
  33. {
  34. public:
  35. CFsaScanItem() {}
  36. BEGIN_COM_MAP(CFsaScanItem)
  37. COM_INTERFACE_ENTRY(IFsaScanItem)
  38. COM_INTERFACE_ENTRY(IFsaScanItemPriv)
  39. // COM_INTERFACE_ENTRY(IWsbCollectable)
  40. // COM_INTERFACE_ENTRY(IWsbTestable)
  41. END_COM_MAP()
  42. DECLARE_REGISTRY_RESOURCEID(IDR_FsaScanItem)
  43. // CComObjectRoot
  44. public:
  45. HRESULT FinalConstruct(void);
  46. void FinalRelease(void);
  47. // IWsbCollectable
  48. public:
  49. STDMETHOD(CompareTo)(IUnknown* pUnknown, SHORT* pResult);
  50. // IWsbTestable
  51. STDMETHOD(Test)(USHORT *passed, USHORT* failed);
  52. // IFsaScanItemPriv
  53. public:
  54. STDMETHOD(FindFirst)(IFsaResource* pResource, OLECHAR* path, IHsmSession* pSession);
  55. STDMETHOD(FindFirstInRPIndex)(IFsaResource* pResource, IHsmSession* pSession);
  56. STDMETHOD(FindFirstInDbIndex)(IFsaResource* pResource, IHsmSession* pSession);
  57. STDMETHOD(FindNext)(void);
  58. STDMETHOD(FindNextInRPIndex)(void);
  59. STDMETHOD(FindNextInDbIndex)(void);
  60. STDMETHOD(TruncateInternal)(LONGLONG offset, LONGLONG size);
  61. STDMETHOD(VerifyInternal)(LONGLONG offset, LONGLONG size, LONGLONG usn1, LONGLONG usn2);
  62. // IFsaScanItem
  63. public:
  64. STDMETHOD(CheckIfSparse)(LONGLONG offset, LONGLONG size);
  65. STDMETHOD(CompareToIScanItem)(IFsaScanItem* pScanItem, SHORT* pResult);
  66. STDMETHOD(CompareToPathAndName)(OLECHAR* path, OLECHAR* name, SHORT* pResult);
  67. STDMETHOD(Copy)(OLECHAR* dest, BOOL retainHierarcy, BOOL expandPlaceholders, BOOL overwriteExisting);
  68. STDMETHOD(CreateLocalStream)(IStream **ppStream);
  69. STDMETHOD(CreatePlaceholder)(LONGLONG offset, LONGLONG size, FSA_PLACEHOLDER pPlaceholder, BOOL checkUsn, LONGLONG usn, LONGLONG *pUsn);
  70. STDMETHOD(Delete)(void);
  71. STDMETHOD(DeletePlaceholder)(LONGLONG offset, LONGLONG size);
  72. STDMETHOD(FindFirstPlaceholder)(LONGLONG* pOffset, LONGLONG* pSize, FSA_PLACEHOLDER* pPlaceholder);
  73. STDMETHOD(FindNextPlaceholder)(LONGLONG* pOffset, LONGLONG* pSize, FSA_PLACEHOLDER* pPlaceholder);
  74. STDMETHOD(GetAccessTime)(FILETIME* pTime);
  75. STDMETHOD(GetFileId)(LONGLONG* pFileId);
  76. STDMETHOD(GetFileUsn)(LONGLONG* pFileUsn);
  77. STDMETHOD(GetFullPathAndName)(OLECHAR* prependix, OLECHAR *appendix, OLECHAR** pPath, ULONG bufferSize);
  78. STDMETHOD(GetGroup)(OLECHAR** pOwner, ULONG bufferSize);
  79. STDMETHOD(GetLogicalSize)(LONGLONG* pSize);
  80. STDMETHOD(GetModifyTime)(FILETIME* pTime);
  81. STDMETHOD(GetOwner)(OLECHAR** pOwner, ULONG bufferSize);
  82. STDMETHOD(GetName)(OLECHAR** pName, ULONG bufferSize);
  83. STDMETHOD(GetPath)(OLECHAR** pPath, ULONG bufferSize);
  84. STDMETHOD(GetPathForFind)(OLECHAR* searchName, OLECHAR** pPath, ULONG bufferSize);
  85. STDMETHOD(GetPathAndName)(OLECHAR* appendix, OLECHAR** pPath, ULONG bufferSize);
  86. STDMETHOD(GetPhysicalSize)(LONGLONG* pSize);
  87. STDMETHOD(GetPlaceholder)(LONGLONG offset, LONGLONG size, FSA_PLACEHOLDER* pPlaceholder);
  88. STDMETHOD(GetSession)(IHsmSession** ppSession);
  89. STDMETHOD(GetUncPathAndName)(OLECHAR* prependix, OLECHAR *appendix, OLECHAR** pPath, ULONG bufferSize);
  90. STDMETHOD(GetVersionId)(LONGLONG* pId);
  91. STDMETHOD(HasExtendedAttributes)(void);
  92. STDMETHOD(IsALink)(void);
  93. STDMETHOD(IsAParent)(void);
  94. STDMETHOD(IsARelativeParent)(void);
  95. STDMETHOD(IsCompressed)(void);
  96. STDMETHOD(IsDeleteOK)(IFsaPostIt *pPostIt);
  97. STDMETHOD(IsEncrypted)(void);
  98. STDMETHOD(IsHidden)(void);
  99. STDMETHOD(IsGroupMemberOf)(OLECHAR* group);
  100. STDMETHOD(IsManageable)(LONGLONG offset, LONGLONG size);
  101. STDMETHOD(IsManaged)(LONGLONG offset, LONGLONG size);
  102. STDMETHOD(IsMbit)(void);
  103. STDMETHOD(IsOffline)(void);
  104. STDMETHOD(IsMigrateOK)(IFsaPostIt *pPostIt);
  105. STDMETHOD(IsOwnerMemberOf)(OLECHAR* group);
  106. STDMETHOD(IsPremigrated)(LONGLONG offset, LONGLONG size);
  107. STDMETHOD(IsReadOnly)(void);
  108. STDMETHOD(IsRecallOK)(IFsaPostIt *pPostIt);
  109. STDMETHOD(IsSparse)(void);
  110. STDMETHOD(IsSystem)(void);
  111. STDMETHOD(IsTotallySparse)(void);
  112. STDMETHOD(IsTruncated)(LONGLONG offset, LONGLONG size);
  113. STDMETHOD(Manage)(LONGLONG offset, LONGLONG size, GUID storagePoolId, BOOL truncate);
  114. STDMETHOD(Move)(OLECHAR* dest, BOOL retainHierarcy, BOOL expandPlaceholders, BOOL overwriteExisting);
  115. STDMETHOD(Recall)(LONGLONG offset, LONGLONG size, BOOL deletePlaceholder);
  116. STDMETHOD(Recycle)(void);
  117. STDMETHOD(Truncate)(LONGLONG offset, LONGLONG size);
  118. STDMETHOD(Unmanage)(LONGLONG offset, LONGLONG size);
  119. STDMETHOD(Validate)(LONGLONG offset, LONGLONG size);
  120. STDMETHOD(PrepareForManage)(LONGLONG offset, LONGLONG size);
  121. STDMETHOD(Verify)(LONGLONG offset, LONGLONG size);
  122. STDMETHOD(TruncateValidated)(LONGLONG offset, LONGLONG size);
  123. // Private functions
  124. private:
  125. STDMETHOD(CheckUsnJournalForChanges)(LONGLONG StartUsn, LONGLONG StopUsn, BOOL *pChanged);
  126. STDMETHOD(GetPremigratedUsn)(LONGLONG* pFileUsn);
  127. STDMETHOD(GetFromRPIndex)(BOOL first);
  128. STDMETHOD(GetFromDbIndex)(BOOL first);
  129. STDMETHOD(CalculateCurrentCRCAndUSN)(LONGLONG offset,LONGLONG size, ULONG *pCurrentCRC, LONGLONG *pUsn);
  130. STDMETHOD(CalculateCurrentCRCInternal)(HANDLE handle, LONGLONG offset,LONGLONG size, ULONG *pCurrentCRC);
  131. STDMETHOD(MakeReadWrite)(void);
  132. STDMETHOD(RestoreAttributes)(void);
  133. STDMETHOD(CheckIfDiskFull)(void);
  134. protected:
  135. CComPtr<IFsaResource> m_pResource;
  136. CWsbStringPtr m_path;
  137. CComPtr<IHsmSession> m_pSession;
  138. HANDLE m_handle;
  139. WIN32_FIND_DATA m_findData;
  140. BOOL m_gotPhysicalSize;
  141. ULARGE_INTEGER m_physicalSize;
  142. BOOL m_gotPlaceholder;
  143. FSA_PLACEHOLDER m_placeholder;
  144. BOOL m_changedAttributes;
  145. ULONG m_originalAttributes;
  146. CComPtr<IDataMover> m_pDataMover;
  147. CComPtr<IStream> m_pStream;
  148. // Only used for Reparse Point Index scan:
  149. HANDLE m_handleRPI;
  150. // Used by :Verify
  151. HANDLE m_handleVerify;
  152. // Only used for Database scan
  153. CComPtr<IFsaUnmanageDb> m_pUnmanageDb;
  154. CComPtr<IFsaUnmanageRec> m_pUnmanageRec;
  155. CComPtr<IWsbDbSession> m_pDbSession;
  156. };
  157. #endif // _FSAITEM_