Added special case when sorting hierarchically in MountInfoTable::read. It is legal to have entries in a `MountInfoTable` whose `entry.id` is the same as `entry.parent`. This can happen (for example), if a system boots from the network and then keeps the original `/` in RAM. However, to avoid cycles when walking the mount hierarchy, we should not treat these entries as children of their parent so we skip them.
This commit adds functionality to handle this case. Review: https://reviews.apache.org/r/52596/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1f04aee1 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1f04aee1 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1f04aee1 Branch: refs/heads/1.0.x Commit: 1f04aee1ed5376d2403818b71f373ca672b7ade1 Parents: ac3d9b8 Author: Kevin Klues <klue...@gmail.com> Authored: Wed Oct 12 22:33:56 2016 -0700 Committer: Jie Yu <yujie....@gmail.com> Committed: Wed Oct 12 22:46:36 2016 -0700 ---------------------------------------------------------------------- src/linux/fs.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/1f04aee1/src/linux/fs.cpp ---------------------------------------------------------------------- diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp index d4f2ac2..1cb329a 100644 --- a/src/linux/fs.cpp +++ b/src/linux/fs.cpp @@ -146,7 +146,16 @@ Try<MountInfoTable> MountInfoTable::read( foreach (const MountInfoTable::Entry& entry, parentToChildren[parentId]) { int newParentId = entry.id; sortedEntries.push_back(std::move(entry)); - sortFrom(newParentId); + + // It is legal to have a `MountInfoTable` entry whose + // `entry.id` is the same as its `entry.parent`. This can + // happen (for example), if a system boots from the network + // and then keeps the original `/` in RAM. To avoid cycles + // when walking the mount hierarchy, we only recurse into our + // children if this case is not satisfied. + if (parentId != newParentId) { + sortFrom(newParentId); + } } };