From 82d1989d3245791c9fac22ca848f5497f261c10b Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Wed, 15 Dec 2004 20:47:26 +0000 Subject: Moving m4 files into m4/. Added extra coreutils files required from autoconf tests. Updated Makefile.am to have nagiosplug lib and a separate coreutils lib git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1027 f882894a-f735-0410-b71e-b25c423dba1c --- lib/Makefile.am | 44 ++++++--- lib/afs.m4 | 13 --- lib/error.m4 | 15 --- lib/exitfail.m4 | 13 --- lib/fstypename.m4 | 32 ------ lib/fsusage.m4 | 246 ---------------------------------------------- lib/full-read.c | 19 ++++ lib/full-write.c | 85 ++++++++++++++++ lib/full-write.h | 24 +++++ lib/getopt.m4 | 13 --- lib/ls-mntd-fs.m4 | 282 ----------------------------------------------------- lib/onceonly.m4 | 63 ------------ lib/safe-read.c | 82 ++++++++++++++++ lib/safe-read.h | 25 +++++ lib/safe-write.c | 19 ++++ lib/safe-write.h | 25 +++++ lib/unlocked-io.m4 | 22 ----- lib/xalloc.m4 | 32 ------ 18 files changed, 310 insertions(+), 744 deletions(-) delete mode 100644 lib/afs.m4 delete mode 100644 lib/error.m4 delete mode 100644 lib/exitfail.m4 delete mode 100644 lib/fstypename.m4 delete mode 100644 lib/fsusage.m4 create mode 100644 lib/full-read.c create mode 100644 lib/full-write.c create mode 100644 lib/full-write.h delete mode 100644 lib/getopt.m4 delete mode 100644 lib/ls-mntd-fs.m4 delete mode 100644 lib/onceonly.m4 create mode 100644 lib/safe-read.c create mode 100644 lib/safe-read.h create mode 100644 lib/safe-write.c create mode 100644 lib/safe-write.h delete mode 100644 lib/unlocked-io.m4 delete mode 100644 lib/xalloc.m4 diff --git a/lib/Makefile.am b/lib/Makefile.am index 3250cdb3..80f3e62e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,20 +1,38 @@ ## Process this file with automake to produce Makefile.in -noinst_LIBRARIES = libnagiosplug.a +noinst_LIBRARIES = libcoreutils.a libnagiosplug.a -libnagiosplug_a_SOURCES = getopt.c getopt1.c fsusage.c snprintf.c mountlist.c \ - xmalloc.c xstrdup.c exitfail.c +# Will auto pick up fsusage.c mountlist.c +libcoreutils_a_SOURCES = \ + cloexec.c cloexec.h \ + exit.h \ + exitfail.c exitfail.h \ + fsusage.h \ + full-read.c full-read.h \ + full-write.c full-write.h \ + getopt.c getopt.h getopt1.c \ + gettext.h \ + mountlist.h \ + safe-read.c safe-read.h \ + safe-write.c safe-write.h \ + unlocked-io.h \ + xalloc.h \ + xmalloc.c \ + xstrdup.c -libnagiosplug_a_LIBADD = @LIBOBJS@ -libnagiosplug_a_DEPENDENCIES = $(libnagiosplug_a_LIBADD) +other_coreutils_files = \ + error.c error.h \ + fsusage.c \ + getloadaavg.c \ + malloc.c \ + mountlist.c \ + realloc.c \ + strtod.c -# Extra GNU libraries required if target is missing these functions -EXTRA_DIST = ulonglong.m4 codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 \ - inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 \ - lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 afs.m4 \ - fstypename.m4 fsusage.m4 ls-mntd-fs.m4 getopt.h gettext.h fsusage.h mountlist.h\ - error.m4 error.h error.c getloadavg.c xalloc.h unlocked-io.h unlocked-io.m4 malloc.c \ - onceonly.m4 realloc.c strtod.c exitfail.h full-read.h xstrdup.c xalloc.m4 exit.h \ - cloexec.c cloexec.h getopt.m4 exitfail.m4 +libcoreutils_a_LIBADD = $(LIBOBJS) +libcoreutils_a_DEPENDENCIES = $(libcoreutils_a_LIBADD) + +libnagiosplug_a_SOURCES = snprintf.c INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl + diff --git a/lib/afs.m4 b/lib/afs.m4 deleted file mode 100644 index 9e7d7731..00000000 --- a/lib/afs.m4 +++ /dev/null @@ -1,13 +0,0 @@ -#serial 5 - -AC_DEFUN([jm_AFS], - [ - AC_MSG_CHECKING(for AFS) - if test -d /afs; then - AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.]) - ac_result=yes - else - ac_result=no - fi - AC_MSG_RESULT($ac_result) - ]) diff --git a/lib/error.m4 b/lib/error.m4 deleted file mode 100644 index 0bc2e689..00000000 --- a/lib/error.m4 +++ /dev/null @@ -1,15 +0,0 @@ -#serial 9 - -AC_DEFUN([gl_ERROR], -[ - AC_FUNC_ERROR_AT_LINE - dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]). - jm_PREREQ_ERROR -]) - -# Prerequisites of lib/error.c. -AC_DEFUN([jm_PREREQ_ERROR], -[ - AC_REQUIRE([AC_FUNC_STRERROR_R]) - : -]) diff --git a/lib/exitfail.m4 b/lib/exitfail.m4 deleted file mode 100644 index fa5b1493..00000000 --- a/lib/exitfail.m4 +++ /dev/null @@ -1,13 +0,0 @@ -# exitfail.m4 serial 3 -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -AC_DEFUN([gl_EXITFAIL], -[ - dnl No prerequisites of lib/exitfail.c. - : -]) diff --git a/lib/fstypename.m4 b/lib/fstypename.m4 deleted file mode 100644 index 75723a14..00000000 --- a/lib/fstypename.m4 +++ /dev/null @@ -1,32 +0,0 @@ -#serial 3 - -dnl From Jim Meyering. -dnl -dnl See if struct statfs has the f_fstypename member. -dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS. -dnl - -AC_DEFUN([jm_FSTYPENAME], - [ - AC_CACHE_CHECK([for f_fstypename in struct statfs], - fu_cv_sys_f_fstypename_in_statfs, - [ - AC_TRY_COMPILE( - [ -#include -#include -#include - ], - [struct statfs s; int i = sizeof s.f_fstypename;], - fu_cv_sys_f_fstypename_in_statfs=yes, - fu_cv_sys_f_fstypename_in_statfs=no - ) - ] - ) - - if test $fu_cv_sys_f_fstypename_in_statfs = yes; then - AC_DEFINE(HAVE_F_FSTYPENAME_IN_STATFS, 1, - [Define if struct statfs has the f_fstypename member.]) - fi - ] -) diff --git a/lib/fsusage.m4 b/lib/fsusage.m4 deleted file mode 100644 index a0ab1e15..00000000 --- a/lib/fsusage.m4 +++ /dev/null @@ -1,246 +0,0 @@ -#serial 11 - -# From fileutils/configure.in - -AC_DEFUN([gl_FSUSAGE], -[ - AC_CHECK_HEADERS_ONCE(sys/param.h) - AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs_types.h) - jm_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) - if test $gl_cv_fs_space = yes; then - AC_LIBOBJ(fsusage) - gl_PREREQ_FSUSAGE_EXTRA - fi -]) - -# Try to determine how a program can obtain filesystem usage information. -# If successful, define the appropriate symbol (see fsusage.c) and -# execute ACTION-IF-FOUND. Otherwise, execute ACTION-IF-NOT-FOUND. -# -# jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) - -AC_DEFUN([jm_FILE_SYSTEM_USAGE], -[ - -echo "checking how to get filesystem space usage..." -ac_fsusage_space=no - -# Perform only the link test since it seems there are no variants of the -# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs) -# because that got a false positive on SCO OSR5. Adding the declaration -# of a `struct statvfs' causes this test to fail (as it should) on such -# systems. That system is reported to work fine with STAT_STATFS4 which -# is what it gets when this test fails. -if test $ac_fsusage_space = no; then - # SVR4 - AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs, - [AC_TRY_LINK([#include -#ifdef __GLIBC__ -Do not use statvfs on systems with GNU libc, because that function stats -all preceding entries in /proc/mounts, and that makes df hang if even -one of the corresponding file systems is hard-mounted, but not available. -#endif -#include ], - [struct statvfs fsd; statvfs (0, &fsd);], - fu_cv_sys_stat_statvfs=yes, - fu_cv_sys_stat_statvfs=no)]) - if test $fu_cv_sys_stat_statvfs = yes; then - ac_fsusage_space=yes - AC_DEFINE(STAT_STATVFS, 1, - [ Define if there is a function named statvfs. (SVR4)]) - fi -fi - -if test $ac_fsusage_space = no; then - # DEC Alpha running OSF/1 - AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) - AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1, - [AC_TRY_RUN([ -#include -#include -#include - main () - { - struct statfs fsd; - fsd.f_fsize = 0; - exit (statfs (".", &fsd, sizeof (struct statfs))); - }], - fu_cv_sys_stat_statfs3_osf1=yes, - fu_cv_sys_stat_statfs3_osf1=no, - fu_cv_sys_stat_statfs3_osf1=no)]) - AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) - if test $fu_cv_sys_stat_statfs3_osf1 = yes; then - ac_fsusage_space=yes - AC_DEFINE(STAT_STATFS3_OSF1, 1, - [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) - fi -fi - -if test $ac_fsusage_space = no; then -# AIX - AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl -member (AIX, 4.3BSD)]) - AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize, - [AC_TRY_RUN([ -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#ifdef HAVE_SYS_MOUNT_H -#include -#endif -#ifdef HAVE_SYS_VFS_H -#include -#endif - main () - { - struct statfs fsd; - fsd.f_bsize = 0; - exit (statfs (".", &fsd)); - }], - fu_cv_sys_stat_statfs2_bsize=yes, - fu_cv_sys_stat_statfs2_bsize=no, - fu_cv_sys_stat_statfs2_bsize=no)]) - AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) - if test $fu_cv_sys_stat_statfs2_bsize = yes; then - ac_fsusage_space=yes - AC_DEFINE(STAT_STATFS2_BSIZE, 1, -[ Define if statfs takes 2 args and struct statfs has a field named f_bsize. - (4.3BSD, SunOS 4, HP-UX, AIX PS/2)]) - fi -fi - -if test $ac_fsusage_space = no; then -# SVR3 - AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) - AC_CACHE_VAL(fu_cv_sys_stat_statfs4, - [AC_TRY_RUN([#include -#include - main () - { - struct statfs fsd; - exit (statfs (".", &fsd, sizeof fsd, 0)); - }], - fu_cv_sys_stat_statfs4=yes, - fu_cv_sys_stat_statfs4=no, - fu_cv_sys_stat_statfs4=no)]) - AC_MSG_RESULT($fu_cv_sys_stat_statfs4) - if test $fu_cv_sys_stat_statfs4 = yes; then - ac_fsusage_space=yes - AC_DEFINE(STAT_STATFS4, 1, - [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)]) - fi -fi - -if test $ac_fsusage_space = no; then -# 4.4BSD and NetBSD - AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl -member (4.4BSD and NetBSD)]) - AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize, - [AC_TRY_RUN([#include -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#ifdef HAVE_SYS_MOUNT_H -#include -#endif - main () - { - struct statfs fsd; - fsd.f_fsize = 0; - exit (statfs (".", &fsd)); - }], - fu_cv_sys_stat_statfs2_fsize=yes, - fu_cv_sys_stat_statfs2_fsize=no, - fu_cv_sys_stat_statfs2_fsize=no)]) - AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) - if test $fu_cv_sys_stat_statfs2_fsize = yes; then - ac_fsusage_space=yes - AC_DEFINE(STAT_STATFS2_FSIZE, 1, -[ Define if statfs takes 2 args and struct statfs has a field named f_fsize. - (4.4BSD, NetBSD)]) - fi -fi - -if test $ac_fsusage_space = no; then - # Ultrix - AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) - AC_CACHE_VAL(fu_cv_sys_stat_fs_data, - [AC_TRY_RUN([#include -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#ifdef HAVE_SYS_MOUNT_H -#include -#endif -#ifdef HAVE_SYS_FS_TYPES_H -#include -#endif - main () - { - struct fs_data fsd; - /* Ultrix's statfs returns 1 for success, - 0 for not mounted, -1 for failure. */ - exit (statfs (".", &fsd) != 1); - }], - fu_cv_sys_stat_fs_data=yes, - fu_cv_sys_stat_fs_data=no, - fu_cv_sys_stat_fs_data=no)]) - AC_MSG_RESULT($fu_cv_sys_stat_fs_data) - if test $fu_cv_sys_stat_fs_data = yes; then - ac_fsusage_space=yes - AC_DEFINE(STAT_STATFS2_FS_DATA, 1, -[ Define if statfs takes 2 args and the second argument has - type struct fs_data. (Ultrix)]) - fi -fi - -if test $ac_fsusage_space = no; then - # SVR2 - AC_TRY_CPP([#include - ], - AC_DEFINE(STAT_READ_FILSYS, 1, - [Define if there is no specific function for reading filesystems usage - information and you have the header file. (SVR2)]) - ac_fsusage_space=yes) -fi - -AS_IF([test $ac_fsusage_space = yes], [$1], [$2]) - -]) - - -# Check for SunOS statfs brokenness wrt partitions 2GB and larger. -# If exists and struct statfs has a member named f_spare, -# enable the work-around code in fsusage.c. -AC_DEFUN([jm_STATFS_TRUNCATES], -[ - AC_MSG_CHECKING([for statfs that truncates block counts]) - AC_CACHE_VAL(fu_cv_sys_truncating_statfs, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#if !defined(sun) && !defined(__sun) -choke -- this is a workaround for a Sun-specific problem -#endif -#include -#include ]], - [[struct statfs t; long c = *(t.f_spare);]])], - [fu_cv_sys_truncating_statfs=yes], - [fu_cv_sys_truncating_statfs=no])]) - if test $fu_cv_sys_truncating_statfs = yes; then - AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1, - [Define if the block counts reported by statfs may be truncated to 2GB - and the correct values may be stored in the f_spare array. - (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. - SunOS 4.1.1 seems not to be affected.)]) - fi - AC_MSG_RESULT($fu_cv_sys_truncating_statfs) -]) - - -# Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE. -AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], -[ - AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) - AC_CHECK_HEADERS_ONCE(fcntl.h) - AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h sys/statvfs.h) - jm_STATFS_TRUNCATES -]) diff --git a/lib/full-read.c b/lib/full-read.c new file mode 100644 index 00000000..1dc3e377 --- /dev/null +++ b/lib/full-read.c @@ -0,0 +1,19 @@ +/* An interface to read that retries after partial reads and interrupts. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define FULL_READ +#include "full-write.c" diff --git a/lib/full-write.c b/lib/full-write.c new file mode 100644 index 00000000..15137056 --- /dev/null +++ b/lib/full-write.c @@ -0,0 +1,85 @@ +/* An interface to read and write that retries (if necessary) until complete. + + Copyright (C) 1993, 1994, 1997-2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#ifdef FULL_READ +# include "full-read.h" +#else +# include "full-write.h" +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#ifdef FULL_READ +# include "safe-read.h" +# define safe_rw safe_read +# define full_rw full_read +# undef const +# define const /* empty */ +#else +# include "safe-write.h" +# define safe_rw safe_write +# define full_rw full_write +#endif + +#ifdef FULL_READ +/* Set errno to zero upon EOF. */ +# define ZERO_BYTE_TRANSFER_ERRNO 0 +#else +/* Some buggy drivers return 0 when one tries to write beyond + a device's end. (Example: Linux 1.2.13 on /dev/fd0.) + Set errno to ENOSPC so they get a sensible diagnostic. */ +# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC +#endif + +/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if + interrupted or if a partial write(read) occurs. Return the number + of bytes transferred. + When writing, set errno if fewer than COUNT bytes are written. + When reading, if fewer than COUNT bytes are read, you must examine + errno to distinguish failure from EOF (errno == 0). */ +size_t +full_rw (int fd, const void *buf, size_t count) +{ + size_t total = 0; + const char *ptr = buf; + + while (count > 0) + { + size_t n_rw = safe_rw (fd, ptr, count); + if (n_rw == (size_t) -1) + break; + if (n_rw == 0) + { + errno = ZERO_BYTE_TRANSFER_ERRNO; + break; + } + total += n_rw; + ptr += n_rw; + count -= n_rw; + } + + return total; +} diff --git a/lib/full-write.h b/lib/full-write.h new file mode 100644 index 00000000..8cd2e815 --- /dev/null +++ b/lib/full-write.h @@ -0,0 +1,24 @@ +/* An interface to write() that writes all it is asked to write. + + Copyright (C) 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include + +/* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted + or if partial writes occur. Return the number of bytes successfully + written, setting errno if that is less than COUNT. */ +extern size_t full_write (int fd, const void *buf, size_t count); diff --git a/lib/getopt.m4 b/lib/getopt.m4 deleted file mode 100644 index df602b98..00000000 --- a/lib/getopt.m4 +++ /dev/null @@ -1,13 +0,0 @@ -# getopt.m4 serial 2 -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -AC_DEFUN([gl_GETOPT], -[ - dnl Prerequisites of lib/getopt.c. - : -]) diff --git a/lib/ls-mntd-fs.m4 b/lib/ls-mntd-fs.m4 deleted file mode 100644 index c28466bb..00000000 --- a/lib/ls-mntd-fs.m4 +++ /dev/null @@ -1,282 +0,0 @@ -#serial 14 - -dnl From Jim Meyering. -dnl -dnl This is not pretty. I've just taken the autoconf code and wrapped -dnl it in an AC_DEFUN. -dnl - -# jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -AC_DEFUN([jm_LIST_MOUNTED_FILESYSTEMS], - [ -AC_CHECK_FUNCS(listmntent getmntinfo) -AC_CHECK_HEADERS_ONCE(sys/param.h) - -# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses -# NGROUPS (as the array dimension for a struct member) without a definition. -AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include ]) - -AC_CHECK_HEADERS(mntent.h sys/mount.h sys/fs_types.h) - getfsstat_includes="\ -$ac_includes_default -#if HAVE_SYS_PARAM_H -# include /* needed by powerpc-apple-darwin1.3.7 */ -#endif -#if HAVE_SYS_UCRED_H -# include /* needed for definition of NGROUPS */ -# include /* needed by powerpc-apple-darwin1.3.7 */ -#endif -#if HAVE_SYS_MOUNT_H -# include -#endif -#if HAVE_SYS_FS_TYPES_H -# include /* needed by powerpc-apple-darwin1.3.7 */ -#endif -" -AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes]) - -# Determine how to get the list of mounted filesystems. -ac_list_mounted_fs= - -# If the getmntent function is available but not in the standard library, -# make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX). -AC_FUNC_GETMNTENT - -# This test must precede the ones for getmntent because Unicos-9 is -# reported to have the getmntent function, but its support is incompatible -# with other getmntent implementations. - -# NOTE: Normally, I wouldn't use a check for system type as I've done for -# `CRAY' below since that goes against the whole autoconf philosophy. But -# I think there is too great a chance that some non-Cray system has a -# function named listmntent to risk the false positive. - -if test -z "$ac_list_mounted_fs"; then - # Cray UNICOS 9 - AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) - AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, - [fu_cv_sys_mounted_cray_listmntent=no - AC_EGREP_CPP(yes, - [#ifdef _CRAY -yes -#endif - ], [test $ac_cv_func_listmntent = yes \ - && fu_cv_sys_mounted_cray_listmntent=yes] - ) - ] - ) - AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) - if test $fu_cv_sys_mounted_cray_listmntent = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_LISTMNTENT, 1, - [Define if there is a function named listmntent that can be used to - list all mounted filesystems. (UNICOS)]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - # AIX. - AC_MSG_CHECKING([for mntctl function and struct vmount]) - AC_CACHE_VAL(fu_cv_sys_mounted_vmount, - [AC_TRY_CPP([#include ], - fu_cv_sys_mounted_vmount=yes, - fu_cv_sys_mounted_vmount=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_vmount) - if test $fu_cv_sys_mounted_vmount = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_VMOUNT, 1, - [Define if there is a function named mntctl that can be used to read - the list of mounted filesystems, and there is a system header file - that declares `struct vmount.' (AIX)]) - fi -fi - -if test $ac_cv_func_getmntent = yes; then - - # This system has the getmntent function. - # Determine whether it's the one-argument variant or the two-argument one. - - if test -z "$ac_list_mounted_fs"; then - # 4.3BSD, SunOS, HP-UX, Dynix, Irix - AC_MSG_CHECKING([for one-argument getmntent function]) - AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1, - [AC_TRY_COMPILE([ -/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */ -#include - -#include -#if !defined MOUNTED -# if defined _PATH_MOUNTED /* GNU libc */ -# define MOUNTED _PATH_MOUNTED -# endif -# if defined MNT_MNTTAB /* HP-UX. */ -# define MOUNTED MNT_MNTTAB -# endif -# if defined MNTTABNAME /* Dynix. */ -# define MOUNTED MNTTABNAME -# endif -#endif -], - [ struct mntent *mnt = 0; char *table = MOUNTED; ], - fu_cv_sys_mounted_getmntent1=yes, - fu_cv_sys_mounted_getmntent1=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) - if test $fu_cv_sys_mounted_getmntent1 = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_GETMNTENT1, 1, - [Define if there is a function named getmntent for reading the list - of mounted filesystems, and that function takes a single argument. - (4.3BSD, SunOS, HP-UX, Dynix, Irix)]) - fi - fi - - if test -z "$ac_list_mounted_fs"; then - # SVR4 - AC_MSG_CHECKING([for two-argument getmntent function]) - AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, - [AC_EGREP_HEADER(getmntent, sys/mnttab.h, - fu_cv_sys_mounted_getmntent2=yes, - fu_cv_sys_mounted_getmntent2=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) - if test $fu_cv_sys_mounted_getmntent2 = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_GETMNTENT2, 1, - [Define if there is a function named getmntent for reading the list of - mounted filesystems, and that function takes two arguments. (SVR4)]) - fi - fi - -fi - -if test -z "$ac_list_mounted_fs"; then - # DEC Alpha running OSF/1, and Apple Darwin 1.3. - # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h - - AC_MSG_CHECKING([for getfsstat function]) - AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat, - [AC_TRY_LINK([ -#include -#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME -# define FS_TYPE(Ent) ((Ent).f_fstypename) -#else -# define FS_TYPE(Ent) mnt_names[(Ent).f_type] -#endif -]$getfsstat_includes -, - [struct statfs *stats; - int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); - char *t = FS_TYPE (*stats); ], - fu_cv_sys_mounted_getfsstat=yes, - fu_cv_sys_mounted_getfsstat=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat) - if test $fu_cv_sys_mounted_getfsstat = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_GETFSSTAT, 1, - [Define if there is a function named getfsstat for reading the - list of mounted filesystems. (DEC Alpha running OSF/1)]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - # SVR3 - AC_MSG_CHECKING([for FIXME existence of three headers]) - AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp, - [AC_TRY_CPP([ -#include -#include -#include ], - fu_cv_sys_mounted_fread_fstyp=yes, - fu_cv_sys_mounted_fread_fstyp=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) - if test $fu_cv_sys_mounted_fread_fstyp = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_FREAD_FSTYP, 1, - [Define if (like SVR2) there is no specific function for reading the - list of mounted filesystems, and your system has these header files: - and . (SVR3)]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - # 4.4BSD and DEC OSF/1. - AC_MSG_CHECKING([for getmntinfo function]) - AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, - [ - test "$ac_cv_func_getmntinfo" = yes \ - && fu_cv_sys_mounted_getmntinfo=yes \ - || fu_cv_sys_mounted_getmntinfo=no - ]) - AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) - if test $fu_cv_sys_mounted_getmntinfo = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_GETMNTINFO, 1, - [Define if there is a function named getmntinfo for reading the - list of mounted filesystems. (4.4BSD, Darwin)]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - # Ultrix - AC_MSG_CHECKING([for getmnt function]) - AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, - [AC_TRY_CPP([ -#include -#include ], - fu_cv_sys_mounted_getmnt=yes, - fu_cv_sys_mounted_getmnt=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) - if test $fu_cv_sys_mounted_getmnt = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_GETMNT, 1, - [Define if there is a function named getmnt for reading the list of - mounted filesystems. (Ultrix)]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - # BeOS - AC_CHECK_FUNCS(next_dev fs_stat_dev) - AC_CHECK_HEADERS(fs_info.h) - AC_MSG_CHECKING([for BEOS mounted file system support functions]) - if test $ac_cv_header_fs_info_h = yes \ - && test $ac_cv_func_next_dev = yes \ - && test $ac_cv_func_fs_stat_dev = yes; then - fu_result=yes - else - fu_result=no - fi - AC_MSG_RESULT($fu_result) - if test $fu_result = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_FS_STAT_DEV, 1, - [Define if there are functions named next_dev and fs_stat_dev for - reading the list of mounted filesystems. (BeOS)]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - # SVR2 - AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) - AC_CACHE_VAL(fu_cv_sys_mounted_fread, - [AC_TRY_CPP([#include ], - fu_cv_sys_mounted_fread=yes, - fu_cv_sys_mounted_fread=no)]) - AC_MSG_RESULT($fu_cv_sys_mounted_fread) - if test $fu_cv_sys_mounted_fread = yes; then - ac_list_mounted_fs=found - AC_DEFINE(MOUNTED_FREAD, 1, - [Define if there is no specific function for reading the list of - mounted filesystems. fread will be used to read /etc/mnttab. - (SVR2) ]) - fi -fi - -if test -z "$ac_list_mounted_fs"; then - AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) - # FIXME -- no need to abort building the whole package - # Can't build mountlist.c or anything that needs its functions -fi - -AS_IF([test $ac_list_mounted_fs = found], [$1], [$2]) - - ]) diff --git a/lib/onceonly.m4 b/lib/onceonly.m4 deleted file mode 100644 index 50b33f48..00000000 --- a/lib/onceonly.m4 +++ /dev/null @@ -1,63 +0,0 @@ -# onceonly.m4 serial 3 (gettext-0.12) -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -dnl This file defines some "once only" variants of standard autoconf macros. -dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS -dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS -dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS -dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC -dnl The advantage is that the check for each of the headers/functions/decls -dnl will be put only once into the 'configure' file. It keeps the size of -dnl the 'configure' file down, and avoids redundant output when 'configure' -dnl is run. -dnl The drawback is that the checks cannot be conditionalized. If you write -dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi -dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to -dnl empty, and the check will be inserted before the body of the AC_DEFUNed -dnl function. - -dnl Autoconf version 2.57 or newer is recommended. -AC_PREREQ(2.54) - -# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of -# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). -AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ - : - AC_FOREACH([gl_HEADER_NAME], [$1], [ - AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(m4_defn([gl_HEADER_NAME]), - [-./], [___])), [ - AC_CHECK_HEADERS(gl_HEADER_NAME) - ]) - AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, - [-./], [___]))) - ]) -]) - -# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of -# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). -AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ - : - AC_FOREACH([gl_FUNC_NAME], [$1], [ - AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ - AC_CHECK_FUNCS(m4_defn([gl_FUNC_NAME])) - ]) - AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) - ]) -]) - -# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of -# AC_CHECK_DECLS(DECL1, DECL2, ...). -AC_DEFUN([AC_CHECK_DECLS_ONCE], [ - : - AC_FOREACH([gl_DECL_NAME], [$1], [ - AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ - AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) - ]) - AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) - ]) -]) diff --git a/lib/safe-read.c b/lib/safe-read.c new file mode 100644 index 00000000..c21d1cf1 --- /dev/null +++ b/lib/safe-read.c @@ -0,0 +1,82 @@ +/* An interface to read and write that retries after interrupts. + Copyright (C) 1993, 1994, 1998, 2002-2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#ifdef SAFE_WRITE +# include "safe-write.h" +#else +# include "safe-read.h" +#endif + +/* Get ssize_t. */ +#include +#if HAVE_UNISTD_H +# include +#endif + +#include +#ifndef errno +extern int errno; +#endif + +#ifdef EINTR +# define IS_EINTR(x) ((x) == EINTR) +#else +# define IS_EINTR(x) 0 +#endif + +#include + +#ifdef SAFE_WRITE +# define safe_rw safe_write +# define rw write +#else +# define safe_rw safe_read +# define rw read +# undef const +# define const /* empty */ +#endif + +/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if + interrupted. Return the actual number of bytes read(written), zero for EOF, + or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */ +size_t +safe_rw (int fd, void const *buf, size_t count) +{ + ssize_t result; + + /* POSIX limits COUNT to SSIZE_MAX, but we limit it further, requiring + that COUNT <= INT_MAX, to avoid triggering a bug in Tru64 5.1. + When decreasing COUNT, keep the file pointer block-aligned. + Note that in any case, read(write) may succeed, yet read(write) + fewer than COUNT bytes, so the caller must be prepared to handle + partial results. */ + if (count > INT_MAX) + count = INT_MAX & ~8191; + + do + { + result = rw (fd, buf, count); + } + while (result < 0 && IS_EINTR (errno)); + + return (size_t) result; +} diff --git a/lib/safe-read.h b/lib/safe-read.h new file mode 100644 index 00000000..cbe6e0bf --- /dev/null +++ b/lib/safe-read.h @@ -0,0 +1,25 @@ +/* An interface to read() that retries after interrupts. + Copyright (C) 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include + +#define SAFE_READ_ERROR ((size_t) -1) + +/* Read up to COUNT bytes at BUF from descriptor FD, retrying if interrupted. + Return the actual number of bytes read, zero for EOF, or SAFE_READ_ERROR + upon error. */ +extern size_t safe_read (int fd, void *buf, size_t count); diff --git a/lib/safe-write.c b/lib/safe-write.c new file mode 100644 index 00000000..fbafa7cc --- /dev/null +++ b/lib/safe-write.c @@ -0,0 +1,19 @@ +/* An interface to write that retries after interrupts. + Copyright (C) 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define SAFE_WRITE +#include "safe-read.c" diff --git a/lib/safe-write.h b/lib/safe-write.h new file mode 100644 index 00000000..ab1f45b4 --- /dev/null +++ b/lib/safe-write.h @@ -0,0 +1,25 @@ +/* An interface to write() that retries after interrupts. + Copyright (C) 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include + +#define SAFE_WRITE_ERROR ((size_t) -1) + +/* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted. + Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR + upon error. */ +extern size_t safe_write (int fd, const void *buf, size_t count); diff --git a/lib/unlocked-io.m4 b/lib/unlocked-io.m4 deleted file mode 100644 index f8e98f1d..00000000 --- a/lib/unlocked-io.m4 +++ /dev/null @@ -1,22 +0,0 @@ -#serial 8 -*- autoconf -*- - -dnl From Jim Meyering. -dnl -dnl See if the glibc *_unlocked I/O macros or functions are available. -dnl Use only those *_unlocked macros or functions that are declared -dnl (because some of them were declared in Solaris 2.5.1 but were removed -dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run -dnl on Solaris 2.6). - -AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO], -[ - dnl Persuade glibc and Solaris to declare - dnl fgets_unlocked(), fputs_unlocked() etc. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_DECLS_ONCE( - [clearerr_unlocked feof_unlocked ferror_unlocked - fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked - fread_unlocked fwrite_unlocked getc_unlocked - getchar_unlocked putc_unlocked putchar_unlocked]) -]) diff --git a/lib/xalloc.m4 b/lib/xalloc.m4 deleted file mode 100644 index dec84177..00000000 --- a/lib/xalloc.m4 +++ /dev/null @@ -1,32 +0,0 @@ -# xalloc.m4 serial 8 -dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -AC_DEFUN([gl_XALLOC], -[ - gl_PREREQ_XALLOC - gl_PREREQ_XMALLOC - gl_PREREQ_XSTRDUP -]) - -# Prerequisites of lib/xalloc.h. -AC_DEFUN([gl_PREREQ_XALLOC], [ - : -]) - -# Prerequisites of lib/xmalloc.c. -AC_DEFUN([gl_PREREQ_XMALLOC], [ - AC_REQUIRE([AC_C_INLINE]) - AC_REQUIRE([jm_FUNC_MALLOC]) - AC_REQUIRE([jm_FUNC_REALLOC]) - : -]) - -# Prerequisites of lib/xstrdup.c. -AC_DEFUN([gl_PREREQ_XSTRDUP], [ - : -]) -- cgit v1.2.3-74-g34f1