How to split a VMA.

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

 



Hi, 
I am trying to write a system call that splits a VMA into two halves. The problem is that, as I am using do_mmap() system call, it is only creating one area and that too at a different address than the old one.

The code:
(*addr is passed as some arbitrary address that falls in any VMA)

struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
unsigned long ret, ret2, old_length,length, start_add, end_add,     second_add;

 
        if (flag == 0) {
                vma = (struct vm_area_struct *) kmalloc(sizeof(struct vm_area_struct));
                vma = find_vma(mm, *addr);
                if (vma == NULL){
                        return ENOMEM;
                }
                old_length = (vma->vm_end - vma->vm_start);
                length = old_length/2;
                start_add = PAGE_ALIGN(vma->vm_start);
                end_add = PAGE_ALIGN(vma->vm_end);
                second_add = PAGE_ALIGN(start_add + length);
                ret = do_mremap(start_add, old_length, length, NULL, NULL);
                ret2 = do_mmap(NULL, second_add, length, PROT_READ, MAP_EXECUTABLE, 0);
               
        } 


Is there anything that i m doing wrong over here .. 

Thanks and Regards,
Narinder


[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