Compartir a través de


2.1.5.1.2.2 Algorithm to Check Sharing Access to an Existing Stream or Directory

The inputs to the algorithm are:

  • Open: The Open for an in-progress Open operation to an existing stream or directory.

On completion, the algorithm returns:

  • Status: An NTSTATUS code that specifies the result of the sharing check.

The object store MUST perform sharing checks when opening an existing stream or directory.

Pseudocode for these checks is as follows:

  • If AccessCheck(SecurityContext, Open.Link.ParentFile.SecurityDescriptor, FILE_WRITE_DATA) returns FALSE, the object store MUST set Open.SharingMode.FILE_SHARE_READ to TRUE.

  • If DesiredAccess contains any of (FILE_READ_DATA | FILE_EXECUTE | FILE_WRITE_DATA | FILE_APPEND_DATA | DELETE):

    • For each ExistingOpen in Open.File.OpenList:

      • If ExistingOpen.Stream equals Open.Stream and ExistingOpen.GrantedAccess contains any of (FILE_READ_DATA | FILE_EXECUTE | FILE_WRITE_DATA | FILE_APPEND_DATA | DELETE), then return STATUS_SHARING_VIOLATION under any of the following conditions:

        • If ExistingOpen.SharingMode.FILE_SHARE_READ is FALSE and Open.GrantedAccess contains either FILE_READ_DATA or FILE_EXECUTE

        • If ExistingOpen.SharingMode.FILE_SHARE_WRITE is FALSE and Open.GrantedAccess contains either FILE_WRITE_DATA or FILE_APPEND_DATA

        • If ExistingOpen.SharingMode.FILE_SHARE_DELETE is FALSE and Open.GrantedAccess contains DELETE

        • If Open.SharingMode.FILE_SHARE_READ is FALSE and ExistingOpen.GrantedAccess contains either FILE_READ_DATA or FILE_EXECUTE

        • If Open.SharingMode.FILE_SHARE_WRITE is FALSE and ExistingOpen.GrantedAccess contains either FILE_WRITE_DATA or FILE_APPEND_DATA

        • If Open.SharingMode.FILE_SHARE_DELETE is FALSE and ExistingOpen.GrantedAccess contains DELETE

      • EndIf

    • EndFor

  • EndIf

  • If Open.Stream.Oplock is not empty, the object store MUST check for an oplock break according to the algorithm in section 2.1.4.12, with input values as follows:

    • Open equal to this operation's Open

    • Oplock equal to Open.Stream.Oplock

    • Operation equal to "OPEN"

    • OpParams containing two members:

      • DesiredAccess equal to this operation's DesiredAccess

      • CreateDisposition equal to this operation's CreateDisposition

    • EndIf

    • Return STATUS_SUCCESS.