On Sun, May 12, 2013 at 09:31:38PM -0700, Luis R. Rodriguez wrote:

> This implementation uses recursion then if subdirs are found
> otherwise it treats it as a regular remove_proc_entry()

Ugh...  What for?  It's not as if traversing the damn thing had
been complicated:
        de = root = root of subtree to be killed
        unlink de
        while true
                /* de is already unlinked */
                if de has children
                        child = first child of de
                        unlink child
                        de = child
                else
                        /* de can be killed now */
                        parent = parent of de
                        kill de
                        if de == root
                                return
                        de = parent
and that's it.  Why bother with recursion, chew stack space, etc.?
We do depth-first walk through the tree, unlinking the nodes from the
lists of children on the way in and freeing them on the way out.

The difference from your variant is that you use the stack to hold
pointers to ancestors of the current victim.  You get to the parent
of said victim by discarding a stack frame.  No need, since the
victim contained an explicit pointer to its parent...
--
To unsubscribe from this list: send the line "unsubscribe backports" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to