I am trying to use a modified getchar
function on a linux kernel for an operating system, to get characters from a string given from the terminal, and then print it, but every other time I call it, it seems to basically return an empty string.
kernel level space:
int sys_readchar(userptr_t chptr, it *retval) {
char ch;
int result;
ch = getch();
copyout(&ch, chptr, sizeof(ch));
*retval=1;
return 0;
}
user level:
int getchar(void) {
char ch;
int len;
len = readchar(&ch);
return (int)(unsigned char)ch;
}
Does anyone know what's wrong?
Thanks.