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.

139 lines
3.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998 - 2000.
  5. //
  6. // File: clogdump.cxx
  7. //
  8. // Contents: Changelog dump utility
  9. //
  10. // History: 04 Mar 1998 AlanW Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <pch.cxx>
  14. #pragma hdrstop
  15. #include <changlog.hxx>
  16. DECLARE_INFOLEVEL(ci)
  17. unsigned fVerbose = 0;
  18. int ChangeLogDump( char * pszPath );
  19. int __cdecl main( int argc, char * argv[] )
  20. {
  21. char * pszFile = argv[1];
  22. unsigned cFail = 0;
  23. for ( int i = 1; i < argc; i++ )
  24. {
  25. if ( argv[i][0] == '-' )
  26. {
  27. switch ( argv[i][1] )
  28. {
  29. case 'v':
  30. case 'V':
  31. fVerbose = 1;
  32. break;
  33. #if 0
  34. case 'm':
  35. case 'M':
  36. fReadMetadata = TRUE;
  37. break;
  38. case 'f':
  39. case 'F':
  40. i++;
  41. if ( cField < cMaxFields )
  42. aiField[cField++] = strtol( argv[i], 0, 10 );
  43. break;
  44. #endif // 0
  45. default:
  46. fprintf(stderr, "Usage: file ...\n");
  47. exit(2);
  48. }
  49. continue;
  50. }
  51. else
  52. {
  53. pszFile = argv[i];
  54. cFail += ChangeLogDump(pszFile);
  55. }
  56. }
  57. return cFail != 0;
  58. }
  59. int ChangeLogDump( char * pszPath )
  60. {
  61. HANDLE h = CreateFileA( pszPath,
  62. GENERIC_READ,
  63. FILE_SHARE_READ,
  64. 0,
  65. OPEN_EXISTING,
  66. 0,
  67. 0 );
  68. if ( INVALID_HANDLE_VALUE == h )
  69. {
  70. printf( "Can't open file %s. Error %u\n", pszPath, GetLastError() );
  71. return 1;
  72. }
  73. printf( "fileaddr rec\t\tUSN\tWorkID\tVolID\tAction\tRetries\n" );
  74. ULONG cbRead;
  75. struct ChangeRecord {
  76. CDocNotification aRecord[cDocInChunk];
  77. ULONG ulChecksum;
  78. } ChangeRecord;
  79. for ( unsigned i = 0; ; i++ )
  80. {
  81. if ( ! ReadFile( h, &ChangeRecord, sizeof ChangeRecord, &cbRead, 0 ) )
  82. {
  83. fprintf(stderr, "Error %d reading %s\n", GetLastError(), pszPath );
  84. CloseHandle( h );
  85. return 1;
  86. }
  87. if (cbRead == 0)
  88. break;
  89. for ( unsigned j = 0; j < cDocInChunk; j++ )
  90. {
  91. CDocNotification * pRecord = &ChangeRecord.aRecord[j];
  92. if (0 == pRecord->Wid())
  93. continue;
  94. printf("%08x %d.\t",
  95. i*sizeof ChangeRecord + j*sizeof (CDocNotification),
  96. i*cDocInChunk + j );
  97. if ( widInvalid == pRecord->Wid() )
  98. {
  99. printf( "<unused>\n" );
  100. continue;
  101. }
  102. char szUSN[40];
  103. _i64toa( pRecord->Usn(), szUSN, 10 );
  104. printf("%11s\t%6d\t%5d\t%5d\t%5d\n",
  105. szUSN, pRecord->Wid(),
  106. pRecord->VolumeId(), pRecord->Action(), pRecord->Retries() );
  107. }
  108. }
  109. CloseHandle( h );
  110. return 0;
  111. }