none
How to create/open a durable handle in an application? RRS feed

  • Question

  • I read the SMB2.0 SPEC from http://download.microsoft.com/download/a/e/6/ae6e4142-aa58-45c6-8dcf-a657e5900cd3/%5BMS-SMB2%5D.pdf. There is a description as below.

    "3.2.4.3 Application Requests Opening a File
    The application MUST provide:
    The name of the server on which to open the file.
    The name of the share on which to open the file.
    The security principal of the user performing the open.
    The share relative path to the file being opened.
    The wanted access for the open, as specified in section 2.2.13.1.
    The sharing mode for the open, as specified in section 2.2.13.
    The create options to be applied for the open, as specified in section 2.2.13.
    The create disposition for the open, as specified in section 2.2.13.
    The file attributes for the open, as specified in section 2.2.13.
    The impersonation level for the open, as specified in section 2.2.13 (optional).
    The security flags for the open, as specified in section 2.2.13 (optional).
    The requested oplock level or lease state for the open, as specified in section 2.2.13 (optional).
    As outlined in subsequent sections, the application may also provide a series of create contexts, as specified in section 2.2.13.2.

    3.2.4.3.5 Application Requests Creating a File Opened for Durable Operation
    To request durable operation on a file being opened or created, in addition to the parameters that are specified in section 3.2.4.3, the application MUST provide a Boolean indicating whether durability is requested. If the application is requesting durability, the client MUST construct a create context using the syntax specified in section 2.2.13.2.3. The client MUST append it to any other create contexts being issued and pass it in for create processing. If the application is not requesting durability, the client MUST follow the normal processing, as specified in section 3.2.4.3."

    I understand the normal file open. But what API should be used in an application in to create/open a durable handle? A native API such as NtCreateFile()? Or anything else? How to pass the durablility Boolean to the API call?

    Thanks a lot.


     
    Wednesday, January 7, 2009 6:58 PM

Answers

  •  

    As stated in [MS-SMB2] 3.2.4.5, the application requests durability in a context passed to the SMB2 CREATE Request. The context structure is defined in:

    2.2.13.2 SMB2_CREATE_CONTEXT Request Values

     

    To request durability on the SMB2 CREATE, you must set the NameOffset (2 bytes) to “DHnC”

    Value

     SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"

    Meaning

    The client is requesting to reconnect to a durable open after being disconnected (see section 3.3.5.9.7).

     

    For your reference, the SMB2 CREATE Request specifies the fields related to the request context.

    2.2.13 SMB2 CREATE Request

    CreateContextsOffset (4 bytes):  The offset, in bytes, from the beginning of the SMB2 header to the first 8-byte aligned SMB2_CREATE_CONTEXT structure in the request. If no SMB2_CREATE_CONTEXTs are being sent, this value MUST be 0.

    CreateContextsLength (4 bytes):  The length, in bytes, of the list of SMB2_CREATE_CONTEXT structures sent in this request.

     

    Regards,

    Edgar

    Friday, January 9, 2009 3:25 PM
    Moderator

All replies

  •  Good Afternoon
     I have alerted our Protocols Support team concerning your questions related to durable handle. One of our team members will be in contact with you soon.

    Regards, Obaid Farooqi
    Thursday, January 8, 2009 1:07 AM
    Owner
  •  

    As stated in [MS-SMB2] 3.2.4.5, the application requests durability in a context passed to the SMB2 CREATE Request. The context structure is defined in:

    2.2.13.2 SMB2_CREATE_CONTEXT Request Values

     

    To request durability on the SMB2 CREATE, you must set the NameOffset (2 bytes) to “DHnC”

    Value

     SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"

    Meaning

    The client is requesting to reconnect to a durable open after being disconnected (see section 3.3.5.9.7).

     

    For your reference, the SMB2 CREATE Request specifies the fields related to the request context.

    2.2.13 SMB2 CREATE Request

    CreateContextsOffset (4 bytes):  The offset, in bytes, from the beginning of the SMB2 header to the first 8-byte aligned SMB2_CREATE_CONTEXT structure in the request. If no SMB2_CREATE_CONTEXTs are being sent, this value MUST be 0.

    CreateContextsLength (4 bytes):  The length, in bytes, of the list of SMB2_CREATE_CONTEXT structures sent in this request.

     

    Regards,

    Edgar

    Friday, January 9, 2009 3:25 PM
    Moderator