I think @Ondriy and @twalberg has already given the answer. But still I am adding some explanation.
There are different way through which we can interact with kernel space.
Syscall: In Linux kernel each system call is assigned a unique syscall number. Like open() -> __NR_open,close() -> __NR_exit,read() -> __NR_read.
IOCTL: There are already predefined ictl number in the kernel. So by using these number you can interact with kernel space. e.g. ioctl(/dev/i2c-0,I2C_SMBUS,address);
Netlink Socket: Through netlink socket you can pass the message from kernel space to user space. e.g socket(), bind(), sendmsg().
Sysfs/procfs: You can communicate with the kernel through sysfs as well proc fs. (Have a look into /sys/* folder).
But if you are looking particular only for ls command then I think you can follow the below link.
How does the 'ls' command work in Linux/Unix?