Search code examples
c++windowsbackupntfs

Question regarding NTFS Change Journal USN records


This maybe a somewhat silly question, but I haven't been able to find the answer anywhere. Is there any way to find out what the last record in the change journal is?

When we run the FSTCL query for the first time it takes too long to enumerate all the records. Is there a easy way to find it?


Solution

  • FSCTL_QUERY_USN_JOURNAL returns the USN that will be used for the next record (NextUsn). The last record will normally be NextUsn minus 1. To play it safe, you could use FSCTL_ENUM_USN_DATA with USN filtering to look for NextUsn minus 1, and if it doesn't exist look for NextUsn minus 2, then minus 4, etc.