I don’t know, I use IoGetRelatedDeviceObject+IoBuildDeviceIoControlRequest
on volume’s FO (instead of FltFs- API). Maybe you should stop when you get
STATUS_ACCESS_DENIED and examine why it failed. Instead of those two status
code, you can also get STATUS_JOURNAL_DELETE_IN_PROGRESS error code. In this
case, call FSCTL_DELETE_USN_JOURNAL with USN_DELETE_FLAG_NOTIFY and query
USN again.
Petr
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@vmware.com
Sent: Monday, February 13, 2012 9:23 AM
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] Querying last USN for the file on NTFS volume from a
filter driver
Hello,
I had a follow-up question on this one.
I was able to query the USN record using FltFsControlFile with
FSCTL_READ_FILE_USN_DATA. However, I noticed, that, if the USN journal is
not active (which is default on NTFS), the API call still succeeds and
USN_RECORD.Usn is zero in this case.
Based on some other reading, it seems that USN is just an offset into an
internal journal file maintained by NTFS and hence USN_RECORD.Usn=0 can
potentially be a genuine USN record.
Hence, there is needs to be a way to distinguish between USN=0 vs. journal
not active case. I came across FSCTL_QUERY_USN_JOURNAL which is supposed to
return me STATUS_JOURNAL_NOT_ACTIVE when journal is not active. However, I
find that many times this API returns STATUS_ACCESS_DENIED instead of
STATUS_JOURNAL_NOT_ACTIVE. Any thoughts on this? I am calling the API as
follows
USN_JOURNAL_DATA usnJournalData;
ns = FltFsControlFile(fltObjects->Instance,
fltObjects->FileObject,
FSCTL_QUERY_USN_JOURNAL,
NULL,
0,
&usnJournalData,
sizeof(usnJournalData),
&bytesRet);
Thanks.
-Prasad
NTFSD is sponsored by OSR
For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer