简体   繁体   English

如何在内核中使用复制?

[英]How to use copyout in kernel?

In the kernel space I want to copy a character from the terminal and put it in a user space. 在内核空间中,我想从终端复制一个字符并将其放在用户空间中。

I am trying this code, but it's not working: 我正在尝试此代码,但无法正常工作:

char mychar;
int result;
mychar = getch();
result = copyout(&mychar, chptr, sizeof(mychr));

( chptr is a pointer to the user level space) chptr是指向用户级别空间的指针)

copyout is not returning 1. Does anyone know what the problem is? copyout未返回1.有人知道问题出在哪里吗?

Assuming a BSD-ish copyout : 假设有BSD式的copyout

RETURN VALUES
     The copy functions return 0 on success or EFAULT if a bad address is
      encountered. ...

In other words, you're just expecting something other than what it returns. 换句话说,您只期待返回的东西以外的东西。 :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM