Issue
I need to create a system call function to get all child folders of the directory. But, I don't have any idea to do that. Can you give me some keywords or advice to implement that?
asmlinkage long sys_get_child_folder(char* path, char** child_folder);
Solution
I'm smelling a XY problem; what is the actual problem you're trying to solve?
Why the heck do you want to create a new system call for that? Just open the directory, enumerate all its entries and filter out those, that are not directory inodes. The canonical way to do this is to use the opendir
function. https://linux.die.net/man/3/opendir
Also keep in mind that if you're writing code that's supposed to run inside the kernel, be aware that from inside the kernel, the ususal file system mechanisms are difficult to reach. The reason for that is, that filesystems spawn namespaces, which are depending on the task context; the only robust way to access files from within the kernel, is to have a userspace process open them and then hand the file descriptor to some kernel code. But this is strongly discouraged.
Answered By - datenwolf