Question

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)

copyout is not returning 1. Does anyone know what the problem is?

Was it helpful?

Solution

Assuming a BSD-ish 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. :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top