3.2.4.18 Application Requests Change Notifications for a Directory

The application provides:

  • A handle to the Open identifying a directory.

  • The maximum output buffer it will accept.

  • A Boolean indicating whether the directory is monitored recursively.

  • The completion filter following the syntax specified in section 2.2.35, denoting which changes the application would like to be notified of.

If the application requires to be notified when changes occur and does not require to see the actual changes, the maximum output buffer MUST be set to 0.

If the handle is invalid, or if no Open referenced by the handle is found, the client MUST return an implementation-specific error code. If the handle is valid and Open is found, the client MUST proceed as follows.

For the specified Open, the client MUST select a connection as specified in section 3.2.4.1.7. If no connection is available, the client MUST fail the change notify operation.

Otherwise, the client initializes an SMB2 CHANGE_NOTIFY Request, following the syntax specified in section 2.2.37. The SMB2 header MUST be initialized as follows:

  • The Command field is set to SMB2 CHANGE_NOTIFY.

  • The MessageId field is set as specified in section 3.2.4.1.3.

  • The SessionId field is set to Open.TreeConnect.Session.SessionId.

  • The TreeId field is set to Open.TreeConnect.TreeConnectId.

The SMB2 CHANGE_NOTIFY Request MUST be initialized as follows:

  • The CompletionFilter field is set to the completion filter that is provided by the calling application.

  • The OutputBufferLength field is set to the maximum output buffer that the calling application will accept.

  • The FileId field is set to Open.FileId.

  • If the application requested that the directory be monitored recursively, the client sets SMB2_WATCH_TREE to TRUE in the Flags field.

The request MUST be sent to the server.