Changing lsdir to consistently return an slist

This is a backport of 6807e0dda5bd265c9bbee631fffb2ec0aa68adaa to the
3.4.x branch.