[PATCH libpciaccess 2/2 v3] linux: Implement map_legacy

Javier Pello javier.pello at urjc.es
Tue Oct 11 00:46:06 PDT 2011


On Fri, 2011-10-07 at 10:18:20 -0700, Jeremy Huddleston wrote:
> +    char name[PATH_MAX];
> +    int flags = O_RDONLY;
> +    int prot = PROT_READ;
> +    int fd;
> +    int ret=0;
> +
> +    if (map_flags & PCI_DEV_MAP_FLAG_WRITABLE) {
> +	flags |= O_WRONLY;
> +	prot |= PROT_WRITE;
> +    }

This won't do what you want. Linux has

#define O_ACCMODE       00000003
#define O_RDONLY        00000000
#define O_WRONLY        00000001
#define O_RDWR          00000002

in asm-generic/fcntl.h, so O_RDONLY | O_WRONLY != O_RDWR.
I think you should just say flags = O_RDWR in the conditional.

Javier


More information about the xorg-devel mailing list