FSCTL_QUERY_USN_JOURNAL control code
Queries for information on the current update sequence number (USN) change journal, its records, and its capacity.
BOOL WINAPI DeviceIoControl( (HANDLE) Device, // handle to volume (DWORD) FSCTL_QUERY_USN_JOURNAL,// dwIoControlCode (LPVOID) NULL, // lpInBuffer (DWORD) 0, // nInBufferSize (LPVOID) lpOutBuffer, // output buffer (DWORD) nOutBufferSize, // size of output buffer (LPDWORD) lpBytesReturned, // number of bytes returned (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure
To perform this operation, call the DeviceIoControl function using the following parameters.
Parameters
- hDevice
-
A handle to the local volume from which data is to be retrieved.
To retrieve a volume handle, call the CreateFile function.
- dwIoControlCode
-
The control code for the operation.
Use FSCTL_QUERY_USN_JOURNAL for this operation.
- lpInBuffer
-
Not used with this operation; set to NULL.
- nInBufferSize
-
Not used with this operation; set to 0 (zero).
- lpOutBuffer
-
A pointer to the output buffer that receives a USN_JOURNAL_DATA_V0 or USN_JOURNAL_DATA_V1 structure that contains information about the current change journal, its records, and its capacity.
- nOutBufferSize
-
The size of the output buffer, in bytes. If the size passed is at least
sizeof(USN_JOURNAL_DATA_V0)but less thansizeof(USN_JOURNAL_DATA_V1)then the output structure is a USN_JOURNAL_DATA_V0 structure. If the output buffer issizeof(USN_JOURNAL_DATA_V1)or larger than the output buffer is a USN_JOURNAL_DATA_V1 structure.Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: USN_JOURNAL_DATA_V1 is not supported before Windows Server 2012. - lpBytesReturned
-
A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.
If the output buffer is too small, the call fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and lpBytesReturned is 0 (zero).
If lpOverlapped is NULL, lpBytesReturned cannot be NULL. Even when an operation does not return output data and lpOutBuffer is NULL, DeviceIoControl uses lpBytesReturned. After such an operation, the value of lpBytesReturned is meaningless.
If lpOverlapped is not NULL, lpBytesReturned can be NULL. If this parameter is not NULL and the operation returns data, lpBytesReturned is meaningless until the overlapped operation is complete. To retrieve the number of bytes returned, call GetOverlappedResult. If hDevice is associated with an I/O completion port, you can retrieve the number of bytes returned by calling GetQueuedCompletionStatus.
- lpOverlapped
-
A pointer to an OVERLAPPED structure.
If hDevice is opened without specifying FILE_FLAG_OVERLAPPED, lpOverlapped is ignored.
If hDevice is opened with the FILE_FLAG_OVERLAPPED flag, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped must point to a valid OVERLAPPED structure that contains a handle to an event object. Otherwise, the function fails in unpredictable ways.
For overlapped operations, DeviceIoControl returns immediately, and the event object is signaled when the operation is complete. Otherwise, the function does not return until the operation is complete or an error occurs.
Return value
If the operation completes successfully, DeviceIoControl returns a nonzero value, and the output buffer pointed to by lpOutBuffer contains a valid USN_JOURNAL_DATA structure.
If the operation fails or is pending, DeviceIoControl returns 0 (zero), and the contents of the output buffer pointed to by lpOutBuffer are meaningless. To get extended error information, call GetLastError.
The possible return values include the following.
| Return code | Description |
|---|---|
|
The specified volume does not support change journals. Where supported, change journals can also be deleted. |
|
One or more parameters is invalid. For example, DeviceIoControl returns this error code if the handle supplied is not a volume handle. |
|
An attempt is made to read from, create, delete, or modify the journal while a journal deletion is in process, or an attempt is made to write a USN record while a journal deletion is in process. |
|
An attempt is made to write a USN record or to read the change journal while the journal is inactive. |
Remarks
For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic.
For more information, see Creating, Modifying, and Deleting a Change Journal.
To retrieve a handle to a volume, call CreateFile with the lpFileName parameter set to a string in the following form:
\\.\X:
In the preceding string, X is the letter identifying the drive on which the volume appears. The volume must be formatted with the NTFS filesystem.
In Windows 8 and Windows Server 2012, this code is supported by the following technologies.
| Technology | Supported |
|---|---|
|
Server Message Block (SMB) 3.0 protocol |
No |
|
SMB 3.0 Transparent Failover (TFO) |
No |
|
SMB 3.0 with Scale-out File Shares (SO) |
No |
|
Cluster Shared Volume File System (CsvFS) |
Yes |
An application may experience false positives on CsvFs pause/resume.
Requirements
|
Minimum supported client | Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server | Windows Server 2003 [desktop apps only] |
|
Header |
|
See also
- Change Journals
- CreateFile
- DeviceIoControl
- GetOverlappedResult
- GetQueuedCompletionStatus
- OVERLAPPED
- USN_JOURNAL_DATA_V0
- USN_JOURNAL_DATA_V1
- Volume Management Control Codes
Send comments about this topic to Microsoft
Build date: 4/16/2013
