1 dnl Copyright 2011 The Kyua Authors.
2 dnl All rights reserved.
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that the following conditions are
8 dnl * Redistributions of source code must retain the above copyright
9 dnl notice, this list of conditions and the following disclaimer.
10 dnl * Redistributions in binary form must reproduce the above copyright
11 dnl notice, this list of conditions and the following disclaimer in the
12 dnl documentation and/or other materials provided with the distribution.
13 dnl * Neither the name of Google Inc. nor the names of its contributors
14 dnl may be used to endorse or promote products derived from this software
15 dnl without specific prior written permission.
17 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 dnl File system related checks.
32 dnl The macros in this file check for features required in the utils/fs
33 dnl module. The global KYUA_FS_MODULE macro will call all checks required
37 dnl KYUA_FS_GETCWD_DYN
39 dnl Checks whether getcwd(NULL, 0) works; i.e. if getcwd(3) can dynamically
40 dnl allocate the output buffer to fit the whole current path.
41 AC_DEFUN([KYUA_FS_GETCWD_DYN], [
43 [whether getcwd(NULL, 0) works],
44 [kyua_cv_getcwd_dyn], [
45 AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>
48 char *cwd = getcwd(NULL, 0);
49 return (cwd != NULL) ? EXIT_SUCCESS : EXIT_FAILURE;
51 [kyua_cv_getcwd_dyn=yes],
52 [kyua_cv_getcwd_dyn=no])
54 if test "${kyua_cv_getcwd_dyn}" = yes; then
55 AC_DEFINE_UNQUOTED([HAVE_GETCWD_DYN], [1],
56 [Define to 1 if getcwd(NULL, 0) works])
63 dnl Checks whether lchmod(3) exists and if it works. Some systems, such as
64 dnl Ubuntu 10.04.1 LTS, provide a lchmod(3) stub that is not implemented yet
65 dnl allows programs to compile cleanly (albeit for a warning). It would be
66 dnl nice to detect if lchmod(3) works at run time to prevent side-effects of
67 dnl this test but doing so means we will keep receiving a noisy compiler
69 AC_DEFUN([KYUA_FS_LCHMOD], [
71 [for a working lchmod],
72 [kyua_cv_lchmod_works], [
73 AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <sys/stat.h>
79 int fd = open("conftest.txt", O_WRONLY | O_CREAT | O_TRUNC, 0644);
81 perror("creation of conftest.txt failed");
85 return lchmod("conftest.txt", 0640) != -1 ? EXIT_SUCCESS : EXIT_FAILURE;
87 [kyua_cv_lchmod_works=yes],
88 [kyua_cv_lchmod_works=no])
91 if test "${kyua_cv_lchmod_works}" = yes; then
92 AC_DEFINE_UNQUOTED([HAVE_WORKING_LCHMOD], [1],
93 [Define to 1 if your lchmod works])
100 dnl Detect the correct method to unmount a file system.
101 AC_DEFUN([KYUA_FS_UNMOUNT], [
102 AC_CHECK_FUNCS([unmount], [have_unmount2=yes], [have_unmount2=no])
103 if test "${have_unmount2}" = no; then
105 AC_PATH_PROG([UMOUNT], [umount], [have_umount8=no])
106 if test "${have_umount8}" = yes; then
107 AC_DEFINE_UNQUOTED([UMOUNT], ["${UMOUNT}"],
108 [Set to the path of umount(8)])
110 AC_MSG_ERROR([Don't know how to unmount a file system])
118 dnl Performs all checks needed by the utils/fs library.
119 AC_DEFUN([KYUA_FS_MODULE], [
120 AC_CHECK_HEADERS([sys/mount.h sys/statvfs.h sys/vfs.h])
121 AC_CHECK_FUNCS([statfs statvfs])