Ioregisterfsregistrationchange registers a file system change callback function, which is used to notify the file system of activation and logoff, activation refers to the first time the file system is loaded, when a file system has been loaded, when loading a volume of the same file system, The file system is not OK with activation. After the function is called, the activated file system is reactivated again, and the system will do so after the 2k SP4.
Now consider how this mechanism is implemented, guess is at the time of registration, after the registration is completed, the system will be various types of file system, call the callback function again, to all the file system activation notification. In fact, it should be so, ReactOS implementation mechanism shows that, on the source:
First of all, explain some things, the system will be the various types of file systems in their own linked list queue, such as the local Disk file system, NTFS and FAT32 file system, in the Iopdiskfilesystemqueuehead queue, other types of file systems, such as network file system, is in Iopnetworkfilesystemqueuehead, CDROM file system, is in Iopcdromfilesystemqueuehead, tape file system, is in the Ioptapefilesystemqueuehead queue.
First look at the realization of Ioregisterfsregistrationchange
Here are some of the structures and data used
The implementation of this function is still relatively simple, the first query to save the fs_change_notify_entry structure of the list iopfsnotifychangequeuehead, if you want to register the Driveobject and callback function address are the same, no longer duplicate registration , if it is not registered, allocates memory, fills the structure and inserts it into the tail of the linked list, then, that is, the implementation of the part we suspect, is indeed the various types of file system queues, which in turn invoke the callback function on the line file system activation notification.
Look at the implementation of the Iopnotifyalreadyregisteredfilesystems function:
Loop through the various types of file system queues, and then call the callback function to notify, at the time of judgment, the last node, and RAWFS together to judge, about Rawfs things, is not very clear, here do not explain.
Now, understand this problem, when the file system has been loaded, the registration file activation notification, is how to get notified.
In the file filter driver, the main application of this function is that when a new volume is to be mounted, how we mount it in real time, we can call the function, get the control device of each file system, then attach up, then the block device will send the file system control device when the device is mounted IRP_ Mj_file_system_control the IRP, after we mount the file system control device, we will be notified first, and then take out the VPB corresponding Realdeivce object stored up, when the IRP in the real file system control device is completed, We obtain the corresponding deviceobject based on the saved VPB, that is, the newly mounted volume device, so that it can be attach to the new volume device in real time, so that the new volume equipment can be controlled or designed in a timely manner.
[Reprint] File filter drive file system Activation notification Ioregisterfsregistrationchange function implementation