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 12, 2023
1 parent 9c645b0 commit 639c9e5
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ To <dfn for="file system entry/lock">take a lock</dfn> with a |value| of

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 |descendantLockStatus| be the result of [=file system entry/lock/checking for a descendant lock=] on |entry|.
1. If |descendantLockStatus| is "`taken`":
1. Return "`failure`".
1. If |entry| is a [=directory entry=]:
1. Let |descendantLockStatus| be the result of [=file system entry/lock/checking for a descendant lock=] on |entry|.
1. If |descendantLockStatus| is "`taken`":
1. Return "`failure`".
1. If |value| is "`exclusive`":
1. If |lock| is "`open`":
1. Set lock to "`taken-exclusive`".
Expand All @@ -158,16 +159,16 @@ Note: These steps have to be run on the [=file system queue=].

<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 "`taken`".
1. If |entry| is a [=directory entry=]:
1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. Let |descendantLockStatus| be the result of [=file system entry/lock/checking for a descendant lock=] on |child|.
1. If |descendantLockStatus| is "`taken`":
1. Return "`taken`".
[=directory entry=] |directory|:

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

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

0 comments on commit 639c9e5

Please sign in to comment.