Deleted Added
full compact
30c30
< __FBSDID("$FreeBSD: head/sys/i386/linux/linux_machdep.c 166395 2007-02-01 13:27:52Z kib $");
---
> __FBSDID("$FreeBSD: head/sys/i386/linux/linux_machdep.c 166727 2007-02-15 00:54:40Z jkim $");
587,596d586
< /* XXX move */
< struct l_mmap_argv {
< l_caddr_t addr;
< l_int len;
< l_int prot;
< l_int flags;
< l_int fd;
< l_int pos;
< };
<
614c604
< linux_args.addr = (l_caddr_t)args->addr;
---
> linux_args.addr = args->addr;
619c609
< linux_args.pos = args->pgoff * PAGE_SIZE;
---
> linux_args.pgoff = args->pgoff * PAGE_SIZE;
638c628
< linux_args.flags, linux_args.fd, linux_args.pos);
---
> linux_args.flags, linux_args.fd, linux_args.pgoff);
682c672
< if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
---
> if (linux_args->flags & LINUX_MAP_GROWSDOWN)
684a675,709
> /*
> * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC
> * on Linux/i386. We do this to ensure maximum compatibility.
> * Linux/ia64 does the same in i386 emulation mode.
> */
> bsd_args.prot = linux_args->prot;
> if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
> bsd_args.prot |= PROT_READ | PROT_EXEC;
>
> if (linux_args->fd != -1) {
> /*
> * Linux follows Solaris mmap(2) description:
> * The file descriptor fildes is opened with
> * read permission, regardless of the
> * protection options specified.
> */
>
> if ((error = fget(td, linux_args->fd, &fp)) != 0)
> return (error);
> if (fp->f_type != DTYPE_VNODE) {
> fdrop(fp, td);
> return (EINVAL);
> }
>
> /* Linux mmap() just fails for O_WRONLY files */
> if (!(fp->f_flag & FREAD)) {
> fdrop(fp, td);
> return (EACCES);
> }
>
> fdrop(fp, td);
> }
> bsd_args.fd = linux_args->fd;
>
> if (linux_args->flags & LINUX_MAP_GROWSDOWN) {
707,710c732,733
< /* This gives us TOS */
< bsd_args.addr = linux_args->addr + linux_args->len;
<
< if (bsd_args.addr > p->p_vmspace->vm_maxsaddr) {
---
> if ((caddr_t)PTRIN(linux_args->addr) + linux_args->len >
> p->p_vmspace->vm_maxsaddr) {
746c769,770
< bsd_args.addr -= bsd_args.len;
---
> bsd_args.addr = (caddr_t)PTRIN(linux_args->addr) -
> bsd_args.len;
748c772
< bsd_args.addr = linux_args->addr;
---
> bsd_args.addr = (caddr_t)PTRIN(linux_args->addr);
751,784c775
<
< bsd_args.prot = linux_args->prot;
< if (linux_args->flags & LINUX_MAP_ANON)
< bsd_args.fd = -1;
< else {
< /*
< * Linux follows Solaris mmap(2) description:
< * The file descriptor fildes is opened with
< * read permission, regardless of the
< * protection options specified.
< * If PROT_WRITE is specified, the application
< * must have opened the file descriptor
< * fildes with write permission unless
< * MAP_PRIVATE is specified in the flag
< * argument as described below.
< */
<
< if ((error = fget(td, linux_args->fd, &fp)) != 0)
< return (error);
< if (fp->f_type != DTYPE_VNODE) {
< fdrop(fp, td);
< return (EINVAL);
< }
<
< /* Linux mmap() just fails for O_WRONLY files */
< if (! (fp->f_flag & FREAD)) {
< fdrop(fp, td);
< return (EACCES);
< }
<
< bsd_args.fd = linux_args->fd;
< fdrop(fp, td);
< }
< bsd_args.pos = linux_args->pos;
---
> bsd_args.pos = linux_args->pgoff;
803a795,807
> linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
> {
> struct mprotect_args bsd_args;
>
> bsd_args.addr = uap->addr;
> bsd_args.len = uap->len;
> bsd_args.prot = uap->prot;
> if (bsd_args.prot & (PROT_READ | PROT_WRITE | PROT_EXEC))
> bsd_args.prot |= PROT_READ | PROT_EXEC;
> return (mprotect(td, &bsd_args));
> }
>
> int