Module Name:    xsrc
Committed By:   maya
Date:           Fri Oct 26 11:17:33 UTC 2018

Modified Files:
        xsrc/external/mit/libpciaccess/dist/src: netbsd_pci.c

Log Message:
If O_RDWR fails, try O_RDONLY.

Lets me run unprivileged X.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 \
    xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c
diff -u xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.17 xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.18
--- xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.17	Sun Mar 11 10:37:32 2018
+++ xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c	Fri Oct 26 11:17:33 2018
@@ -924,6 +924,9 @@ pci_system_netbsd_create(void)
 	nbuses = 0;
 	snprintf(netbsd_devname, 32, "/dev/pci%d", nbuses);
 	pcifd = open(netbsd_devname, O_RDWR | O_CLOEXEC);
+	if (pcifd == -1)
+		pcifd = open(netbsd_devname, O_RDONLY | O_CLOEXEC);
+
 	while (pcifd > 0) {
 		ioctl(pcifd, PCI_IOC_BUSINFO, &businfo);
 		buses[nbuses].fd = pcifd;
@@ -946,6 +949,8 @@ pci_system_netbsd_create(void)
 		}
 		snprintf(netbsd_devname, 32, "/dev/pci%d", nbuses);
 		pcifd = open(netbsd_devname, O_RDWR);
+		if (pcifd == -1)
+			pcifd = open(netbsd_devname, O_RDONLY | O_CLOEXEC);
 	}
 
 	pci_sys->num_devices = ndevs;

Reply via email to