guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mkostemp portability issues


From: Greg Troxel
Subject: mkostemp portability issues
Date: Mon, 20 Feb 2017 21:39:30 -0500
User-agent: Gnus/5.130016 (Ma Gnus v0.16) Emacs/24.5 (berkeley-unix)

Earlier I reported that 2.0.13 did not build on NetBSD.  Matt Wette
pointed me to a debbugs entry.  The issue seems to be that mkostemp is
not a POSIX-specified interface and the list of acceptable flags differs
on different platforms.

I have included the patch I just added to pkgsrc, which steals the patch
from the debbugs entry for Mac and adds a similar line for NetBSD.

Overall, I am unclear on the portability status of mkostemp.  I think
it's not specified by POSIX, and thus I wonder if guile is checking for
it before  using it, and what happens to scheme code if it isn't there.

And then there's the issue of differing flags.  I wonder what flags are
acually useful and if there is a core set that is supported more or less
everywhere.  Perhaps the Mac set is that set.  Generally guile tries to
avoid the OS details creeping into scheme code, and silently dropping
flags rather than erroring seems troublesome.  But I don't really
understand this issue well enough to have a firm opinion yet.



$NetBSD: patch-libguile_filesys.c,v 1.2 2017/02/21 02:32:00 gdt Exp $

When using mkostemp (an interface not defined by POSIX), restrict
flags to the set defined by the documentation of particular operating
systems.

See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24862#23 for discussion.

This patch has not yet been sent upstream.

--- libguile/filesys.c.orig     2016-12-15 00:03:33.000000000 +0000
+++ libguile/filesys.c
@@ -1486,6 +1486,15 @@ SCM_DEFINE (scm_i_mkstemp, "mkstemp!", 1
       mode_bits = scm_i_mode_bits (mode);
     }
 
+#ifdef __APPLE__
+  /* https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24862#23 */
+  open_flags &= O_APPEND|O_SHLOCK|O_EXLOCK|O_CLOEXEC;
+#endif
+#ifdef __NetBSD__
+  /* Restrict to list of flags documented in man page. */
+  open_flags = O_APPEND|O_DIRECT|O_SHLOCK|O_EXLOCK|O_SYNC|O_CLOEXEC;
+#endif
+
   SCM_SYSCALL (rv = mkostemp (c_tmpl, open_flags));
   if (rv == -1)
     SCM_SYSERROR;

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]