OSDN Git Service

linux_sysfs.c: Include <limits.h> for PATH_MAX
[android-x86/external-libpciaccess.git] / src / common_vgaarb.c
index f09d513..7a7d204 100644 (file)
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -128,7 +132,7 @@ pci_device_vgaarb_init(void)
     if (!pci_sys)
         return -1;
 
-    if ((pci_sys->vgaarb_fd = open ("/dev/vga_arbiter", O_RDWR)) < 0) {
+    if ((pci_sys->vgaarb_fd = open ("/dev/vga_arbiter", O_RDWR | O_CLOEXEC)) < 0) {
         return errno;
     }
 
@@ -263,6 +267,13 @@ pci_device_vgaarb_decodes(int new_vgaarb_rsrc)
     ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);
     if (ret == 0)
         dev->vgaarb_rsrc = new_vgaarb_rsrc;
+
+    ret = read(pci_sys->vgaarb_fd, buf, BUFSIZE);
+    if (ret <= 0)
+        return -1;
+
+    parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, NULL);
+
     return ret;
 }