gpt4 book ai didi

linux-kernel - 在进行系统调用时获取 'errno 38: function not implemented'

转载 作者:行者123 更新时间:2023-12-04 15:34:10 26 4
gpt4 key购买 nike

我正在尝试在 Linux 中编写系统调用。我修改了unistd.h , syscall_32.tblsys.c分别如下:

/*
#define __NR3264_fadvise64 223
__SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64)
*/
#define __NR_zslhello 223
__SYSCALL(__NR_zslhello, sys_zslhello)
223 i386 zslhello sys_zslhello
asmlinkage int sys_zslhello(int ret)
{
printk("Hello, my syscall!\n");
return ret;
}

编译内核后,我使用 syscall(223, 10000); ,返回值为 -1 ,以及 errno38 ,即该功能未实现。你对此有什么想法吗?

最佳答案

这是因为 syscall没有像名字所暗示的那样实现。在您的情况下,您的机器可能是 64 位的。所以你必须更改文件syscall_64.tbl不是 syscall_32.tbl .

在定义通用系统调用的文件的最后一行添加一行

x common zslhello sys_zslhello

在哪里 x是 1 加上公共(public)区域中的最后一个值。这就是我的 syscall_64.tbl 的片段好像。
330 common  pkey_alloc      sys_pkey_alloc
331 common pkey_free sys_pkey_free

#
# x32-specific system call numbers start at 512 to avoid cache impact
# for native 64-bit operation.
#
512 x32 rt_sigaction compat_sys_rt_sigaction
513 x32 rt_sigreturn sys32_x32_rt_sigreturn

就我而言 x是 332。干杯!

关于linux-kernel - 在进行系统调用时获取 'errno 38: function not implemented',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23520376/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com