shm: Pick the shm dir at run time, not build time.
Prodding the builder's filesystem for tmp dirs doesn't necessarily
tell you anything about what the actual host's filesystem is going to
look like, so we should just try the dirs at runtime.
Signed-off-by: Eric Anholt <eric@anholt.net>
(cherry picked from commit 19f6cb570b
)
This commit is contained in:
parent
9ee4e35bfe
commit
05c5b97013
48
Xext/shm.c
48
Xext/shm.c
@ -1194,36 +1194,46 @@ ProcShmAttachFd(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
shm_tmpfile(void)
|
shm_tmpfile(void)
|
||||||
{
|
{
|
||||||
#ifdef SHMDIR
|
const char *shmdirs[] = {
|
||||||
|
"/run/shm",
|
||||||
|
"/var/tmp",
|
||||||
|
"/tmp",
|
||||||
|
};
|
||||||
int fd;
|
int fd;
|
||||||
char template[] = SHMDIR "/shmfd-XXXXXX";
|
|
||||||
#ifdef O_TMPFILE
|
#ifdef O_TMPFILE
|
||||||
fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
|
for (int i = 0; i < ARRAY_SIZE(shmdirs); i++) {
|
||||||
if (fd >= 0) {
|
fd = open(shmdirs[i], O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
|
||||||
DebugF ("Using O_TMPFILE\n");
|
if (fd >= 0) {
|
||||||
return fd;
|
DebugF ("Using O_TMPFILE\n");
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ErrorF ("Not using O_TMPFILE\n");
|
ErrorF ("Not using O_TMPFILE\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < ARRAY_SIZE(shmdirs); i++) {
|
||||||
|
char template[PATH_MAX];
|
||||||
|
snprintf(template, ARRAY_SIZE(template), "%s/shmfd-XXXXXX", shmdirs[i]);
|
||||||
#ifdef HAVE_MKOSTEMP
|
#ifdef HAVE_MKOSTEMP
|
||||||
fd = mkostemp(template, O_CLOEXEC);
|
fd = mkostemp(template, O_CLOEXEC);
|
||||||
#else
|
#else
|
||||||
fd = mkstemp(template);
|
fd = mkstemp(template);
|
||||||
#endif
|
#endif
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
continue;
|
||||||
unlink(template);
|
unlink(template);
|
||||||
#ifndef HAVE_MKOSTEMP
|
#ifndef HAVE_MKOSTEMP
|
||||||
int flags = fcntl(fd, F_GETFD);
|
int flags = fcntl(fd, F_GETFD);
|
||||||
if (flags != -1) {
|
if (flags != -1) {
|
||||||
flags |= FD_CLOEXEC;
|
flags |= FD_CLOEXEC;
|
||||||
(void) fcntl(fd, F_SETFD, &flags);
|
(void) fcntl(fd, F_SETFD, &flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return fd;
|
|
||||||
#else
|
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
43
configure.ac
43
configure.ac
@ -1122,49 +1122,6 @@ case "$DRI2,$HAVE_DRI2PROTO" in
|
|||||||
esac
|
esac
|
||||||
AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
|
AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(xtrans-send-fds, AS_HELP_STRING([--disable-xtrans-send-fds], [Use Xtrans support for fd passing (default: auto)]), [XTRANS_SEND_FDS=$enableval], [XTRANS_SEND_FDS=auto])
|
AC_ARG_ENABLE(xtrans-send-fds, AS_HELP_STRING([--disable-xtrans-send-fds], [Use Xtrans support for fd passing (default: auto)]), [XTRANS_SEND_FDS=$enableval], [XTRANS_SEND_FDS=auto])
|
||||||
|
|
||||||
case "x$XTRANS_SEND_FDS" in
|
case "x$XTRANS_SEND_FDS" in
|
||||||
|
@ -458,9 +458,6 @@
|
|||||||
/* Wrap SIGBUS to catch MIT-SHM faults */
|
/* Wrap SIGBUS to catch MIT-SHM faults */
|
||||||
#undef BUSFAULT
|
#undef BUSFAULT
|
||||||
|
|
||||||
/* Directory for shared memory temp files */
|
|
||||||
#undef SHMDIR
|
|
||||||
|
|
||||||
/* Don't let Xdefs.h define 'pointer' */
|
/* Don't let Xdefs.h define 'pointer' */
|
||||||
#define _XTYPEDEF_POINTER 1
|
#define _XTYPEDEF_POINTER 1
|
||||||
|
|
||||||
|
@ -70,11 +70,6 @@ conf_data.set('SYSTEMD_LOGIND', build_systemd_logind)
|
|||||||
conf_data.set('NEED_DBUS', build_systemd_logind or build_hal)
|
conf_data.set('NEED_DBUS', build_systemd_logind or build_hal)
|
||||||
conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd')
|
conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd')
|
||||||
|
|
||||||
# XXX: SHMDIR is weird in autoconf, probing the build system for
|
|
||||||
# various tmp directories. Could we replace it with C code at runtime
|
|
||||||
# that just uses whatever directory works?
|
|
||||||
conf_data.set_quoted('SHMDIR', '/tmp')
|
|
||||||
|
|
||||||
conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found())
|
conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found())
|
||||||
conf_data.set('WITH_LIBDRM', libdrm_dep.found())
|
conf_data.set('WITH_LIBDRM', libdrm_dep.found())
|
||||||
conf_data.set('GLAMOR_HAS_EGL_QUERY_DMABUF',
|
conf_data.set('GLAMOR_HAS_EGL_QUERY_DMABUF',
|
||||||
|
Loading…
Reference in New Issue
Block a user