Platform SDK: Hardware |
The FSCTL_RECALL_FILE operation recalls a file from storage media managed by Remote Storage, the hierarchical storage management software in Windows 2000.
To perform this operation, call the DeviceIoControl function with the following parameters.
BOOL DeviceIoControl( (HANDLE) hDevice, // handle to file or directory FSCTL_RECALL_FILE, // dwIoControlCode operation NULL, // lpInBuffer; must be NULL 0, // nInBufferSize; must be zero NULL, // lpOutBuffer; must be NULL 0, // nOutBufferSize; must be zero (LPDWORD) lpBytesReturned, // number of bytes returned (LPOVERLAPPED) lpOverlapped // OVERLAPPED structure );
If lpOverlapped is NULL (nonoverlapped I/O), lpBytesReturned is used internally and cannot be NULL.
If lpOverlapped is not NULL (overlapped I/O), lpBytesReturned can be NULL.
If hDevice was opened with the FILE_FLAG_OVERLAPPED flag, lpOverlapped must point to a valid OVERLAPPED structure. In this case, DeviceIoControl is performed as an overlapped (asynchronous) operation. If the device was opened with the FILE_FLAG_OVERLAPPED flag and lpOverlapped is NULL, the function fails in unpredictable ways.
If hDevice was opened without specifying the FILE_FLAG_OVERLAPPED flag, lpOverlapped is ignored and the DeviceIoControl function does not return until the operation has been completed, or until an error occurs.
If the operation succeeds, DeviceIoControl returns a nonzero value.
If the operation fails, DeviceIoControl returns zero. To get extended error information, call GetLastError.
FSCTL_RECALL_FILE recovers a file from storage, such as tape, that is managed by Remote Storage. If the file is already cached locally, this operation has no effect. Similarly, if the file has not been moved to remote storage, this operation has no effect.
FSCTL_RECALL_FILE operates only on systems on which Remote Storage is installed. Where Remote Storage is not installed, the operation fails, and GetLastError returns the error code ERROR_INVALID_FUNCTION.
Directories cannot be moved to remote storage. Calling FSCTL_RECALL_FILE for a directory fails, and GetLastError returns the error code ERROR_INVALID_HANDLE.
Files stored on media managed by Remote Storage are usually recalled when an application attempts to make the first access to data. An application that opens a file without immediately accessing the data can speed up the first access by using FSCTL_RECALL_FILE immediately after opening the file. However, you should avoid indiscriminate recall of files that your application will not touch.
You need not test a file's attributes for the flag FILE_ATTRIBUTE_OFFLINE with the function GetFileAttributes before calling FSCTL_RECALL_FILE. A test is unnecessary because an online file is not affected by this operation. However, any operating system call takes processor time. To conserve processor time, call GetFileAttributes to check file attributes to determine if FSCTL_RECALL_FILE is necessary.
For the implications of overlapped I/O on this operation, see the Remarks section of the DeviceIoControl topic.
The following short program, Recall.c, shows a command-line utility that recalls one or more files indicated on the command line from remote storage.
/*++ Copyright (c) 1999 Microsoft Corporation Module Name: Recall.c Simple utility to recall files managed by Remote Storage */ #include <windows.h> #include <malloc.h> #include <stdio.h> #include <winioctl.h> DWORD RecallFile(PUCHAR FileName); int _cdecl main(int argc, char *argv[]) { HANDLE file; LONG i; DWORD nbytes; if (argc < 2) { printf("Usage: recall <file-name1> <file-name2> ...\n"); return 1; } for (i = 1; i < argc; i++) { (void) RecallFile(argv[i]); } return 0; } DWORD RecallFile(IN PUCHAR FileName) /*++ Routine Description Recalls the file with the supplied path. Arguments FileName - Path of the file to be recalled Return Value 0 - Recall is successful. Any other value - Error code for the operation. --*/ { HANDLE fileHandle; DWORD nbytes; DWORD errorCode = 0; fileHandle = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (fileHandle == INVALID_HANDLE_VALUE) { errorCode = GetLastError(); printf("Couldn't open file %s: error %x\n", FileName, errorCode); return errorCode; } if (!DeviceIoControl(fileHandle, FSCTL_RECALL_FILE, NULL, 0, NULL, 0, &nbytes, NULL)) { errorCode = GetLastError(); printf("Couldn't recall file %s: error %x\n", FileName, errorCode); } CloseHandle(fileHandle); return errorCode; }
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winioctl.h.
Device Input and Output Overview, Device Input and Output Control Codes, CreateFile, DeviceIoControl, GetFileAttributes, OVERLAPPED