Skip to content

Commit 9f5bae7

Browse files
ppennaCopilot
andcommitted
doc: say that virtio-fs listings leave out entries that lookups refuse
The host filesystem's design said that the first directory read on a handle lists the host directory without the entries that the access policy hides, and that a name longer than 255 bytes fails the listing with EINVAL, whether the policy hides it or not. OpenVMM also failed the listing for an entry whose name the share refuses, such as one with a colon or a backslash, or whose path exceeds 4,096 bytes, so a single such entry kept the guest from listing any entry of its directory (#2133). With the OpenVMM fix, a listing also leaves out the entries whose names or paths every lookup refuses: names longer than 255 bytes, which no FUSE request carries, names that the share refuses, and paths longer than 4,096 bytes. Say so, and say that READDIRPLUS omits a listed name whose path a rename of an ancestor has since made too long rather than fail at it, so that only the bounds on nodes and names still fail it at an entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e83d21e commit 9f5bae7

1 file changed

Lines changed: 21 additions & 18 deletions

File tree

‎doc/design/3.6-host-filesystem.md‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,20 @@ without a handle when `fstat` of an unlinked file misses its attribute cache.
242242
descriptor, opened without following the final component, which every request
243243
that names the handle uses and `RELEASE` closes. The first directory read on a
244244
handle enumerates the host directory once into a listing of at most 4,096
245-
entries and 64 KiB of names, without the entries that the policy hides,
246-
which count toward neither bound, and later reads page through that
247-
listing. Listing a directory that shows more fails with `E2BIG`, and one
248-
that holds a name longer than 255 bytes fails with `EINVAL`, whether the
249-
policy hides the name or not. The listings of all handles hold at most
250-
16,384 entries and 4 MiB of names together, as many as a snapshot saves,
251-
so a first read that would exceed them fails with `ENOSPC` until the guest
252-
releases listed handles. Each entry's cookie is its position in the
253-
listing, so a listing survives a snapshot. `READDIRPLUS` looks each listed
254-
name up again. It omits a name that
255-
no longer exists, as after an unlink or a rename, or whose lookup the policy
245+
entries and 64 KiB of names, and later reads page through that listing. The
246+
listing leaves out, wherever the host lists them, the entries whose paths the
247+
policy hides and those whose names or paths every lookup refuses, which count
248+
toward neither bound: names longer than 255 bytes, which no FUSE request
249+
carries, names that the share refuses, such as one that holds a colon or a
250+
backslash, and paths longer than 4,096 bytes. Failing the listing instead
251+
would hide every other entry of the directory. Listing a directory that shows
252+
more fails with `E2BIG`. The listings of all handles hold at most 16,384
253+
entries and 4 MiB of names together, as many as a snapshot saves, so a first
254+
read that would exceed them fails with `ENOSPC` until the guest releases
255+
listed handles. Each entry's cookie is its position in the listing, so a
256+
listing survives a snapshot. `READDIRPLUS` looks each listed name up again. It
257+
omits a name that no longer exists, as after an unlink or a rename, whose path
258+
a rename of an ancestor has since made too long, or whose lookup the policy
256259
refuses, as for a host hard link to a hidden file, and fails at a name on the
257260
directory's own host device that no longer reaches the listed object. The host
258261
lists a mount point or a btrfs subvolume by the number of another object, such
@@ -271,13 +274,13 @@ a replacement that races the request. A name that the host lists by another
271274
number, as after a rename over it, no longer reaches the listed object. Each
272275
entry that `READDIRPLUS` returns with a node adds a lookup, which the guest can
273276
forget only if it receives the entry, so a `READDIRPLUS` that fails at an
274-
entry, at such a name or at the bounds below, returns the entries before it and
275-
reports the error to the next read, which starts at that entry. The entry of a
276-
name whose lookup reaches the object of the handle's own node, as a bind mount
277-
of the directory on one of its own subdirectories does, has no node, as those
278-
of `.` and `..` have none: the guest cannot hold a directory below itself, and
279-
adding the name to the node would move the node below itself, where the server
280-
would look the rest of the listing up.
277+
entry, at such a name or at the bounds on nodes and names below, returns the
278+
entries before it and reports the error to the next read, which starts at that
279+
entry. The entry of a name whose lookup reaches the object of the handle's own
280+
node, as a bind mount of the directory on one of its own subdirectories does,
281+
has no node, as those of `.` and `..` have none: the guest cannot hold a
282+
directory below itself, and adding the name to the node would move the node
283+
below itself, where the server would look the rest of the listing up.
281284

282285
A request through a handle must also name the handle's node, which the guest
283286
must still hold, because the node's recorded names decide what the request may

0 commit comments

Comments
 (0)