Comment 11 for bug 1476662

Quoting Tyler Hicks (<email address hidden>):
> On 2015-07-30 18:46:50, Serge Hallyn wrote:
> > Yup, that race is there in theory. This appears to be yet another
> > reason to push for a 'fdmount/mountat' function. But lacking that I'm
> > not sure how we can prevent this.
> >
> > Do you have any suggestions?
>
> You could split all of the path components up into an array (or however
> you want to iterate over them) and then walk each component of the path
> like so:
>
> for (component = components[0]; component; component++) {
> fd = open(dirfd, component,
> O_CLOEXEC | O_NOFOLLOW | O_DIRECTORY | O_RDONLY);
> fchdir(fd);
> close(dirfd);
> dirfd = fd;
> }
> close(fd);
> mount(source, ".", ...);

Haha. I guess that works :) mount with '.' was escaping me - thanks!