configure: Add mkdirat() detection, fix build

Build failure is caused by adding the ex4 features tests into the
default build which exposes code which uses mkdirat().

This patch adds configure check for mkdirat() and ifdefs around the
code in create_long_dirs.c and create_short_dirs.c.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/configure.ac b/configure.ac
index 9e3df00..8a2a96a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,5 +172,6 @@
 LTP_CHECK_KERNEL_DEVEL
 LTP_CHECK_XFS_QUOTACTL
 LTP_CHECK_CLONE_SUPPORTS_7_ARGS
+LTP_CHECK_MKDIRAT
 
 AC_OUTPUT
diff --git a/m4/ltp-mkdirat.m4 b/m4/ltp-mkdirat.m4
new file mode 100644
index 0000000..40786c3
--- /dev/null
+++ b/m4/ltp-mkdirat.m4
@@ -0,0 +1,25 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2014
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+dnl
+
+dnl
+dnl LTP_CHECK_MKDIRAT
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_MKDIRAT],[
+AC_CHECK_FUNCS(mkdirat,,)
+])
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_long_dirs.c b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_long_dirs.c
index e709ae9..fc9221a 100644
--- a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_long_dirs.c
+++ b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_long_dirs.c
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 //#define __USE_ATFILE
 #include <sys/stat.h>
+#include "config.h"
 
 #define NAME_LEN	255
 #define NCHARS		62
@@ -64,10 +65,15 @@
 
 void create_dir(void)
 {
+#ifdef HAVE_MKDIRAT
 	if (mkdirat(parent_fd, name, S_IRWXU)) {
 		perror("mkdir");
 		exit(1);
 	}
+#else
+	fprintf(stderr, "System lacks mkdirat() call.\n");
+	exit(1);
+#endif
 }
 
 /*
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_short_dirs.c b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_short_dirs.c
index fd8d819..cb67dbd 100644
--- a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_short_dirs.c
+++ b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/create_short_dirs.c
@@ -28,6 +28,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include "config.h"
 
 /* valid characters for a directory name */
 char chars[] = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
@@ -46,10 +47,15 @@
 
 void create_dir(void)
 {
+#ifdef HAVE_MKDIRAT
 	if (mkdirat(parent_fd, name, S_IRWXU)) {
 		perror("mkdir");
 		exit(1);
 	}
+#else
+	fprintf(stderr, "System lacks mkdirat() call.\n");
+	exit(1);
+#endif
 }
 
 /*