Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linux/linux_mmap.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | linux_mmap_check_fp(struct file *fp, int flags, int prot, int maxprot) | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot, | linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot, | ||||
int flags, int fd, off_t pos) | int flags, int fd, off_t pos) | ||||
{ | { | ||||
struct mmap_req mr; | |||||
struct proc *p = td->td_proc; | struct proc *p = td->td_proc; | ||||
struct vmspace *vms = td->td_proc->p_vmspace; | struct vmspace *vms = td->td_proc->p_vmspace; | ||||
int bsd_flags, error; | int bsd_flags, error; | ||||
struct file *fp; | struct file *fp; | ||||
LINUX_CTR6(mmap2, "0x%lx, %ld, %ld, 0x%08lx, %ld, 0x%lx", | LINUX_CTR6(mmap2, "0x%lx, %ld, %ld, 0x%08lx, %ld, 0x%lx", | ||||
addr, len, prot, flags, fd, pos); | addr, len, prot, flags, fd, pos); | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | #endif | ||||
/* | /* | ||||
* FreeBSD is free to ignore the address hint if MAP_FIXED wasn't | * FreeBSD is free to ignore the address hint if MAP_FIXED wasn't | ||||
* passed. However, some Linux applications, like the ART runtime, | * passed. However, some Linux applications, like the ART runtime, | ||||
* depend on the hint. If the MAP_FIXED wasn't passed, but the | * depend on the hint. If the MAP_FIXED wasn't passed, but the | ||||
* address is not zero, try with MAP_FIXED and MAP_EXCL first, | * address is not zero, try with MAP_FIXED and MAP_EXCL first, | ||||
* and fall back to the normal behaviour if that fails. | * and fall back to the normal behaviour if that fails. | ||||
*/ | */ | ||||
mr = (struct mmap_req) { | |||||
brooks: We could alternatively do the declaration above and assign with a compound literal here. Style… | |||||
.mr_hint = addr, | |||||
.mr_len = len, | |||||
.mr_prot = prot, | |||||
.mr_flags = bsd_flags, | |||||
.mr_fd = fd, | |||||
.mr_pos = pos, | |||||
.mr_check_fp_fn = linux_mmap_check_fp | |||||
kibUnsubmitted Done Inline Actionsend line with comma, as we usually do ? kib: end line with comma, as we usually do ? | |||||
}; | |||||
if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && | if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && | ||||
(bsd_flags & MAP_EXCL) == 0) { | (bsd_flags & MAP_EXCL) == 0) { | ||||
error = kern_mmap_fpcheck(td, addr, len, prot, | struct mmap_req mr_fixed = mr; | ||||
bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos, | mr_fixed.mr_flags |= MAP_FIXED | MAP_EXCL; | ||||
linux_mmap_check_fp); | error = kern_mmap_req(td, &mr_fixed); | ||||
Done Inline ActionsI do not see why mr_fixed needs to be defined there and not at the start of the function. kib: I do not see why mr_fixed needs to be defined there and not at the start of the function.
If… | |||||
Done Inline ActionsThis comment is still relevant. kib: This comment is still relevant. | |||||
if (error == 0) | if (error == 0) | ||||
goto out; | goto out; | ||||
} | } | ||||
error = kern_mmap_fpcheck(td, addr, len, prot, bsd_flags, fd, pos, | error = kern_mmap_req(td, &mr); | ||||
linux_mmap_check_fp); | |||||
out: | out: | ||||
LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); | LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
linux_mprotect_common(struct thread *td, uintptr_t addr, size_t len, int prot) | linux_mprotect_common(struct thread *td, uintptr_t addr, size_t len, int prot) | ||||
Show All 27 Lines |
We could alternatively do the declaration above and assign with a compound literal here. Style(9) doesn't really have an opinion.