Fix directory listing (implementation copied from x11/).