IRP_MJ_SET_INFORMATION

When Sent

The IRP_MJ_SET_INFORMATION request is sent by the I/O Manager and other operating system components, as well as other kernel-mode drivers. It can be sent, for example, when a user-mode application has called a Microsoft Win32 function such as SetEndOfFile or when a kernel-mode component has called ZwSetInformationFile.

Operation: File System Drivers

The file system driver should extract and decode the file object to determine whether it represents a user file or directory open. If it does, the file system driver should process the request as appropriate and complete the IRP.

The following types of information can be set on files and directories:

FileBasicInformation

FileDispositionInformation

FileLinkInformation (for file systems that allow cycles to be created in the directory hierarchy)

FilePositionInformation

FileRenameInformation

The following types of information can be set only on files:

FileAllocationInformation

FileEndOfFileInformation

FileLinkInformation (for file systems, such as NTFS, that do not allow cycles to be created in the directory hierarchy)

FileValidDataLengthInformation

Operation: File System Filter Drivers

The filter driver must pass this IRP down to the next-lower driver on the stack.

Parameters

A file system or filter driver calls IoGetCurrentIrpStackLocation with the given IRP to get a pointer to its own stack location in the IRP, shown in the following list as IrpSp. (The IRP is shown as Irp.) The driver can use the information that is set in the following members of the IRP and the IRP stack location in processing a set file information request:

DeviceObject
Pointer to the target device object.

Irp->AssociatedIrp.SystemBuffer
Pointer to an input buffer that contains the file or directory information to be set. This information is stored in one of the following structures:

FILE_ALLOCATION_INFORMATION

FILE_BASIC_INFORMATION

FILE_DISPOSITION_INFORMATION

FILE_END_OF_FILE_INFORMATION

FILE_LINK_INFORMATION

FILE_POSITION_INFORMATION

FILE_RENAME_INFORMATION

FILE_VALID_DATA_LENGTH_INFORMATION

Irp->IoStatus Pointer to an IO_STATUS_BLOCK structure that receives the final completion status and information about the requested operation. For more information, see the description of the IoStatusBlock parameter to ZwSetInformationFile.

IrpSp->FileObject Pointer to the file object that is associated with DeviceObject.

The IrpSp->FileObject parameter contains a pointer to the RelatedFileObject field, which is also a FILE_OBECT structure. The RelatedFileObject field of the FILE_OBJECT structure is not valid during the processing of IRP_MJ_SET_INFORMATION and should not be used.

IrpSp->MajorFunction Specifies IRP_MJ_SET_INFORMATION.

IrpSp->Parameters.SetFile.AdvanceOnly A flag for end-of-file operations. This determines the use of the EndOfFile member FILE_END_OF_FILE_INFORMATION structure when FileInformationClass == FileEndOfFileInformation. If TRUE, a new valid data length for the file will be set from EndOfFile only if it increases the current valid data length. If FALSE, a new file size is set from EndOfFile.

IrpSp->Parameters.SetFile.ClusterCount Reserved for system use.

IrpSp->Parameters.SetFile.DeleteHandle Reserved for system use.

IrpSp->Parameters.SetFile.FileInformationClass Specifies the type of information to be set for the file. One of the following:

Value Meaning

FileAllocationInformation

Set FILE_ALLOCATION_INFORMATION for the file.

FileBasicInformation

Set FILE_BASIC_INFORMATION for the file.

FileDispositionInformation

Set FILE_DISPOSITION_INFORMATION for the file.

FileEndOfFileInformation

Set FILE_END_OF_FILE_INFORMATION for the file.

FileLinkInformation

Set FILE_LINK_INFORMATION for the file.

FilePositionInformation

Set FILE_POSITION_INFORMATION for the file.

FileRenameInformation

Set FILE_RENAME_INFORMATION for the file.

FileValidDataLengthInformation

Set FILE_VALID_DATA_LENGTH_INFORMATION for the file.

IrpSp->Parameters.SetFile.FileObject For rename or link operations. If Irp->AssociatedIrp.SystemBuffer->FileName contains a fully qualified file name, or if Irp->AssociatedIrp.SystemBuffer->RootDirectory is non-NULL, this member is a file object pointer for the parent directory of the file that is the target of the operation. Otherwise it is NULL.

IrpSp->Parameters.SetFile.Length Length, in bytes, of the buffer pointed to by Irp->AssociatedIrp.SystemBuffer.

IrpSp->Parameters.SetFile.ReplaceIfExists Set to TRUE to specify that if a file with the same name already exists, it should be replaced with the given file. Set to FALSE if the rename operation should fail if a file with the given name already exists.

Remarks

The AdvanceOnly member is set to TRUE by the cache manager to notify the file system to advance the current valid data length on the disk to the new valid data length in EndOfFile. If AdvanceOnly is FALSE, a new file size, in the EndOfFile member, is being set which can be larger or smaller than the current file size.

See also

FILE_ALLOCATION_INFORMATION

FILE_BASIC_INFORMATION

FILE_DISPOSITION_INFORMATION

FILE_END_OF_FILE_INFORMATION

FILE_LINK_INFORMATION

FILE_POSITION_INFORMATION

FILE_RENAME_INFORMATION

FILE_VALID_DATA_LENGTH_INFORMATION

IO_STACK_LOCATION

IO_STATUS_BLOCK

IoGetCurrentIrpStackLocation

IRP

IRP_MJ_QUERY_INFORMATION

ZwSetInformationFile