So it seems like the most robust way to handle this would be to at the top of remove_tree do something like: fd = open(root); ret = fstat(fd, &sb); if (S_ISLNK(fd)) return -1; // or unlink it, but warning the admin seems best DIR = fopendir(fd); Is there another approach?