Tra parentesi, se l'obiettivo è ottenere nel tuo programma le informazioni che otterresti con ls, puoi usare le syscall dell'header dirent.h (man dirent.h e trovi tutto) unite alla syscall stat (man 2 stat).