Pass in file offset into mmap() handlers.
authorKanoj Sarcar' via Akaros <akaros@googlegroups.com>
Sat, 30 Jan 2016 00:25:32 +0000 (16:25 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sat, 30 Jan 2016 01:34:19 +0000 (20:34 -0500)
Signed-off-by: Kanoj Sarcar <kanoj@google.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/mm.c

index 2ad0f7d..7b7e542 100644 (file)
@@ -636,6 +636,7 @@ void *do_mmap(struct proc *p, uintptr_t addr, size_t len, int prot, int flags,
        addr = vmr->vm_base;
        vmr->vm_prot = prot;
        vmr->vm_flags = flags;
+       vmr->vm_foff = offset;
        if (file) {
                if (!check_file_perms(vmr, file, prot)) {
                        assert(!vmr->vm_file);
@@ -669,7 +670,6 @@ void *do_mmap(struct proc *p, uintptr_t addr, size_t len, int prot, int flags,
                pm_add_vmr(file2pm(file), vmr);
        }
        vmr->vm_file = file;
-       vmr->vm_foff = offset;
        vmr = merge_me(vmr);            /* attempts to merge with neighbors */
 
        if (flags & MAP_POPULATE && prot != PROT_NONE) {