summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHilko Bengen <bengen@hilluzination.de>2011-08-22 19:52:02 +0200
committerRichard W.M. Jones <rjones@redhat.com>2011-08-24 12:56:51 +0100
commit24e778286a2d684cb08afb29f5c0e48b2b312e7e (patch)
tree4be7fbba5ffca3eb934db7a90319ad619d9d4876
parenteef5ef620496d0a77aba0b6cdd90926f2e66eba2 (diff)
downloadhivex-24e778286a2d684cb08afb29f5c0e48b2b312e7e.tar.gz
hivex-24e778286a2d684cb08afb29f5c0e48b2b312e7e.tar.xz
hivex-24e778286a2d684cb08afb29f5c0e48b2b312e7e.zip
hivex: Fix building on platforms without O_CLOEXEC such as FreeBSD
-rw-r--r--lib/hivex.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/hivex.c b/lib/hivex.c
index a3f5171..4b9fcf0 100644
--- a/lib/hivex.c
+++ b/lib/hivex.c
@@ -294,9 +294,16 @@ hivex_open (const char *filename, int flags)
if (h->filename == NULL)
goto error;
+#ifdef O_CLOEXEC
h->fd = open (filename, O_RDONLY | O_CLOEXEC);
+#else
+ h->fd = open (filename, O_RDONLY);
+#endif
if (h->fd == -1)
goto error;
+#ifndef O_CLOEXEC
+ fcntl (h->fd, F_SETFD, FD_CLOEXEC);
+#endif
struct stat statbuf;
if (fstat (h->fd, &statbuf) == -1)