From e8cbcdb648340f55f03551110052d24c5d0bd9c6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 20 Nov 2013 08:30:44 -0800 Subject: Locate directory for shared memory files at configure time Signed-off-by: Keith Packard --- configure.ac | 43 +++++++++++++++++++++++++++++++++++++++++++ src/xshmfence.c | 6 +++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2780ac5..02359e1 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,49 @@ dnl Allow checking code with lint, sparse, etc. XORG_WITH_LINT LINT_FLAGS="${LINT_FLAGS} ${FONTENC_CFLAGS}" +dnl +dnl Locate a suitable tmp file system for creating shared memeory files +dnl + +AC_ARG_WITH(shared-memory-dir, AS_HELP_STRING([--with-shared-memory-dir=PATH], [Path to directory in a world-writable temporary directory for anonymous shared memory (default: auto)]), +[], +[with_shared_memory_dir=yes]) + +shmdirs="/run/shm /var/tmp /tmp" + +case x"$with_shared_memory_dir" in +xyes) + for dir in $shmdirs; do + case x"$with_shared_memory_dir" in + xyes) + echo Checking temp dir "$dir" + if test -d "$dir"; then + with_shared_memory_dir="$dir" + fi + ;; + esac + done + ;; +x/*) + ;; +xno) + ;; +*) + AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir]) + ;; +esac + +case x"$with_shared_memory_dir" in +xyes) + AC_MSG_ERROR([No directory found for shared memory temp files.]) + ;; +xno) + ;; +*) + AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files]) + ;; +esac + XORG_RELEASE_VERSION XORG_CHANGELOG diff --git a/src/xshmfence.c b/src/xshmfence.c index 83049de..ecf2f4a 100644 --- a/src/xshmfence.c +++ b/src/xshmfence.c @@ -20,6 +20,10 @@ * OF THIS SOFTWARE. */ +#if HAVE_CONFIG_H +#include "config.h" +#endif + #include "xshmfenceint.h" struct xshmfence { @@ -106,7 +110,7 @@ xshmfence_reset(struct xshmfence *f) int xshmfence_alloc_shm(void) { - char template[] = "/run/shm/shmfd-XXXXXX"; + char template[] = SHMDIR "/shmfd-XXXXXX"; int fd = mkstemp(template); if (fd < 0) -- cgit v1.2.3