]
)
+# Check for faccessat
+AC_CHECK_LIB([c], [faccessat],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FACCESSAT], 1, [Has faccessat support.])
+]
+)
+
AC_CHECK_LIB([popt], [poptGetContext], [],
[AC_MSG_ERROR([Cannot find popt.])]
)
-
# For Python
# SWIG version needed or newer:
swig_version=2.0.0
snprintf(index_name, strlen(path) + sizeof(INDEX_PATH),
INDEX_PATH, path);
- if (faccessat(td->dirfd, index_name, O_RDONLY, flags) < 0) {
+ if (bt_faccessat(td->dirfd, td->parent.path, index_name, O_RDONLY, 0) < 0) {
ret = create_stream_packet_index(td, file_stream);
if (ret) {
fprintf(stderr, "[error] Stream index creation error.\n");
}
#endif /* #else #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
+
+#ifdef BABELTRACE_HAVE_FACCESSAT
+
+#include <fcntl.h>
+#include <unistd.h>
+
+static inline
+int bt_faccessat(int dirfd, const char *dirname,
+ const char *pathname, int mode, int flags)
+{
+ return faccessat(dirfd, pathname, mode, flags);
+}
+
+#else /* #ifdef BABELTRACE_HAVE_FACCESSAT */
+
+#include <string.h>
+#include <unistd.h>
+
+static inline
+int bt_faccessat(int dirfd, const char *dirname,
+ const char *pathname, int mode, int flags)
+{
+ char cpath[PATH_MAX];
+
+ if (flags != 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ /* Includes middle / and final \0. */
+ if (strlen(dirname) + strlen(pathname) + 2 > PATH_MAX) {
+ return -1;
+ }
+ strcpy(cpath, dirname);
+ strcat(cpath, "/");
+ strcat(cpath, pathname);
+ return access(cpath, mode);
+}
+
+#endif /* #else #ifdef BABELTRACE_HAVE_FACCESSAT */
+
#endif /* _BABELTRACE_COMPAT_FCNTL_H */