Hi Keppler, You should put something like: struct vm_area_struct *tail_vma = NULL; tail_vma = get_gate_vma(tsk); // iterate over the vma while (vma && (vma != tail_vma)) { ... } For more details you can check how the m_start() and m_next() functions handle VMAs on fs/proc/task_mmu.c file. BR, Mauricio Lin. --- Keppler Alecrim <alecrim@xxxxxxxxx> escreveu: > Hi all , > I'm studying vma.This is my proc_read function and I want to > return vma > list information related with a current task. But , the loop(while > (vma)) > does not stop.What is wrong ? > Can anyone help me ? > > int my_get_info( char *buf, char **start, off_t off, int count ) > { > struct task_struct *tsk = current; > struct vm_area_struct *vma; > unsigned long ptdb; > int i = 0, len = 0; > > // display title > len += sprintf( buf+len, "\n\nList of the Virtual Memory > Areas " ); > len += sprintf( buf+len, "for task \'%s\' ", tsk->comm ); > len += sprintf( buf+len, "(pid=%d)\n", tsk->pid ); > > // loop to traverse the list of the task's vm_area_structs > vma = tsk->mm->mmap; > while ( vma ) > { > char ch; > len += sprintf( buf+len, "\n%3d ", ++i ); > len += sprintf( buf+len, " vm_start=%08lX ", > vma->vm_start > ); > len += sprintf( buf+len, " vm_end=%08lX ", > vma->vm_end ); > > ch = ( vma->vm_flags & VM_READ ) ? 'r' : '-'; > len += sprintf( buf+len, "%c", ch ); > > ch = ( vma->vm_flags & VM_WRITE ) ? 'w' : '-'; > len += sprintf( buf+len, "%c", ch ); > > ch = ( vma->vm_flags & VM_EXEC ) ? 'x' : '-'; > len += sprintf( buf+len, "%c", ch ); > > ch = ( vma->vm_flags & VM_SHARED ) ? 's' : 'p'; > len += sprintf( buf+len, "%c", ch ); > > vma = vma->vm_next; > } > len += sprintf( buf+len, "\n" ); > // display additional information about tsk->mm > asm(" movl %%cr3, %%ecx \n movl %%ecx, %0 " : "=m" (ptdb) ); > len += sprintf( buf+len, "\nCR3=%08lX ", ptdb ); > len += sprintf( buf+len, " mm->pgd=%p ", tsk->mm->pgd ); > len += sprintf( buf+len, " mm->map_count=%d ", > tsk->mm->map_count ); > len += sprintf( buf+len, "\n\n" ); > > return len; > > } > > My code is based on : http://www.cs.usfca.edu/~cruse/cs635/vma.c > > -- > -- > Francisco Keppler Silva Alecrim > Instituto Nokia de Tecnologia (INdT) > Open Source Mobile Research Center (OSMRC) > _______________________________________________________ Você quer respostas para suas perguntas? Ou você sabe muito e quer compartilhar seu conhecimento? Experimente o Yahoo! Respostas ! http://br.answers.yahoo.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/