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.

284 lines
10 KiB

  1. @rem = '
  2. @goto endofperl
  3. ';
  4. use Getopt::Long;
  5. use Time::Local;
  6. $USAGE = "
  7. Usage: $0 [-sort=xxx] datafile
  8. Process the output of \"ntfrsutl inlog\" or \"ntfrsutl outlog\"
  9. and summarize the pending change orders.
  10. Sort Keyword Sort the output by:
  11. -sort=seqnum Sequence Number (default)
  12. -sort=version File Version Number
  13. -sort=filename File Name
  14. -sort=size File Size
  15. -sort=fileguid File Guid
  16. -sort=origguid Originator Guid
  17. -sort=cxtion Cxtion Name / Guid
  18. -sort=eventtime Event Time
  19. ";
  20. die $USAGE unless @ARGV;
  21. $InFile = "";
  22. $argsort = "seqnum";
  23. $havedata = 0;
  24. $tabletype = "unknown";
  25. &GetOptions("sort=s" => \$argsort);
  26. $argsort = lc($argsort);
  27. if (!($argsort =~ m/seqnum|version|size|fileguid|origguid|eventtime|filename|cxtion/)) {
  28. print STDERR "Error: Invalid -sort parameter\n";
  29. die $USAGE;
  30. }
  31. printf "Report generated at %s\n\n", scalar localtime;
  32. printf "Records sorted by: %s\n\n", $argsort;
  33. while (<>) {
  34. if ($InFile ne $ARGV) {
  35. $InFile = $ARGV;
  36. $modtime = (stat $InFile)[9];
  37. printf("Processing file %s Modify Time: %s\n\n", $InFile, scalar localtime($modtime));
  38. $infilelist = $infilelist . " " . $InFile;
  39. $linenumber = 0;
  40. }
  41. chop;
  42. ($field, $sep, $value) = split;
  43. if ($field eq "") {next;}
  44. # ID, OUTLOG, INLOG
  45. if ($field eq "NTFRS") {$tabletype = $sep; next;}
  46. #
  47. # Check for start of table dump for new replica set and dump the sorted table.
  48. #
  49. if ($field eq "*****") {
  50. if ($havedata) {&PrintData();}
  51. if ($havedata > 0) {
  52. foreach $param (sort keys(%outhash)) {
  53. printf("%s", $outhash{$param});
  54. }
  55. undef %outhash;
  56. $havedata = 0;
  57. printf("\f\n");
  58. }
  59. $ReplicaName = substr($_, 6);
  60. next;
  61. }
  62. #
  63. # Get field values.
  64. #
  65. if (m/^SequenceNumber/) {$SequenceNumber = $value; next;}
  66. if ($field =~ m/VersionNumber/) {$FileVersionNumber = hex($value); next; }
  67. if ($field =~ m/FileUsn/) {($junk, $FileUsn) = split(" : ", $_); next; }
  68. if ($field =~ m/EventTime/) {($junk, $EventTime) = split(" : ", $_); next; }
  69. if ($field =~ m/WriteTime/) {($junk, $WriteTime) = split(" : ", $_); next; }
  70. if ($field =~ m/OriginalReplica/) {($junk, $ReplicaNumber) = split(" : ", $_); next; }
  71. if (m/^Flags/) {($Flags) = m/Flags \[(.*)\]/i; next; }
  72. if (m/^IFlags/) {($IFlags) = m/Flags \[(.*)\]/i; next; }
  73. if (m/^ContentCmd/) {($ContentCmd) = m/Flags \[(.*)\]/i; next; }
  74. if (m/^FileName/) {($junk, $FileName) = split(" : ", $_); next;}
  75. if (m/^FileSize/) {($j1, $j2, $j3, $FileSize) = split; $FileSize = hex($FileSize)/1024; next; }
  76. if (m/^FileGuid/) {
  77. ($FileGuid) = m/: (.*)-....-....-/i;
  78. if ($havedata == 0) {
  79. #
  80. # Print the header once we see the first Fileguid.
  81. #
  82. printf("\n\nREPLICA SET: %s (%d) Table Type: %s\n\n", $ReplicaName, $ReplicaNumber, $tabletype);
  83. printf("SeqNumber Event Time FileVersNum FileUsn FileSize(K) FileGuid OrigGuid Cxtion FileName Flags /Lcmd/Content chg \n\n");
  84. }
  85. $havedata++;
  86. next;
  87. }
  88. if (m/^OriginatorGuid/) {($OriginatorGuid) = m/: (.*)-....-....-/i; next; }
  89. if (m/^CxtionGuid/) {($CxtionGuid) = m/: (.*)-....-....-/i; next; }
  90. if (m/^Cxtion Name/) {($CxtionName) = m/\\.*\\(.*)\$$/; next; }
  91. if (m/^Lcmd/) {($Lcmd) = m/(\w+)$/;
  92. $Lcmd = ($Lcmd eq "NoCmd") ? "" : " $Lcmd ";
  93. next; }
  94. if (m/^Extension.*MD5/) {
  95. if ($tabletype ne "ID") {$ExtraFlags = $ExtraFlags . " MD5"; next; }
  96. $md5 = m/MD5:\s(........)/;
  97. if ($md5 && $md5 ne "00000000") {$ExtraFlags = $ExtraFlags . " MD5"; next; }
  98. }
  99. if (m/^FileAttributes.*DIRECTORY/) {$ExtraFlags = $ExtraFlags . " DIR"; next; }
  100. if ($field =~ m/^ReplEnabled.*00000000/) {$ExtraFlags = $ExtraFlags . " ReplDisabled"; next; }
  101. if (m/^Table Type/ && $havedata) {&PrintData(); next;}
  102. }
  103. #
  104. # Process last record.
  105. #
  106. if ($havedata) {&PrintData();}
  107. if ($havedata > 0) {
  108. foreach $param (sort keys(%outhash)) {
  109. printf("%s", $outhash{$param});
  110. }
  111. undef %outhash;
  112. $havedata = 0;
  113. }
  114. exit;
  115. #
  116. # Gather the record data
  117. #
  118. sub PrintData {
  119. my $outstr, $i, $key, $str, $mon, $day, $year, $distinguish, $hr, $min, $sec;
  120. if ($tabletype eq "ID") {
  121. $SequenceNumber = "00000000"; # leave seq num zero so windiff between idtables will work. sprintf("%08lx", $idtseqnum++);
  122. $FileUsn =~ s/[0-9a-fA-F]/-/g; # omit the FileUsn so windiff works.
  123. }
  124. if ($Flags eq "<Flags Clear>") {$Flags = "";}
  125. if ($CxtionName eq "") {$CxtionName = $CxtionGuid;}
  126. $outstr = sprintf("%s %s %6d %s %6d %s %s %-14s %-26s [%s%s/%s/%s]\n",
  127. $SequenceNumber, substr($EventTime,4), $FileVersionNumber,
  128. substr($FileUsn,4) , $FileSize, $FileGuid, $OriginatorGuid, $CxtionName, $FileName, $Flags, $ExtraFlags, $Lcmd, $ContentCmd);
  129. $ExtraFlags = "";
  130. #
  131. # Index the output result by the sort key. Zero extend the key.
  132. # Default is to sort by name.
  133. #
  134. $key = "0000000000";
  135. if ($argsort eq "seqnum") {$i = $SequenceNumber; $key = substr("0000000000".$i, -10);}
  136. if ($argsort eq "version") {$i = $FileVersionNumber; $key = substr("0000000000".$i, -10);}
  137. if ($argsort eq "size") {$i = $FileSize; $key = substr("0000000000".$i, -10);}
  138. if ($argsort eq "fileguid") {$i = hex($FileGuid); $key = substr("0000000000".$i, -10);};
  139. if ($argsort eq "origguid") {$i = hex($OriginatorGuid); $key = substr("0000000000".$i, -10);};
  140. if ($argsort eq "eventtime"){$str = $EventTime;};
  141. if ($argsort eq "filename") {$key = $FileName;};
  142. if ($argsort eq "cxtion") {$key = $CxtionName;};
  143. if ($argsort eq "eventtime") {
  144. # Oct 18, 2000
  145. ($mon, $day, $year) = lc($str) =~ m/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s*(\d*).*(\d\d\d\d)/;
  146. ($hr, $min, $sec) = $str =~ m/(\d\d):(\d\d):(\d\d)/;
  147. $i = 0;
  148. if ($mon ne "") {
  149. $mon = index("janfebmaraprmayjunjulaugsepoctnovdec", $mon) / 3;
  150. $i = timelocal($sec, $min, $hr, $day, $mon, $year-1900);
  151. }
  152. $key = substr("000000000000".$i, -12);
  153. }
  154. if ($tabletype ne "ID") {
  155. $distinguish = substr("0000000000".hex($SequenceNumber), -10);
  156. } else {
  157. $distinguish = substr("0000000000".hex($FileGuid), -10);
  158. }
  159. #
  160. # combine key with sequence number to distinguish duplicates.
  161. #
  162. $outhash{$key . $distinguish} = $outstr;
  163. $CxtionName = "";
  164. }
  165. __END__
  166. :endofperl
  167. @perl %~dpn0.cmd %*
  168. @goto :QUIT
  169. Table Type: Outbound Log Table for CCI-DFS|DFSISSOFT
  170. SequenceNumber : 0000713e
  171. Flags : 00040088 Flags [Locn InstallInc VVjoinToOrig ]
  172. IFlags : 00000001 Flags [IFlagVVRetireExec ]
  173. State : 00000014 CO STATE: IBCO_OUTBOUND_REQUEST
  174. ContentCmd : 00000000 Flags [<Flags Clear>]
  175. Lcmd : 0000000c D/F 0 MoveDir
  176. FileAttributes : 00000020 Flags [ARCHIVE ]
  177. FileVersionNumber : 00000002
  178. PartnerAckSeqNumber : 0046eb01
  179. FileSize : 00000000 0013c000
  180. FileOffset : 00000000 00000000
  181. FrsVsn : 01c11175 0374e84d
  182. FileUsn : 00000000 4f4e38e0
  183. JrnlUsn : 00000000 00000000
  184. JrnlFirstUsn : 00000000 00000000
  185. OriginalReplica : 6 [???]
  186. NewReplica : 6 [???]
  187. ChangeOrderGuid : 6cbae37c-d423-407c-8b4a2eb7b655fa22
  188. OriginatorGuid : fe7dcf0d-8b50-44af-874b88445c20aa4b
  189. FileGuid : 37128060-92e4-4c00-87edecdadbe70b8d
  190. OldParentGuid : 4e060479-af69-4afb-9f1842e07cc4fd7a
  191. NewParentGuid : a8b63177-e130-4d55-986879001c06871b
  192. CxtionGuid : c826a4d8-508d-470f-a1c6b31550e7d316
  193. Spare1Ull : Tue Jul 24, 2001 01:36:28
  194. Extension : MD5: d8693a27 1d05e581 1e8571cc bed5dc98
  195. EventTime : Mon Jul 23, 2001 10:19:34
  196. FileNameLength : 18
  197. FileName : data1.cab
  198. Cxtion Name : {FEBE6930-3A41-496A-B996-600051D08E39} <- HATL0FS23\CORP\HATL0FS23$
  199. Cxtion State : Unjoined
  200. Table Type: Outbound Log Table for DOMAIN SYSTEM VOLUME (SYSVOL SHARE)
  201. SequenceNumber : 0001eaf1
  202. Flags : 00000024 Flags [Content LclCo ]
  203. IFlags : 00000001 Flags [IFlagVVRetrireExec ]
  204. State : 00000014 CO STATE: IBCO_OUTBOUND_REQUEST
  205. ContentCmd : 00000007 Flags [DatOvrWrt DatExt DatTrunc ]
  206. Lcmd : 0000000e D/F 0 NoCmd
  207. FileAttributes : 00000020 Flags [ARCHIVE ]
  208. FileVersionNumber : 000019f6
  209. PartnerAckSeqNumber : 00000000
  210. FileSize : 00000000 00020000
  211. FileOffset : 00000000 00000000
  212. FrsVsn : 01c01527 c439f6dc
  213. FileUsn : 0000000c c9adf7f8
  214. JrnlUsn : 0000000c c9adf7f8
  215. JrnlFirstUsn : 0000000c c9adcf50
  216. OriginalReplica : 0 [???]
  217. NewReplica : 0 [???]
  218. ChangeOrderGuid : 75d2610e-4dd7-411c-a0fa4646deac7bcc
  219. OriginatorGuid : c2a0e5cd-de3a-45a5-93ca09f5b38817b4
  220. FileGuid : e725bf8b-a8b8-4139-8dfb32e91cf2cbe4
  221. OldParentGuid : 67ef5973-5556-48a6-b47f76070c0266a9
  222. NewParentGuid : 67ef5973-5556-48a6-b47f76070c0266a9
  223. CxtionGuid : 521e207a-cff6-46f2-84283e78c270062f
  224. Spare1Ull :
  225. Extension : MD5: 51c59a6c a7168e5e 645ba619 35a9c33d
  226. EventTime : Tue Oct 3, 2000 17:53:04
  227. FileNameLength : 22
  228. FileName : GptTmpl.inf
  229. ---------------------------------------
  230. @:QUIT