Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Feb 2006
Copying a struct from kernel(module) to userland using /proc, how?
I'm trying to copy a struct from the a kernel module to userland. I can copy a struct from userland to the module doing this in the user program:
void write_procfile() /* Test for struct copy */
if((fp = fopen("/proc/nf_lb", "wb")) == NULL)
printf("Error opening /proc/nf_lb for writing.\n");
} /* open /proc/nf_lb for writing */
if((fwrite(&input, sizeof (struct user_input), 1, fp)) != 1)
printf("An error has occured. Please make sure to specify correct options.\n");
fclose(fp); /* close the file */
/* write data to the buffer*/
if (copy_from_user((char *) &input, buffer, sizeof(struct user_input)))
Any ideas? I suppose I'm looking for a function like userlands fwrite().
Thanks for any help,
Did you try with copy_to_user? That appears to be the standar way to write data from kernel space to user space. At least it works with plain text.