Page MenuHomeFreeBSD

makefs: count "." in the link count and size of dataset roots
Needs ReviewPublic

Authored by garga on Wed, Oct 7, 2:09 PM.

Details

Reviewers
markj
Summary

The root directory of a dataset is populated from an fsnode that is the
"." entry of the staging directory, and its children are the siblings of
that node, so the loop that computes the link count and the size of the
directory (which expects "." among the children, as the nodes of the
other directories have) never counts it. The link count of the root of
every dataset is one less than it should be (1 for an empty dataset
instead of 2, 19 instead of 20 for a root with 18 subdirectories), and
so is its size.

fts(3) trusts the link count of the directories of ZFS when called with
FTS_NOSTAT and FTS_PHYSICAL: it stops looking for subdirectories once it
has seen as many as the link count says, and does not descend into the
ones it did not look at. As a result find(1), and rm(1) when it does
not need to stat the entries, silently skip directories of a pool made
by makefs. On a root filesystem made by makefs, find / does not list
/etc at all.

Start the loop at the "." node itself for the roots of datasets, so that
it is counted the same way as in every other directory. Add a test that
checks the link counts and the sizes of the dataset roots and of the
other directories, with nested datasets and a dataset whose mountpoint
is not in the staging tree, and that find(1) sees the whole tree.

Fixes: 240afd8c1fc ("makefs: Add ZFS support")
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77811
Build 74694: arc lint + arc unit