Sorting 获取scandir系统调用以使用户定义的比较函数正常工作?

Sorting 获取scandir系统调用以使用户定义的比较函数正常工作?,sorting,system-calls,scandir,Sorting,System Calls,Scandir,我的任务是扫描一个目录,并根据几个标准(如大小、修改时间等)对其进行排序。查看scandir的手册页,显示 SYNOPSIS #include <dirent.h> int scandir(const char *dirp, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const struct dirent **,

我的任务是扫描一个目录,并根据几个标准(如大小、修改时间等)对其进行排序。查看
scandir
的手册页,显示

 SYNOPSIS
   #include <dirent.h>

   int scandir(const char *dirp, struct dirent ***namelist,
          int (*filter)(const struct dirent *),
          int (*compar)(const struct dirent **, const struct dirent **));
因此,我想知道如何使用函数指针(第四个参数)并根据文件大小进行排序

我可以从dirent指针获取inode编号,但似乎无法仅使用系统调用来查找只有inode编号的文件详细信息。不允许使用系统库(exec)

有什么提示吗

lstat((*d1)->d_name, &sb1);
lstat((*d2)->d_name, &sb2);