summaryrefslogtreecommitdiff
path: root/src/common_device_name.c
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2012-02-27 11:19:50 -0500
committerAdam Jackson <ajax@redhat.com>2012-02-27 17:09:01 -0500
commitd2dc9f9daa45504f035b169aba94d0b154fd29f0 (patch)
tree28ccca7fd1ab27a208a9fbd73306c922d19dac86 /src/common_device_name.c
parentf550c1347d3518874fe1c1d417a57322ee6b52db (diff)
Use O_CLOEXEC for internal file descriptors
Well, almost all of them. zlib doesn't support "e" in the mode string in gzopen() though it will silently accept and ignore it, and Solaris appears not to support "e" in the mode string at all. Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src/common_device_name.c')
-rw-r--r--src/common_device_name.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/common_device_name.c b/src/common_device_name.c
index b2765dd..ad9ed9d 100644
--- a/src/common_device_name.c
+++ b/src/common_device_name.c
@@ -51,6 +51,7 @@
#define DO_MATCH(a,b) (((a) == PCI_MATCH_ANY) || ((a) == (b)))
#ifdef HAVE_ZLIB
+
#include <zlib.h>
typedef gzFile pci_id_file;
@@ -68,11 +69,28 @@ pci_id_file_open(void)
#define pci_id_file_gets(l, s, f) gzgets(f, l, s)
#define pci_id_file_close(f) gzclose(f)
-#else
+
+#else /* not zlib */
+
typedef FILE * pci_id_file;
-#define pci_id_file_open() fopen(PCIIDS_PATH "/pci.ids", "r")
+
+static pci_id_file
+pci_id_file_open(void)
+{
+ pci_id_file result;
+
+#ifndef __sun
+ result = fopen(PCIIDS_PATH "/pci.ids", "re");
+ if (result)
+ return result;
+#endif
+
+ return fopen(PCIIDS_PATH "/pci.ids", "r");
+}
+
#define pci_id_file_gets(l, s, f) fgets(l, s, f)
#define pci_id_file_close(f) fclose(f)
+
#endif
/**