'Error: modpost: "vfs_fstatat" undefined for kernl 5.10.113

I've developed a kernel module, have been built on kernel version 4.9 and 5.4, and works file. But when I try to build for kernel version 5.10.113, I got following error:

ERROR: modpost: "vfs_fstatat" [/home/jarvisbao/***/build/kernel/shman/shman.ko] undefined!

I used vfs_stat function to in a function as below:

int file_stat(char *path, struct kstat *st){
    mm_segment_t oldfs;
    int ret=0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
    oldfs = get_fs();
    set_fs( get_ds() );
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
    oldfs = get_fs();
    set_fs( KERNEL_DS );
#else
    oldfs = force_uaccess_begin();
#endif
    ret = vfs_stat(path, st);
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
    set_fs(oldfs);
#else
    force_uaccess_end(oldfs);
#endif
    return ret;
}

It seems there are some difference for calling vfs_stat between kernel version 5.10 and 5.4, but I don't know.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source