2.1.4.1 Algorithm for Reporting a Change Notification for a Directory or View Index
The inputs for this algorithm are:
Volume: The volume this event occurs on.
Action: A 32-bit unsigned integer describing the action that caused the change events to be notified, as specified in [MS-FSCC] section 2.7.1.
FilterMatch: A 32-bit unsigned integer field with flags representing possible change events, corresponding to a ChangeNotifyEntry.CompletionFilter. It is specified in [MS-SMB2] section 2.2.35.
FileName: The pathname, relative to Volume.RootDirectory, of the file involved in the change event.
NotifyData: A binary data structure containing information specific to the ViewIndexFile being monitored. This is an optional parameter, specified only for ViewIndexFile notifications.
NotifyDataLength: The length, in bytes, of NotifyData. This is an optional parameter, specified only for ViewIndexFile notifications.
Pseudocode for the algorithm is as follows:
For each ChangeNotifyEntry in Volume.ChangeNotifyList:
Initialize SendNotification to FALSE.
If NotifyData is specified: // this is a ViewIndexFile notification
If ChangeNotifyEntry.OpenedDirectory.File matches the File whose pathname is FileName, then SendNotification MUST be set to TRUE.
Else: // this is a DirectoryFile notification
If ChangeNotifyEntry.OpenedDirectory.File matches the File whose pathname is FileName or matches the immediate parent of this File and one or more of the flags in FilterMatch are present in ChangeNotifyEntry.CompletionFilter, then SendNotification MUST be set to TRUE.
Else If ChangeNotifyEntry.WatchTree is TRUE and ChangeNotifyEntry.OpenedDirectory.File matches an ancestor of the File whose pathname is FileName and one or more of the flags in FilterMatch are present in ChangeNotifyEntry.CompletionFilter, then SendNotification MUST be set to TRUE.
EndIf
If SendNotification is TRUE:
A NotifyEventEntry object MUST be constructed with:
NotifyEventEntry.Action set to Action.
If NotifyData is specified: // this is a ViewIndexFile notification
NotifyEventEntry.FileName set to NotifyData.
NotifyEventEntry.FileNameLength set to NotifyDataLength.
Else: // this is DirectoryFile notification
NotifyEventEntry.FileName set to the portion of FileName relative to ChangeNotifyEntry.OpenedDirectory.FileName.
NotifyEventEntry.FileNameLength set to the length, in bytes, of NotifyEventEntry.FileName.
EndIf
Insert NotifyEventEntry into ChangeNotifyEntry.NotifyEventList.
Processing will be performed as described in section 2.1.5.11.1.
EndIf
EndFor