copy_from_user does not copy from process-heap


 
Thread Tools Search this Thread
Operating Systems Linux copy_from_user does not copy from process-heap
# 1  
Old 08-16-2009
copy_from_user does not copy from process-heap

Hello all,
I need a positive reply from you.
I want to copy the user-process-heap to the kernel space memory.
For that, I wrote the following code but it does not copy.
---------------- code --------------
unsigned long length_of_heap_vma = < length of vma pointing to process-heap > ;
void * kernel_mem = (void *) kmalloc(length_of_heap_vma,GFP_KERNEL);
unsigned long bytes_not_copied = 0;

bytes_not_copied = copy_from_user(kernel_mem,(void *)vm->vma_start,length_of_heap_vma);//vm points to process heap
printk("failed to copy %ld bytes.",bytes_not_copied); //it always displays a non-zero value.
---------------- end of code --------

now the PROBLEM is that - the code successfuly compiles, but when I execute it, it copies not a single byte and
bytes_not-copied always becomes equal to length_of_heap_vma. No compile-time or execution-time error occurs.
(note: my process has the following dynamic memory in user-part:
int * p = (int*) malloc(5 * sizeof(int));
for(i=0;i<5;i++)
p[i]= i;
)
# 2  
Old 08-16-2009
I am hardly an expert in kernel code, but my understanding is there is a translation step between process addresses and kernel addresses.
# 3  
Old 08-17-2009
No, copy_from_user( ) function does not require such logical to physical translation.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Sudden rise in heap memory of a process

Hi, There is a abrupt memory rise observed for a process on solaris. When the process is started the memory is around 268 MB and is stable for a day. Then suddenly the memory increased to 4364 MB. Below is the pmap -xs output for the process (only for heap) Address Kbytes ... (1 Reply)
Discussion started by: Nidds
1 Replies

2. UNIX for Advanced & Expert Users

Copy files without affecting the running process

Hi Experts, I would like to know in Linux any command which will replace a file without affecting the running process. I tried the mv command bug the running process is not taking the new file. Any rsync option is available like this for not affecting the current process. Thanks in... (7 Replies)
Discussion started by: ThobiasVakayil
7 Replies

3. Shell Programming and Scripting

check if some file is in copy process, then transfer it

my user copy large files, and it's take 10min for file to be copied to the server (/tmp/user/ files/), if in the meantime start my scheduled script, then it will copy a part of some file to server1 my idea is to check the file size twice in a short period (1-2 seconds) of time, then compare, if... (5 Replies)
Discussion started by: waso
5 Replies

4. Shell Programming and Scripting

Ensure file copy is complete before starting process

Hi experts, I have a requirement wherein a user is uploading a file to the Landing directory on one of our Linux servers. A cron job is scheduled to run after every 5 minutes which will pick up the files from the source (Landing) dir and copy to the target dir, and once successfully copied to... (4 Replies)
Discussion started by: adi_2_chaos
4 Replies

5. Shell Programming and Scripting

Shell Script, Copy process using find.

Ok, so here is what I am looking for.. Shell script that uses find to look for one days worth of data using the modified date and then copies only those files to a specified directory. I figured I could use grep and the find command to do this. It seems to work just fine from what I can... (4 Replies)
Discussion started by: techjunky
4 Replies

6. Programming

C program to make an exact copy of the current process in Ubundu

Hi All, I am new to Linux and i need your for a program which makes the exact copy of the running process. I have got some codes but it only works for the first command and will not work for subsequent commands. Means it works for "ps" but will not work for "ps u". I have changed the code to... (1 Reply)
Discussion started by: subhash007
1 Replies

7. HP-UX

Heap fragementation on HPUX

The Resident size(as observed from top) of my process is increasing. But, the behaviour is very random. My process works on request reponse model. So when i put some request load on my process the memory starts increasing. For initial few hours (approx ~3 hrs) it increase at a rapid rate and after... (1 Reply)
Discussion started by: atgoel
1 Replies

8. Programming

Heap and stack

Hi, I have a basic doubt here. Consider the following code snippet: main() { int *a; . . } Here the memory for a gets allocated in heap or stack. (5 Replies)
Discussion started by: naan
5 Replies

9. Filesystems, Disks and Memory

heap size for JVM!

Hi all, Thanks 'thehoghunter' and 'hugo' for the comments! I've to increase the size of the heap size for AIX 4.3.3. Now what's the command that I've and also is it something similar to growing the file system in Solaris (growfs) (1 Reply)
Discussion started by: i2admin
1 Replies

10. Filesystems, Disks and Memory

heap size!

I'm a new guy to this field and I'm learning a lot about UNIX! Can any explan to me what exactly does 'heap size' mean and how can i increase the size for AIX 4.3.3? (2 Replies)
Discussion started by: i2admin
2 Replies
Login or Register to Ask a Question