changed ls function from void to int, returned errno if failed in main