Skip to content

Commit

Permalink
Support locking of directory entries
Browse files Browse the repository at this point in the history
Moves the locking algorithm from file entry to file system entry.

Fixes whatwg#137
  • Loading branch information
Nathan Memmott committed Jul 11, 2023
1 parent f428b36 commit fad217a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ To <dfn for="file system entry/lock">take</dfn> a [=file system entry/lock=] wit

1. Let |lock| be the |entry|'s [=file system entry/lock=].
1. Let |count| be the |entry|'s [=file system entry/shared lock count=].
1. Let |hasDescendantLock| be the result of [=file system entry/lock/checking for a descendant lock=] on |entry|.
1. If |hasDescendantLock| is true:
1. Return "`failure`".
1. If |value| is "`exclusive`":
1. If |lock| is "`open`":
1. Set lock to "`taken-exclusive`".
Expand All @@ -153,6 +156,24 @@ Note: These steps have to be run on the [=file system queue=].

</div>

<div algorithm>
To <dfn for="file system entry/lock">check for a descendant lock</dfn> on a given
[=/file system entry=] |entry|:

1. Let |lock| be the |entry|'s [=file system entry/lock=].
1. If |lock| is not "`open`":
1. Return true.
1. If |entry| is a [=directory entry=]:
1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. Let |hasDescendantLock| be the result of [=file system entry/lock/checking for a descendant lock=] on |child|.
1. If |hasDescendantLock| is true:
1. Return true.
1. Return false.

Note: These steps have to be run on the [=file system queue=].

</div>

<div algorithm>
To <dfn for="file system entry/lock">release</dfn> a [=file system entry/lock=] on a given
[=/file system entry=] |entry|:
Expand Down

0 comments on commit fad217a

Please sign in to comment.