Partager via


3.2.4.3.8 Requesting a Lease on a File or a Directory

To request a lease, in addition to the parameters that are specified in section 3.2.4.3, the application provides a Boolean value indicating that a lease requires to be taken and a LeaseState value (as defined in section 2.2.13.2.8) that indicates the type of lease to be requested.<153>

The client MUST fail this request with STATUS_NOT_SUPPORTED in the following cases:

  • If Connection.Dialect is equal to "2.0.2".

  • If Connection.SupportsFileLeasing is FALSE.

  • If Connection.Dialect is equal to "2.1" and the application provided create options includes FILE_DIRECTORY_FILE.

The client MUST construct an SMB2 CREATE request as described in section 3.2.4.3, with a RequestedOplockLevel of SMB2_OPLOCK_LEVEL_LEASE.

If Connection.Dialect belongs to the SMB 3.x dialect family, the client MUST attach an SMB2_CREATE_REQUEST_LEASE_V2 create context to the request. The create context MUST be formatted as described in section 2.2.13.2.10 with the following values:

  • LeaseKey is set to File.LeaseKey obtained from section 3.2.4.3.

  • The client MUST search the GlobalFileTable for the parent directory of the file being opened. (The name of the parent directory is obtained by removing the last component of the path.) If any entry is found, ParentLeaseKey is obtained from File.LeaseKey of that entry and SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET bit MUST be set in the Flags field.

  • LeaseState value provided by the application. If the filename to be opened, followed by a ":" colon character and a stream name, indicates a named stream as defined in [MS-FSCC] section 2.1.5, the client SHOULD clear the SMB2_LEASE_HANDLE_CACHING bit in the LeaseState field.

  • Epoch SHOULD be set to 0.

If Connection.Dialect is equal to "2.1", the client MUST attach an SMB2_CREATE_REQUEST_LEASE create context to the request. The create context MUST be formatted as described in section 2.2.13.2.8, with the LeaseState value provided by the application.