Bharata Rao posted a query to the Linux Kernel mailing list looking for ideas on how to best handle filesystem namespace unification with Union Mount, "typically this is done by reading the directory entries of all the union'ed layers (starting from the top and working downwards) and merging the result by eliminating the duplicate entries. This is done by extending the getdents/readdir system calls to support the notion of union'ed directories." He went on to describe a few different methods they were considering for implementation noting, "he main problem in getting a sane readdir() implementation in Union Mount is the fact that a single vfs object (file structure) is used to represent more than one (underlying) directory. Because of this, it is unclear as to how lseek(2) needs to behave in such cases."
Two other similar solutions were discussed, aufs and UnionFS. In response to the Bharata's questions, Erez Zadok explained, "in the long run, storing a cache of the readdir state on disk, is the best approach by far. Since you already spend the CPU and memory resources to create a merged view, storing it on disk as a contiguous file isn't that much more effort. That effort pays off later on esp. if the directories don't change often"