Re: copying linked lists structs to kernelland

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 06, 2003 at 11:35:43AM +0200, Jonathan Heusser wrote:
> How do I copy best a data structure which contains two or more linked 
> list heads (a la linux/list.h) plus some other fields to kernelland?
> Obviously a simple copy_from_user(new_struct,  (struct my_struct*) data, 
> sizeof(struct my_struct)).. does not work.

You'll need to do what is known as a "deep copy". For each struct
member that is a pointer, you will need to decide if you should copy the
data pointed to by the pointer, or ignore the value as being worthless
on the other end of the copy, or store a placeholder value that you can
use to help you figure out the correct value on the other end of the
copy.

Handle those elements specifically and magically.

Look at kernel/fork.c do_fork(), the bits about copy_files() and so
forth, for a specific example on one way to handle "deep copies".

-- 
http://sardonix.org/

Attachment: pgp00362.pgp
Description: PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux