watchdog-5.14.orig/ 0000755 0000000 0000000 00000000000 12421467317 011077 5 ustar watchdog-5.14.orig/depcomp 0000755 0000000 0000000 00000056016 12421467317 012464 0 ustar #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 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, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva .
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to .
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
watchdog-5.14.orig/compile 0000755 0000000 0000000 00000016245 12421467317 012465 0 ustar #! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey .
#
# 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, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to or send patches to
# .
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to .
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
watchdog-5.14.orig/examples/ 0000755 0000000 0000000 00000000000 12233767421 012715 5 ustar watchdog-5.14.orig/examples/uptime.sh 0000755 0000000 0000000 00000000632 12233767421 014560 0 ustar #!/bin/sh
#
# this will unconditionally cause a reboot if the uptime increases 2 days
# some hard disks might need this
#
#
# get uptime info
#
upt=`cat /proc/uptime | tr -d . | cut -d' ' -f1`
#
# calculated days uptime, note that this number will never be greater than 2
#
days=`expr $upt / 8640000`
if [ $days -ge 2 ]
then
#
# return code 255 (-1 as unsigned 8-bit) means reboot
#
exit 255
fi
exit 0
watchdog-5.14.orig/examples/dbcheck.sh 0000755 0000000 0000000 00000001043 12233767421 014635 0 ustar #!/bin/sh
#
# check if ORACLE database instance is still reacting to ping requests
#
#
# name of the instance (must be defined in tnsnames.ora)
#
DATABASE=$1
#
# check the state:
# tnsping returns 0 on success, otherise the return value is 1
#
tnsping $DATABASE > /dev/null 2>&1
result=$?
if [ $result -ne 0 ]
then
#
# obviously there is no system error code for this
# so we have to create our own (system codes are > 0): -2.
# note that 255 (-1 as unsigned 8-bit) means reboot
# and 254 (-2) means hard reset.
#
result=254
fi
exit $result
watchdog-5.14.orig/examples/systemcheck.sh 0000644 0000000 0000000 00000000315 11156210360 015556 0 ustar #!/bin/sh
# This checks quite some resources of the system. If for instance libc is
# destroyed you cannot start /bin/sh anymore.
# Courtesy of: Zygo Blaxell
exit 0
watchdog-5.14.orig/examples/another-chance.sh 0000644 0000000 0000000 00000002045 12076233404 016123 0 ustar #!/bin/sh
# This is a "repair binary" for watchdog that allows the tests to fail N times
# within a given period before a reboot is called. Note that this "grace
# period" should really be a functionality of watchdog itself, IMHO.
#
# Erik Rossen
# If one does not change the default watchdog loop time of 10 secords, N=12
# will allow two minutes of failures before a reboot is signaled.
N=12
# CMAXAGE is the age in seconds that the counter file may have before it is
# considered too old and is wiped out.
CMAXAGE=20
ERR=$1
COUNTER=/var/run/watchdog.counter
if test -f $COUNTER; then
COUNTERAGE=$(stat -c %Y $COUNTER)
NOW=$(date +%s)
if test $(($COUNTERAGE+$CMAXAGE)) -lt $NOW ; then
rm $COUNTER
else
I=$(cat $COUNTER)
fi
fi
I=${I:-0}
I=$(($I+1))
logger -t "watchdog[$$]" "Failure $I of $N"
logger -t "watchdog[$$]" "PROCESS LIST:"
ps auxww | logger -t "watchdog[$$]"
if test "$I" -ge "$N" ; then
logger -t "watchdog[$$]" Too many failures. Signalling reboot.
rm $COUNTER
exit $ERR
fi
echo $I > $COUNTER
exit 0
watchdog-5.14.orig/examples/README 0000644 0000000 0000000 00000000344 11156210360 013562 0 ustar I'd like to provide better scripts with watchdog. So if you use your own
script/binary to test the state of your system resp. to act as repair
script, please mail me a copy so I can include it here.
Michael
watchdog-5.14.orig/examples/repair.sh 0000755 0000000 0000000 00000004363 12076233300 014531 0 ustar #!/bin/sh
#
# I try to get a repair script that can handle as many problems as possible.
# Feel free to send me some additions.
#
# (C) Michael Meskes Mon Jun 23 13:40:15 CEST 1997
# Placed under GPL.
# Improvements, and modification for Redhat by Marc Merlin
#
#
# who to send mail to
#
admin=root
#
# let's see what error message we got
#
case $1 in
#
# ENFILE: file table overflow
# => increase file-max by 10%
#
23)
fm=`cat /proc/sys/fs/file-max`
fm=`expr $fm + $fm / 10`
echo $fm > /proc/sys/fs/file-max
#
# create log entry
#
echo "increased file-max to "$fm | logger -i -t repair -p daemon.info
#
# that's it, problem disappeared
#
exit 0;;
#
# ENETDOWN: network is down
# ENETUNREACH: network is unreachable
# => try to reconfigure network interface, there is no guarantee that
# this helps, but if it does not, reboot won't either
#
100|101)
if [ -x /etc/rc.d/init.d/network ]; then
# Redhat
/etc/rc.d/init.d/network stop
elif [ -x /etc/init.d/networking ]; then
# Debian
/etc/init.d/networking stop
else
ifconfig |
awk '/Link/ {print $1}' |
while read device
do
ifconfig ${device} down
done
fi
# Calling rmmod -a twice should remove all unused modules (including networking
# ones). It might not work with very old rmmod binaries though, I don't know
rmmod -a
rmmod -a
#
# make sure the modules gets back into it in case kerneld/kmod does not run
#
for module in `grep "^alias" /etc/conf.modules | awk '/eth/ {print $3}'`
do
modprobe $module
done
#
# bring it back up
#
if [ -x /etc/init.d/networking ]; then
# Debian
/etc/init.d/networking start
elif [ -x /etc/rc.d/init.d/network ]; then
# Redhat
/etc/rc.d/init.d/network start
else
echo "Couldn't find network script to relaunch networking. Please edit $0" | logger -i -t repair -p daemon.info
exit $1
fi
#
# create log entry
#
echo "re-initialized network interface eth0" | logger -i -t repair -p daemon.info
#
# that' all we can do here
#
exit 0;;
esac
#
# couldn't do anything
# tell the sysadmin what's going on
#
if [ -x /usr/bin/mail ]
then
echo `hostname`" is going down because of error "$1|/usr/bin/mail -s "System fault!" ${admin}
fi
#
# finally tell watchdog to reboot
#
exit $1
watchdog-5.14.orig/wd_keepalive.8 0000644 0000000 0000000 00000003632 12233767421 013633 0 ustar .TH WD_KEEPALIVE 8 "January 2005"
.UC 4
.SH NAME
wd_keepalive \- a simplified software watchdog daemon
.SH SYNOPSIS
.B wd_keepalive
.RB [ \-c " \fIfilename\fR|" \-\-config\-file " \fIfilename\fR]"
.SH DESCRIPTION
This is a simplified version of the watchdog daemon. If configured so it only
opens
.IR /dev/watchdog ,
and keeps writing to it often enough to keep the kernel from resetting,
at least once per minute. Each write delays the reboot
time another minute. After a minute of inactivity the watchdog hardware will
cause a reset. In the case of the software watchdog the ability to
reboot will depend on the state of the machines and interrupts.
.PP
The wd_keepalive daemon can be stopped without causing a reboot if the device
.I /dev/watchdog
is closed correctly, unless your kernel is compiled with the
.I CONFIG_WATCHDOG_NOWAYOUT
option enabled.
.PP
Under high system load
.B wd_keepalive
might be swapped out of memory and may fail
to make it back in in time. Under these circumstances the Linux kernel will
reset the machine. To make sure you won't get unnecessary reboots make
sure you have the variable
.I realtime
set to
.I yes
in the configuration file
.IR watchdog.conf .
This adds real time support to
.BR wd_keepalive :
it will lock itself into memory and there should be no problem even under the
highest of loads.
.PP
On system running out of memory the kernel will try to free enough memory by killing process. The
.B wd_keepalive
daemon itself is exempted from this so-called out-of-memory killer.
.SH OPTIONS
Available command line options are the following:
.TP
.BR \-c " \fIconfig-file\fR, " \-\-config\-file " \fIconfig-file"
Use
.I config-file
as the configuration file instead of the default
.IR /etc/watchdog.conf .
.SH FILES
.TP
.I /dev/watchdog
The watchdog device.
.TP
.I /var/run/wd_keepalive.pid
The pid file of the running
.BR wd_keepalive .
.SH "SEE ALSO"
.BR watchdog.conf (5)
.TP
.BR watchdog (8)
watchdog-5.14.orig/AUTHORS 0000644 0000000 0000000 00000001124 12076233300 012132 0 ustar Watchdog developer and credits list
===================================
Michael Meskes
- Maintainer and overall author
- Original Debian patches
Sascha Schumann
- GNU automake/autoconf support
- some compatibility patches
Johnie Ingram
- more Debian patches
Marc Merlin
- RedHat Patches
Miquel van Smoorenburg
- The stuff borrowed from sysvinit
Marcel Jansen
- Quite a lot of additions.
Several people who worked on mount/umount and/or send me patches.
watchdog-5.14.orig/configure.ac 0000644 0000000 0000000 00000011357 12420274125 013364 0 ustar dnl Process this file with autoconf to produce a configure script.
AC_INIT(include/extern.h)
MAJOR_VERSION=5
MINOR_VERSION=14
AM_INIT_AUTOMAKE(watchdog, $MAJOR_VERSION.$MINOR_VERSION)
AC_PREFIX_DEFAULT(/usr)
AC_DEFINE_UNQUOTED(MAJOR_VERSION, $MAJOR_VERSION, "major version number")
AC_DEFINE_UNQUOTED(MINOR_VERSION, $MINOR_VERSION, "minor version number")
AM_CONFIG_HEADER(include/config.h)
AM_SANITY_CHECK
AM_MAINTAINER_MODE
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PATH_PROG(PATH_SENDMAIL, sendmail, /usr/lib/sendmail, $PATH /usr/bin /usr/sbin /usr/etc /etc /usr/ucblib)
if test -n "$PATH_SENDMAIL"; then
AC_DEFINE_UNQUOTED(PATH_SENDMAIL, "$PATH_SENDMAIL", "path to sendmail binary")
fi
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h paths.h sys/ioctl.h sys/time.h syslog.h unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_ST_RDEV
AC_HEADER_TIME
dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gethostname select socket strcspn strdup strerror strstr strtoul uname)
AC_MSG_CHECKING(whether to log via syslog)
AC_ARG_ENABLE(syslog,
[ --disable-syslog Disable logging by syslog (deprecated)],[
if test "$enableval" = "yes"; then
AC_DEFINE(USE_SYSLOG, 1, "enable syslog")
AC_MSG_RESULT(yes)
else
AC_DEFINE(USE_SYSLOG, 0, "enable syslog")
AC_MSG_RESULT(no)
fi
],[
AC_DEFINE(USE_SYSLOG, 1, "enable syslog")
AC_MSG_RESULT(yes)
])
AC_MSG_CHECKING(whether to include NFS support)
AC_ARG_ENABLE(nfs,
[ --disable-nfs Disable NFS support],[
if test "$enableval" = "yes"; then
AC_DEFINE(HAVE_NFS, 1, "enable NFS")
AC_MSG_RESULT(yes)
else
AC_DEFINE(HAVE_NFS, 0, "enable NFS")
AC_MSG_RESULT(no)
fi
],[
AC_DEFINE(HAVE_NFS, 1, "enable NFS")
AC_MSG_RESULT(yes)
])
AC_MSG_CHECKING(for minimum value accepted as reboot cause)
AC_ARG_WITH(minload,
[ --with-minload=int minimum value accepted as reboot cause (default 2)],[
AC_DEFINE_UNQUOTED(MINLOAD, $withval, "minimum value accepted as reboot cause")
AC_MSG_RESULT($withval)
],[
AC_DEFINE(MINLOAD, 2, "minimum value accepted as reboot cause")
AC_MSG_RESULT(2)
])
AC_MSG_CHECKING(for timer margin used by kernel)
AC_ARG_WITH(timermargin,
[ --with-timermargin=int timer margin used by kernel (default 60)],[
AC_DEFINE_UNQUOTED(TIMER_MARGIN, $withval, "timer margin used by kernel")
AC_MSG_RESULT($withval)
],[
AC_DEFINE(TIMER_MARGIN, 60, "timer margin used by kernel")
AC_MSG_RESULT(60)
])
AC_MSG_CHECKING(for config filename)
AC_ARG_WITH(configfile,
[ --with-configfile=filename
name of config file (default /etc/watchdog.conf)],[
AC_DEFINE_UNQUOTED(CONFIG_FILENAME, "$withval", "name of config file")
CONFIG_FILENAME="$withval"
AC_MSG_RESULT($withval)
],[
CONFIG_FILENAME="/etc/watchdog.conf"
AC_DEFINE_UNQUOTED(CONFIG_FILENAME, "$CONFIG_FILENAME", "name of config file")
AC_MSG_RESULT($CONFIG_FILENAME)
])
AC_SUBST(CONFIG_FILENAME)
AC_MSG_CHECKING(for test binary directory)
AC_ARG_WITH(test-bin-path,
[ --with-test-bin-path=directory
path to test binaries (default /etc/watchdog.d)],[
AC_DEFINE_UNQUOTED(TESTBIN_PATH, "$withval", "path to test binaries")
TESTBIN_PATH="$withval"
AC_MSG_RESULT($withval)
],[
TESTBIN_PATH="/etc/watchdog.d"
AC_DEFINE_UNQUOTED(TESTBIN_PATH, "$TESTBIN_PATH", "path to test binaries")
AC_MSG_RESULT($TESTBIN_PATH)
])
AC_SUBST(TESTBIN_PATH)
AC_MSG_CHECKING(for pid filename)
AC_ARG_WITH(pidfile,
[ --with-pidfile=filename name of pid file (default /var/run/watchdog.pid)],[
AC_DEFINE_UNQUOTED(PIDFILE, "$withval", "name of pid file")
AC_MSG_RESULT($withval)
],[
AC_DEFINE(PIDFILE, "/var/run/watchdog.pid", "name of pid file")
AC_MSG_RESULT("/var/run/watchdog.pid")
])
AC_MSG_CHECKING(for keepalive pid filename)
AC_ARG_WITH(ka_pidfile,
[ --with-ka_pidfile=filename name of keepalive pid file (default /var/run/wd_keepalive.pid)],[
AC_DEFINE_UNQUOTED(KA_PIDFILE, "$withval", "name of keepalive pid file")
AC_MSG_RESULT($withval)
],[
AC_DEFINE(KA_PIDFILE, "/var/run/wd_keepalive.pid", "name of keepalive pid file")
AC_MSG_RESULT("/var/run/wd_keepalive.pid")
])
AC_MSG_CHECKING(for random seed filename)
AC_ARG_WITH(randomseed,
[ --with-randomseed=filename
filename for storing random seed (default /var/run/random-seed)],[
AC_DEFINE_UNQUOTED(RANDOM_SEED, "$withval", filename for storing random seed")
AC_MSG_RESULT($withval)
],[
AC_DEFINE(RANDOM_SEED, "/var/run/random-seed", "filename for storing random seed")
AC_MSG_RESULT("/var/run/random-seed")
])
AC_OUTPUT([Makefile src/Makefile])
watchdog-5.14.orig/INSTALL 0000644 0000000 0000000 00000003577 12076233300 012131 0 ustar If you're on a Debian system, make -f debian/rules binary creates the
watchdog package. It's even easier if you use debmake, just call build.
(Note that the Debian files are not distributed with the original source
anymore. You have to get the Debian .diff.gz file, too.)
If you use redhat, you can use the .spec file to generate a package. But as
with Debian you have to get the .spec file from the RedHat sources. Copy
watchdog.spec to /usr/src/redhat/SPECS, copy the .tar.gz archive to
/usr/src/redhat/SOURCES, cd /usr/src/redhat/SPECS, rpm -ba watchdog.spec.
(Note that the watchdog.spec file not distributed with the original source
either.)
If your Linux distribution does not include watchdog feel free to ask the
distributor to add it. Since watchdog is GPLed there should not be a
problem.
Okay, if you want to install it manually:
$ autoreconf -i (if you're building from CVS)
$ ./configure
$ make
$ su
# make install
There are several options available which can be listed by running
$ ./configure --help
We only list some options here which are generally useful.
Symbols:
*cl - can be overridden in the command line
*cf - can be overridden in the config file
--with-sleep-interval=sec (default 10) *cl *cf
This allows you to set the default number of seconds which watchdog
will sleep before acting again.
--with-sysadmin=email (default root) *cf
If watchdog attempts to reboot a machine, it will try to send an email out
before that. You can set the email address of the recipient with this
option.
--with-maxload=int (default 12) *cf
If the load average reaches this point, the machine will reboot.
--with-watchdog=path (default /dev/watchdog) *cf
--with-temperature=path (default /dev/temperature) *cf
Sets the path for the respective device.
Enjoy
Michael
watchdog-5.14.orig/watchdog.conf.5 0000644 0000000 0000000 00000014304 12420301715 013677 0 ustar .TH WATCHDOG.CONF 5 "January 2005"
.UC 4
.SH NAME
watchdog.conf \- configuration file for the watchdog daemon
.SH DESCRIPTION
This file carries all configuration options for the Linux watchdog daemon.
Each option has to be written on a line for itself. Comments start with '#'.
Blanks are ignored except after the '=' sign. An empty text after the '='
sign disables the feature as long as that makes sense.
.SH OPTIONS
.TP
interval =
Set the highest possible interval between two writes to the watchdog device.
The device is triggered after each check regardless of the time it took. After
finishing all checks watchdog goes to sleep for a full cycle of
seconds. Default value is 1 second. The kernel drivers expects a write command
every minute. Otherwise the system will be rebooted. Therefore an interval of
more than a minute can only be used with the \-f command-line option.
.TP
logtick =
If you enable verbose logging, a message is written into the syslog or a
logfile. While this is nice, it is not necessary to get a message every
10 seconds which really fills up disk and needs CPU. logtick allows adjustment
of the number of intervals skipped before a log message is written. If you
use logtick = 60 and interval = 10, only every 10 minutes (600 seconds) a
message is written. This may make the exact time of a crash harder to find but
greatly reduces disk usage and administrator nerves if you're looking for a
particular syslog entry in between of watchdog messages.
.TP
max-load-1 =
Set the maximal allowed load average for a 1 minute span. Once this load
average is reached the system is rebooted. Default value is 0. That means
the load average check is disabled. Be careful not to this parameter too
low. To set a value less then the predefined minimal value of 2, you have to
use the \-f commandline option.
.TP
max-load-5 =
Set the maximal allowed load average for a 5 minute span. Once this load
average is reached the system is rebooted. Default value is 3/4*max-load-1.
Be careful not to this parameter too low. To set a value less then the
predefined minimal value of 2, you have to use the \-f commandline option.
.TP
max-load-15 =
Set the maximal allowed load average for a 15 minute span. Once this load
average is reached the system is rebooted. Default value is 1/2*max-load-1.
Be careful not to this parameter too low. To set a value less then the
predefined minimal value of 2, you have to use the \-f commandline option.
.TP
min-memory =
Set the minimal amount of virtual memory that has to stay free. Note that
this is in pages. Default value is 0 pages which means this test is
disabled. The page size is taken from the system include files.
.TP
allocatable-memory =
Set the minimum amount of allocatable memory available on the system.
Note that this is in pages. Default value is 0 pages which means the test
is disabled. As with min-memory, the page size is taken from the system
include files.
.TP
max-temperature =
Set the maximal allowed temperature. Once this temperature is reached the
system is halted. Default value is 120. There is no unit conversion, so make
sure you use the same unit as your hardware. Watchdog will issue warnings
once the temperature increases 90%, 95% and 98% of this temperature.
.TP
watchdog-device =
Set the watchdog device name. Default is to disable keep alive support.
.TP
watchdog-timeout =
Set the watchdog device timeout during startup. If not set, a default is used
that should be set to the kernel timer margin at compile time.
.TP
temperature-device =
Set the temperature device name. Default is to disable temperature checking.
.TP
file =
Set file name for file mode.
This option can be given as often as you like to check several files.
.TP
change =
Set the change interval time for file mode. This options
always belongs to the active filename, that is when finding a 'change ='
line watchdog assumes it belongs to the most recently read 'file =' line.
They don't neccessarily have to follow each other directly. But you cannot
specify a 'change =' before a 'file ='.
The default is to only stat the file and don't look for changes.
Using this feature to monitor changes in /var/log/messages might require some
special syslog daemon configuration, e.g. rsyslog needs
"$ActionWriteAllMarkMessages on" to be set to make sure the marks are written
no matter what.
.TP
pidfile =
Set pidfile name for server test mode.
This option can be given as often as you like to check several servers.
.TP
ping =
Set IP address for ping mode.
This option can be used more than once to check different
connections.
.TP
interface =
Set interface name for network mode.
This option can be used more than once to check different
interfaces.
.TP
test-binary =
Execute the given binary to do some user defined tests.
.TP
test-timeout =
User defined tests may only run for seconds. Set to 0 for unlimited.
.TP
repair-binary =
Execute the given binary in case of a problem instead of shutting down the
system.
.TP
repair-timeout =
repair command may only run for seconds. Set to 0 for unlimited.
.TP
admin =
Email address to send admin mail to. That is, who shall be notified that the
machine is being halted or rebooted. Default is 'root'. If you want to disable
notification via email just set admin to en empty string.
.TP
realtime =
If set to yes watchdog will lock itself into memory so it is never swapped
out.
.TP
priority =
Set the schedule priority for realtime mode.
.TP
test-directory =
Set the directory to run user test/repair scripts. Default is '/etc/watchdog.d'
See the Test Directory section in watchdog(8) for more information.
.TP
log-dir =
Set the log directory to capture the standard output and standard error from
repair-binary and test-binary execution. Default is '/var/log/watchdog'.
.SH FILES
.TP
.I /etc/watchdog.conf
The watchdog configuration file
.TP
.I /etc/watchdog.d
A directory containing test-or-repair commands. See the Test Directory
section in watchdog(8) for more information.
.SH "SEE ALSO"
.BR watchdog (8)
watchdog-5.14.orig/missing 0000755 0000000 0000000 00000015330 12421467317 012500 0 ustar #! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard , 1996.
# 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, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to ."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
watchdog-5.14.orig/Makefile.am 0000644 0000000 0000000 00000001303 12233767421 013130 0 ustar
man_MANS = watchdog.8 wd_keepalive.8 watchdog.conf.5 wd_identify.8
# This does not work. subdirs are not copied correctly
# for make dist... :(
EXTRA_DIST = $(man_MANS) include examples ChangeLog watchdog.lsm \
watchdog.conf rc.watchdog.debian rc.watchdog.redhat
SUBDIRS = src
CONFIG_FILENAME = @CONFIG_FILENAME@
install-etc-local: watchdog.conf
@if test -e $(DESTDIR)$(CONFIG_FILENAME) ; then \
echo "NOT installing $(CONFIG_FILENAME) - exists already"; \
else \
echo "installing $(CONFIG_FILENAME)"; \
$(mkinstalldirs) `dirname $(DESTDIR)$(CONFIG_FILENAME)`; \
$(INSTALL_DATA) watchdog.conf $(DESTDIR)$(CONFIG_FILENAME); \
fi
install-data-local: install-etc-local
watchdog-5.14.orig/create_tarball.sh 0000644 0000000 0000000 00000001070 12326772051 014373 0 ustar #!/bin/sh
# start this script inside the watchdog source tree to create a releasable tarball
major=`grep MAJOR_VERSION= configure.ac | cut -f2 -d"="`
minor=`grep MINOR_VERSION= configure.ac | cut -f2 -d"="`
if [ -d ../watchdog-$major.$minor ]
then
echo "target directory exists"
exit 1
fi
cp -a . ../watchdog-$major.$minor
cd ../watchdog-$major.$minor
aclocal
autoheader
automake --add-missing --copy
autoconf
rm -rf autom4te.cache
cd ..
tar --exclude CVS --exclude .git -zcf watchdog-$major.$minor.tar.gz watchdog-$major.$minor && rm -rf watchdog-$major.$minor
watchdog-5.14.orig/watchdog.sysconfig 0000644 0000000 0000000 00000000235 12076233263 014622 0 ustar #
# /etc/sysconfig/watchdog
#
# Controls the behaviour of the watchdog
#
# VERBOSE - Enables or disables verbose operation (logging to syslog)
#
VERBOSE=no
watchdog-5.14.orig/README.watchdog.ipmi 0000644 0000000 0000000 00000011453 12076233404 014511 0 ustar This is RedHat/Fedora specific, but can be used with other distros with minor adjustments.
Instructions for how to set up the watchdog daemon to work with IPMI's hardware watchdog
----------------------------------------------------------------------------------------
First, verify that the ipmitool utility is present on the system to allow
the watchdog timer to be turned off via the command line (which ipmitool).
This will allow the hardware watchdog timer to be turned off gracefully
should it ever become necessary. If ipmitool is not present, install
it or download the latest version from http://ipmitool.sourceforge.net and
build and install it on your system.
Next, prior to starting up the watchdog daemon, the BMC BIOS should be set
to enable the IPMI/BMC hardware watchdog timer, the OpenIPMI watchdog driver
module should be inserted with the desired configuration/startup settings,
and the watchdog daemon's configuration file should be modified to use /dev/watchdog:
1. To setup the IPMI/BMC BIOS to enable the hardware watchdog
timer, see BMC documentation. The main settings in the BMC BIOS
requiring modification to turn on the IPMI watchdog timer are:
- Set the BMC POST Watchdog to "ENABLED".
- Set the BMC POST Watchdog Timeout to "5 Minutes".
2. To insert the OpenIPMI watchdog driver module with the
desired configuration settings, two steps are necessary:
i.) Configure the OpenIPMI watchdog driver by editing the
/etc/sysconfig/ipmi configuration file:
- Set "IPMI_WATCHDOG=yes".
- Set desired options via the IPMI_WATCHDOG_OPTIONS
config entry.
EXAMPLE: 'IPMI_WATCHDOG_OPTIONS="timeout=60 start_now=1 \
preop=preop_give_data action=power_cycle pretimeout=1" '
Execute "modinfo ipmi_watchdog" for more detailed information
on the available ipmi watchdog timer options.
- Execute "service ipmi start" (the watchdog driver starts
automatically along with the other ipmi drivers).
IMPORTANT: If "start_now=1" has been set as one of the
configuration options, be sure to start up the watchdog
daemon before the BMC timer expires!
ii.) Set the OpenIPMI daemon and watchdog to start during bootup:
- chkconfig ipmi on
- chkconfig watchdog on
3. Configure the watchdog daemon by editing the
/etc/watchdog.conf configuration file:
- Uncomment the "watchdog-device = /dev/watchdog" line.
- Ensure that "realtime = yes" and "priority = 1" are set and not
commented-out.
- Uncomment the "interval" line, and set the interval to be less
than what you set the timeout option to be in the /etc/sysconfig/ipmi
file (ex "timeout=60" so you might set interval to 50).
So in the example described herein, the BMC BIOS setting is in
minutes (5), and the "interval" and ipmi_watchdog "timeout" settings
are both in seconds (50 and 60 respectively). Therefore, the BMC
hardware watchdog timer is set to expire and trigger a system power
cycle unless reset by the watchdog daemon within 5 minutes, and the
watchdog daemon will reset the timer every 60 seconds.
4. Start the Watchdog daemon:
- execute "service watchdog start"
IMPORTANT: To gracefully stop/kill the watchdog daemon, be sure
to use "service watchdog stop" (which executes "kill -s SIGTERM ")
and do *not* use "kill -9 ". Using "kill -9 " will cause the
daemon to be shut off without stopping the BMC's watchdog timer, thus
a system reboot will be triggered when the BMC's watchdog timer expires.
Alternately, or in case the watchdog daemon is killed "ungracefully",
you can stop the BMC timer by executing the following ipmitool utility
command before the watchdog timer expires:
# ipmitool -v raw 0x06 0x24 0x04 0x01 0x00 0x10 0x00 0x0a
----------------------------------------------------------------------
To test the watchdog after system configuration and setup:
. Use kill -9 on the watchdog daemon so it doesn't shut down the watchdog daemon
gracefully. Verify that the system gets reset after the BMC timer expires.
. Use "service watchdog stop" and verify that the watchdog daemon shuts off
the BMC watchdog timer gracefully (the system doesn't get reset).
. Set the timer on the watchdog daemon to be greater than the time set in
the BMC BIOS for system reset and verify that the system is reset.
. Set the timer on the daemon to be less than the time set in the
BMC timer and verify that the BMC watchdog is poked regularly and the
system is not reset.
. Test some of the other actions the BMC can take when the watchdog timer
goes off (see modinfo ipmi_watchdog for some other settings to try).
watchdog-5.14.orig/aclocal.m4 0000644 0000000 0000000 00000127062 12421467316 012746 0 ustar # generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is '.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ([2.52])dnl
m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
[$1], [CXX], [depcc="$CXX" am_compiler_list=],
[$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
[$1], [UPC], [depcc="$UPC" am_compiler_list=],
[$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named 'D' -- because '-MD' means "put the output
# in D".
rm -rf conftest.dir
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
# Solaris 10 /bin/sh.
echo '/* dummy */' > sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with '-c' and '-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle '-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs.
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
nosideeffect)
# After this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested.
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
msvc7 | msvc7msys | msvisualcpp | msvcmsys)
# This compiler won't grok '-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
if depmode=$depmode \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE([dependency-tracking], [dnl
AS_HELP_STRING(
[--enable-dependency-tracking],
[do not reject slow dependency extractors])
AS_HELP_STRING(
[--disable-dependency-tracking],
[speeds up one-time build])])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
am__nodep='_no'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
AC_SUBST([am__nodep])dnl
_AM_SUBST_NOTMAKE([am__nodep])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[{
# Older Autoconf quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named 'Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running 'make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "$am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each '.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])
[_AM_PROG_CC_C_O
])
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.65])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I."
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
# test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[AC_DIAGNOSE([obsolete],
[$0: two- and three-arguments forms are deprecated.])
m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
[ok:ok],,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
AM_MISSING_PROG([AUTOCONF], [autoconf])
AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
AM_MISSING_PROG([AUTOHEADER], [autoheader])
AM_MISSING_PROG([MAKEINFO], [makeinfo])
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
#
#
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES([CC])],
[m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES([CXX])],
[m4_define([AC_PROG_CXX],
m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES([OBJC])],
[m4_define([AC_PROG_OBJC],
m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[_AM_DEPENDENCIES([OBJCXX])],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
])
AC_REQUIRE([AM_SILENT_RULES])dnl
dnl The testsuite driver may need to know about EXEEXT, so add the
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes. So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
cat >&2 <<'END'
Oops!
Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present. This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard:
Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message. This
can help us improve future automake versions.
END
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
echo 'Configuration will proceed anyway, since you have set the' >&2
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
echo >&2
else
cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: .
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.
END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi
])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$_am_arg | $_am_arg:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
*)
install_sh="\${SHELL} $am_aux_dir/install-sh"
esac
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MAINTAINER_MODE([DEFAULT-MODE])
# ----------------------------------
# Control maintainer-specific portions of Makefiles.
# Default is to disable them, unless 'enable' is passed literally.
# For symmetry, 'disable' may be passed as well. Anyway, the user
# can override the default with the --enable/--disable switch.
AC_DEFUN([AM_MAINTAINER_MODE],
[m4_case(m4_default([$1], [disable]),
[enable], [m4_define([am_maintainer_other], [disable])],
[disable], [m4_define([am_maintainer_other], [enable])],
[m4_define([am_maintainer_other], [enable])
m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode's default is 'disable' unless 'enable' is passed
AC_ARG_ENABLE([maintainer-mode],
[AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
am_maintainer_other[ make rules and dependencies not useful
(and sometimes confusing) to the casual installer])],
[USE_MAINTAINER_MODE=$enableval],
[USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
AC_MSG_RESULT([$USE_MAINTAINER_MODE])
AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
MAINT=$MAINTAINER_MODE_TRUE
AC_SUBST([MAINT])dnl
]
)
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it is modern enough.
# If it is, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --is-lightweight"; then
am_missing_run="$MISSING "
else
am_missing_run=
AC_MSG_WARN(['missing' script is too old or missing])
fi
])
# -*- Autoconf -*-
# Obsolete and "removed" macros, that must however still report explicit
# error messages when used, to smooth transition.
#
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([AM_CONFIG_HEADER],
[AC_DIAGNOSE([obsolete],
['$0': this macro is obsolete.
You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
AC_CONFIG_HEADERS($@)])
AC_DEFUN([AM_PROG_CC_STDC],
[AC_PROG_CC
am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
AC_DIAGNOSE([obsolete],
['$0': this macro is obsolete.
You should simply use the 'AC][_PROG_CC' macro instead.
Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
but upon 'ac_cv_prog_cc_stdc'.])])
AC_DEFUN([AM_C_PROTOTYPES],
[AC_FATAL([automatic de-ANSI-fication support has been removed])])
AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# --------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
# _AM_SET_OPTIONS(OPTIONS)
# ------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_CC_C_O
# ---------------
# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
# to automatically call this.
AC_DEFUN([_AM_PROG_CC_C_O],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([compile])dnl
AC_LANG_PUSH([C])dnl
AC_CACHE_CHECK(
[whether $CC understands -c and -o together],
[am_cv_prog_cc_c_o],
[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
# Make sure it works both with $CC and with simple cc.
# Following AC_PROG_CC_C_O, we do the test twice because some
# compilers refuse to overwrite an existing .o file with -o,
# though they will create one.
am_cv_prog_cc_c_o=yes
for am_i in 1 2; do
if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
&& test -f conftest2.$ac_objext; then
: OK
else
am_cv_prog_cc_c_o=no
break
fi
done
rm -f core conftest*
unset am_i])
if test "$am_cv_prog_cc_c_o" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_RUN_LOG(COMMAND)
# -------------------
# Run COMMAND, save the exit status in ac_status, and log it.
# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
AC_DEFUN([AM_RUN_LOG],
[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
(exit $ac_status); }])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
*[[\\\"\#\$\&\'\`$am_lf]]*)
AC_MSG_ERROR([unsafe absolute working directory name]);;
esac
case $srcdir in
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
esac
# Do 'set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
am_has_slept=no
for am_try in 1 2; do
echo "timestamp, slept: $am_has_slept" > conftest.file
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t "$srcdir/configure" conftest.file`
fi
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
if test "$[2]" = conftest.file || test $am_try -eq 2; then
break
fi
# Just in case.
sleep 1
am_has_slept=yes
done
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT([yes])
# If we didn't sleep, we still need to ensure time stamps of config.status and
# generated files are strictly newer.
am_sleep_pid=
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
( sleep 1 ) &
am_sleep_pid=$!
fi
AC_CONFIG_COMMANDS_PRE(
[AC_MSG_CHECKING([that generated files are newer than configure])
if test -n "$am_sleep_pid"; then
# Hide warnings about reused PIDs.
wait $am_sleep_pid 2>/dev/null
fi
AC_MSG_RESULT([done])])
rm -f conftest.file
])
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_SILENT_RULES([DEFAULT])
# --------------------------
# Enable less verbose build rules; with the default set to DEFAULT
# ("yes" being less verbose, "no" or empty being verbose).
AC_DEFUN([AM_SILENT_RULES],
[AC_ARG_ENABLE([silent-rules], [dnl
AS_HELP_STRING(
[--enable-silent-rules],
[less verbose build output (undo: "make V=1")])
AS_HELP_STRING(
[--disable-silent-rules],
[verbose build output (undo: "make V=0")])dnl
])
case $enable_silent_rules in @%:@ (((
yes) AM_DEFAULT_VERBOSITY=0;;
no) AM_DEFAULT_VERBOSITY=1;;
*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
esac
dnl
dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
dnl do not support nested variable expansions.
dnl See automake bug#9928 and bug#10237.
am_make=${MAKE-make}
AC_CACHE_CHECK([whether $am_make supports nested variables],
[am_cv_make_support_nested_variables],
[if AS_ECHO([['TRUE=$(BAR$(V))
BAR0=false
BAR1=true
V=1
am__doit:
@$(TRUE)
.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
am_cv_make_support_nested_variables=yes
else
am_cv_make_support_nested_variables=no
fi])
if test $am_cv_make_support_nested_variables = yes; then
dnl Using '$V' instead of '$(V)' breaks IRIX make.
AM_V='$(V)'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
else
AM_V=$AM_DEFAULT_VERBOSITY
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
fi
AC_SUBST([AM_V])dnl
AM_SUBST_NOTMAKE([AM_V])dnl
AC_SUBST([AM_DEFAULT_V])dnl
AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
AM_BACKSLASH='\'
AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor 'install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in "make install-strip", and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using 'strip' when the user
# run "make install-strip". However 'strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the 'STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# --------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of 'v7', 'ustar', or 'pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
#
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AC_SUBST([AMTAR], ['$${TAR-tar}'])
# We'll loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
m4_if([$1], [v7],
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
[m4_case([$1],
[ustar],
[# The POSIX 1988 'ustar' format is defined with fixed-size fields.
# There is notably a 21 bits limit for the UID and the GID. In fact,
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
# and bug#13588).
am_max_uid=2097151 # 2^21 - 1
am_max_gid=$am_max_uid
# The $UID and $GID variables are not portable, so we need to resort
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
# below are definitely unexpected, so allow the users to see them
# (that is, avoid stderr redirection).
am_uid=`id -u || echo unknown`
am_gid=`id -g || echo unknown`
AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
if test $am_uid -le $am_max_uid; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
_am_tools=none
fi
AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
if test $am_gid -le $am_max_gid; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
_am_tools=none
fi],
[pax],
[],
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Go ahead even if we have the value already cached. We do so because we
# need to set the values for the 'am__tar' and 'am__untar' variables.
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
for _am_tool in $_am_tools; do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar; do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works.
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar /dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
watchdog-5.14.orig/Makefile.in 0000644 0000000 0000000 00000072206 12421467317 013153 0 ustar # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = .
DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
$(top_srcdir)/include/config.h.in COPYING TODO compile \
install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man5dir = $(mandir)/man5
am__installdirs = "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)"
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFIG_FILENAME = @CONFIG_FILENAME@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SENDMAIL = @PATH_SENDMAIL@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TESTBIN_PATH = @TESTBIN_PATH@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
man_MANS = watchdog.8 wd_keepalive.8 watchdog.conf.5 wd_identify.8
# This does not work. subdirs are not copied correctly
# for make dist... :(
EXTRA_DIST = $(man_MANS) include examples ChangeLog watchdog.lsm \
watchdog.conf rc.watchdog.debian rc.watchdog.redhat
SUBDIRS = src
all: all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
include/config.h: include/stamp-h1
@test -f $@ || rm -f include/stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) include/stamp-h1
include/stamp-h1: $(top_srcdir)/include/config.h.in $(top_builddir)/config.status
@rm -f include/stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status include/config.h
$(top_srcdir)/include/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f include/stamp-h1
touch $@
distclean-hdr:
-rm -f include/config.h include/stamp-h1
install-man5: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man5dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.5[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
done; }
uninstall-man5:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man5dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.5[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir)
install-man8: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man8dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.8[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
done; }
uninstall-man8:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man8dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.8[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(MANS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-data-local install-man
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man: install-man5 install-man8
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-man
uninstall-man: uninstall-man5 uninstall-man8
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
distcheck distclean distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-data-local install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-man5 install-man8 install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-man uninstall-man5 uninstall-man8
install-etc-local: watchdog.conf
@if test -e $(DESTDIR)$(CONFIG_FILENAME) ; then \
echo "NOT installing $(CONFIG_FILENAME) - exists already"; \
else \
echo "installing $(CONFIG_FILENAME)"; \
$(mkinstalldirs) `dirname $(DESTDIR)$(CONFIG_FILENAME)`; \
$(INSTALL_DATA) watchdog.conf $(DESTDIR)$(CONFIG_FILENAME); \
fi
install-data-local: install-etc-local
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
watchdog-5.14.orig/src/ 0000755 0000000 0000000 00000000000 12421467317 011666 5 ustar watchdog-5.14.orig/src/fstab.c 0000644 0000000 0000000 00000021756 12326764724 013152 0 ustar /* $Header: /cvsroot/watchdog/watchdog/src/fstab.c,v 1.2 2006/07/31 09:39:23 meskes Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define _GNU_SOURCE /* for strsignal() */
#include
#include
#include
#include
#include
#include "wd_mntent.h"
#include "fstab.h"
#include "sundries.h" /* for xmalloc() etc */
#define streq(s, t) (strcmp ((s), (t)) == 0)
#define PROC_MOUNTS "/proc/mounts"
/* Information about mtab. ------------------------------------*/
static int have_mtab_info = 0;
static int var_mtab_does_not_exist = 0;
static int var_mtab_is_a_symlink = 0;
static void get_mtab_info(void)
{
struct stat mtab_stat;
if (!have_mtab_info) {
if (lstat(MOUNTED, &mtab_stat))
var_mtab_does_not_exist = 1;
else if (S_ISLNK(mtab_stat.st_mode))
var_mtab_is_a_symlink = 1;
have_mtab_info = 1;
}
}
int mtab_does_not_exist(void)
{
get_mtab_info();
return var_mtab_does_not_exist;
}
int mtab_is_a_symlink(void)
{
get_mtab_info();
return var_mtab_is_a_symlink;
}
int mtab_is_writable()
{
static int ret = -1;
/* Should we write to /etc/mtab upon an update?
Probably not if it is a symlink to /proc/mounts, since that
would create a file /proc/mounts in case the proc filesystem
is not mounted. */
if (mtab_is_a_symlink())
return 0;
if (ret == -1) {
int fd = open(MOUNTED, O_RDWR | O_CREAT, 0644);
if (fd >= 0) {
close(fd);
ret = 1;
} else
ret = 0;
}
return ret;
}
/* Contents of mtab and fstab ---------------------------------*/
struct mntentchn mounttable, fstab;
static int got_mtab = 0;
static int got_fstab = 0;
static void read_mounttable(void), read_fstab(void);
struct mntentchn *mtab_head()
{
if (!got_mtab)
read_mounttable();
return &mounttable;
}
struct mntentchn *fstab_head()
{
if (!got_fstab)
read_fstab();
return &fstab;
}
static void read_mntentchn(mntFILE * mfp, const char *fnam, struct mntentchn *mc0)
{
struct mntentchn *mc = mc0;
struct mntent *mnt;
while ((mnt = my_getmntent(mfp)) != NULL && !streq(mnt->mnt_type, MNTTYPE_IGNORE)) {
mc->nxt = (struct mntentchn *)xmalloc(sizeof(*mc));
mc->nxt->prev = mc;
mc = mc->nxt;
mc->mnt_fsname = mnt->mnt_fsname;
mc->mnt_dir = mnt->mnt_dir;
mc->mnt_type = mnt->mnt_type;
mc->mnt_opts = mnt->mnt_opts;
mc->nxt = NULL;
}
mc0->prev = mc;
if (ferror(mfp->mntent_fp)) {
error("warning: error reading %s: %s", fnam, strerror(errno));
mc0->nxt = mc0->prev = NULL;
}
my_endmntent(mfp);
}
/*
* Read /etc/mtab. If that fails, try /proc/mounts.
* This produces a linked list. The list head mounttable is a dummy.
* Return 0 on success.
*/
static void read_mounttable()
{
mntFILE *mfp;
const char *fnam;
struct mntentchn *mc = &mounttable;
got_mtab = 1;
mc->nxt = mc->prev = NULL;
fnam = MOUNTED;
mfp = my_setmntent(fnam, "r");
if (mfp == NULL || mfp->mntent_fp == NULL) {
int errsv = errno;
fnam = PROC_MOUNTS;
if (mfp != NULL)
free(mfp);
mfp = my_setmntent(fnam, "r");
if (mfp == NULL || mfp->mntent_fp == NULL) {
error("warning: can't open %s: %s", MOUNTED, strerror(errsv));
return;
}
if (mount_verbose)
printf("mount: could not open %s - using %s instead\n", MOUNTED, PROC_MOUNTS);
}
read_mntentchn(mfp, fnam, mc);
}
static void read_fstab()
{
mntFILE *mfp = NULL;
const char *fnam;
struct mntentchn *mc = &fstab;
got_fstab = 1;
mc->nxt = mc->prev = NULL;
fnam = _PATH_FSTAB;
mfp = my_setmntent(fnam, "r");
if (mfp == NULL || mfp->mntent_fp == NULL) {
error("warning: can't open %s: %s", _PATH_FSTAB, strerror(errno));
return;
}
read_mntentchn(mfp, fnam, mc);
}
/* Given the name NAME, try to find it in mtab. */
struct mntentchn *getmntfile(const char *name)
{
struct mntentchn *mc;
for (mc = mtab_head()->nxt; mc; mc = mc->nxt)
if (streq(mc->mnt_dir, name) || (streq(mc->mnt_fsname, name)))
break;
return mc;
}
/* Given the name FILE, try to find the option "loop=FILE" in mtab. */
struct mntentchn *getmntoptfile(const char *file)
{
struct mntentchn *mc;
char *opts, *s;
int l;
if (!file)
return NULL;
l = strlen(file);
for (mc = mtab_head()->nxt; mc; mc = mc->nxt)
if ((opts = mc->mnt_opts) != NULL && (s = strstr(opts, "loop="))
&& !strncmp(s + 5, file, l)
&& (s == opts || s[-1] == ',')
&& (s[l + 5] == 0 || s[l + 5] == ','))
return mc;
return NULL;
}
/* Find the dir FILE in fstab. */
struct mntentchn *getfsfile(const char *file)
{
struct mntentchn *mc;
for (mc = fstab_head()->nxt; mc; mc = mc->nxt)
if (streq(mc->mnt_dir, file))
break;
return mc;
}
/* Find the device SPEC in fstab. */
struct mntentchn *getfsspec(const char *spec)
{
struct mntentchn *mc;
for (mc = fstab_head()->nxt; mc; mc = mc->nxt)
if (streq(mc->mnt_fsname, spec))
break;
return mc;
}
/* Updating mtab ----------------------------------------------*/
/* File descriptor for lock. Value tested in unlock_mtab() to remove race. */
static int lock = -1;
/* Flag for already existing lock file. */
static int old_lockfile = 1;
/* Ensure that the lock is released if we are interrupted. */
static void handler(int sig)
{
die(EX_USER, "%s", strsignal(sig));
}
static void setlkw_timeout(int sig)
{
/* nothing, fcntl will fail anyway */
}
/* Create the lock file. The lock file will be removed if we catch a signal
or when we exit. The value of lock is tested to remove the race. */
void lock_mtab(void)
{
int sig = 0;
struct sigaction sa;
struct flock flock;
/* If this is the first time, ensure that the lock will be removed. */
if (lock < 0) {
struct stat st;
sa.sa_handler = handler;
sa.sa_flags = 0;
sigfillset(&sa.sa_mask);
while (sigismember(&sa.sa_mask, ++sig) != -1 && sig != SIGCHLD) {
if (sig == SIGALRM)
sa.sa_handler = setlkw_timeout;
else
sa.sa_handler = handler;
sigaction(sig, &sa, (struct sigaction *)0);
}
/* This stat is performed so we know when not to be overly eager
when cleaning up after signals. The window between stat and
open is not significant. */
if (lstat(MOUNTED_LOCK, &st) < 0 && errno == ENOENT)
old_lockfile = 0;
lock = open(MOUNTED_LOCK, O_WRONLY | O_CREAT, 0);
if (lock < 0) {
die(EX_FILEIO, "can't create lock file %s: %s "
"(use -n flag to override)", MOUNTED_LOCK, strerror(errno));
}
flock.l_type = F_WRLCK;
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 0;
alarm(LOCK_TIMEOUT);
if (fcntl(lock, F_SETLKW, &flock) == -1) {
int errnosv = errno;
close(lock);
lock = -1; /* The file should not be removed */
die(EX_FILEIO, "can't lock lock file %s: %s",
MOUNTED_LOCK, errnosv == EINTR ? "timed out" : strerror(errno));
}
/* We have now access to the lock, and it can always be removed */
old_lockfile = 0;
}
}
/* Remove lock file. */
void unlock_mtab(void)
{
if (lock != -1) {
close(lock);
if (!old_lockfile)
unlink(MOUNTED_LOCK);
}
}
/*
* Update the mtab.
* Used by umount with null INSTEAD: remove any DIR entries.
* Used by mount upon a remount: update option part,
* and complain if a wrong device or type was given.
* [Note that often a remount will be a rw remount of /
* where there was no entry before, and we'll have to believe
* the values given in INSTEAD.]
*/
void update_mtab(const char *dir, struct mntent *instead)
{
struct mntent *mnt;
struct mntent *next;
struct mntent remnt;
int added = 0;
mntFILE *mfp, *mftmp;
if (mtab_does_not_exist() || mtab_is_a_symlink())
return;
lock_mtab();
mfp = my_setmntent(MOUNTED, "r");
if (mfp == NULL || mfp->mntent_fp == NULL) {
error("cannot open %s (%s) - mtab not updated", MOUNTED, strerror(errno));
goto leave;
}
mftmp = my_setmntent(MOUNTED_TEMP, "w");
if (mftmp == NULL || mftmp->mntent_fp == NULL) {
error("can't open %s (%s) - mtab not updated", MOUNTED_TEMP, strerror(errno));
goto leave;
}
while ((mnt = my_getmntent(mfp))) {
if (streq(mnt->mnt_dir, dir)) {
added++;
if (instead) { /* a remount */
remnt = *instead;
next = &remnt;
remnt.mnt_fsname = mnt->mnt_fsname;
remnt.mnt_type = mnt->mnt_type;
if (instead->mnt_fsname && !streq(mnt->mnt_fsname, instead->mnt_fsname))
printf("mount: warning: cannot change " "mounted device with a remount\n");
else if (instead->mnt_type && !streq(instead->mnt_type, "unknown")
&& !streq(mnt->mnt_type, instead->mnt_type))
printf("mount: warning: cannot change " "filesystem type with a remount\n");
} else
next = NULL;
} else
next = mnt;
if (next && my_addmntent(mftmp, next) == 1)
die(EX_FILEIO, "error writing %s: %s", MOUNTED_TEMP, strerror(errno));
}
if (instead && !added && my_addmntent(mftmp, instead) == 1)
die(EX_FILEIO, "error writing %s: %s", MOUNTED_TEMP, strerror(errno));
my_endmntent(mfp);
if (fchmod(fileno(mftmp->mntent_fp), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0)
fprintf(stderr, "error changing mode of %s: %s\n", MOUNTED_TEMP, strerror(errno));
my_endmntent(mftmp);
if (rename(MOUNTED_TEMP, MOUNTED) < 0)
fprintf(stderr, "can't rename %s to %s: %s\n", MOUNTED_TEMP, MOUNTED, strerror(errno));
leave:
unlock_mtab();
}
watchdog-5.14.orig/src/watchdog.c 0000644 0000000 0000000 00000031010 12420300633 013607 0 ustar /*************************************************************/
/* Original version was an example in the kernel source tree */
/* */
/* Most of the rest was written by me, Michael Meskes */
/* meskes@debian.org */
/* */
/*************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "watch_err.h"
#include "extern.h"
static int no_act = FALSE;
volatile sig_atomic_t _running = 1;
char *filename_buf;
static void usage(char *progname)
{
fprintf(stderr, "%s version %d.%d, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION);
fprintf(stderr, "%s [options]\n", progname);
fprintf(stderr, "options:\n");
fprintf(stderr, " -c | --config-file specify location of config file\n");
fprintf(stderr, " -f | --force don't sanity-check config\n");
fprintf(stderr, " -F | --foreground run in foreground\n");
fprintf(stderr, " -q | --no-action do not reboot or halt\n");
fprintf(stderr, " -b | --softboot soft-boot on error\n");
fprintf(stderr, " -s | --sync sync filesystem\n");
fprintf(stderr, " -v | --verbose verbose messages\n");
exit(1);
}
/* Try to sync */
static int sync_system(int sync_it)
{
if (sync_it) {
sync();
sync();
}
return (0);
}
/* execute repair binary */
static int repair(char *rbinary, int result, char *name, int version)
{
pid_t child_pid;
pid_t r_pid;
char parm[5];
int ret;
/* no binary given, we have to reboot */
if (rbinary == NULL)
return (result);
sprintf(parm, "%d", result);
child_pid = fork();
if (!child_pid) {
/* Don't want the stdin and stdout of our repair program
* to cause trouble.
* So make stdout and stderr go to their respective files */
strcpy(filename_buf, logdir);
strcat(filename_buf, "/repair-bin.stdout");
if (!freopen(filename_buf, "a+", stdout))
exit(errno);
strcpy(filename_buf, logdir);
strcat(filename_buf, "/repair-bin.stderr");
if (!freopen(filename_buf, "a+", stderr))
exit(errno);
/* now start binary */
if (version == 0) {
if (name == NULL)
execl(rbinary, rbinary, parm, NULL);
else
execl(rbinary, rbinary, parm, name, NULL);
} else { /* if (version == 1) */
if (name == NULL)
execl(rbinary, rbinary, "repair", parm, NULL);
else
execl(rbinary, rbinary, "repair", parm, name, NULL);
}
/* execl should only return in case of an error */
/* so we return the reboot code */
return (errno);
} else if (child_pid < 0) { /* fork failed */
int err = errno;
if (errno == EAGAIN) { /* process table full */
log_message(LOG_ERR, "process table is full!");
return (EREBOOT);
} else if (softboot)
return (err);
else
return (ENOERR);
}
if (repair_timeout > 0) {
time_t left = repair_timeout;
do {
sleep(1);
r_pid = waitpid(child_pid, &result, WNOHANG);
if (r_pid)
break;
left--;
} while (left > 0);
} else
r_pid = waitpid(child_pid, &result, 0);
if (r_pid == 0) {
log_message(LOG_ERR, "repair child %d timed out", child_pid);
return (EREBOOT);
} else if (r_pid != child_pid) {
int err = errno;
log_message(LOG_ERR, "child %d does not exist (errno = %d = '%s')", child_pid, err, strerror(err));
if (softboot)
return (err);
}
/* check result */
ret = WEXITSTATUS(result);
if (ret != 0) {
log_message(LOG_ERR, "repair binary %s returned %d", rbinary, ret);
if (ret == ERESET) /* repair script says force hard reset, we give it a try */
sleep(dev_timeout * 4);
/* for all other errors or if we still live, we let shutdown handle it */
return (ret);
}
return (ENOERR);
}
static void wd_action(int result, char *rbinary, char *name, int version)
{
/* if no-action flag set, do nothing */
/* no error, keep on working */
if (result == ENOERR || no_act == TRUE)
return;
/* error that might be repairable */
if (result != EREBOOT)
result = repair(rbinary, result, name, version);
/* if still error, reboot */
if (result != ENOERR)
do_shutdown(result);
}
static void do_check(int res, char *rbinary, char *name)
{
wd_action(res, rbinary, name, 0);
wd_action(keep_alive(), rbinary, NULL, 0);
}
static void do_check2(int res, char *r_specific, char *r_global, char *name)
{
wd_action(res, r_specific, name, 1);
wd_action(keep_alive(), r_global, NULL, 0);
}
static void old_option(int c, char *configfile)
{
fprintf(stderr, "Option -%c is no longer valid, please specify it in %s.\n", c, configfile);
}
int main(int argc, char *const argv[])
{
int c, foreground = FALSE, force = FALSE, sync_it = FALSE;
char *configfile = CONFIG_FILENAME;
struct list *act;
pid_t child_pid;
char *progname;
char *opts = "d:i:n:Ffsvbql:p:t:c:r:m:a:";
struct option long_options[] = {
{"config-file", required_argument, NULL, 'c'},
{"foreground", no_argument, NULL, 'F'},
{"force", no_argument, NULL, 'f'},
{"sync", no_argument, NULL, 's'},
{"no-action", no_argument, NULL, 'q'},
{"verbose", no_argument, NULL, 'v'},
{"softboot", no_argument, NULL, 'b'},
{NULL, 0, NULL, 0}
};
long count = 0L;
progname = basename(argv[0]);
open_logging(progname, MSG_TO_STDERR | MSG_TO_SYSLOG);
/* check the options */
/* there aren't that many any more */
while ((c = getopt_long(argc, argv, opts, long_options, NULL)) != EOF) {
switch (c) {
case 'n':
case 'p':
case 'a':
case 'r':
case 'd':
case 't':
case 'l':
case 'm':
case 'i':
old_option(c, configfile);
usage(progname);
break;
case 'c':
configfile = optarg;
break;
case 'F':
foreground = TRUE;
break;
case 'f':
force = TRUE;
break;
case 's':
sync_it = TRUE;
break;
case 'b':
softboot = TRUE;
break;
case 'q':
no_act = TRUE;
break;
case 'v':
verbose = TRUE;
break;
default:
usage(progname);
}
}
read_config(configfile);
if (tint >= dev_timeout && !force) {
fatal_error(EX_USAGE, "Error:\n"
"This interval length might reboot the system while the process sleeps!\n"
"To force this interval length use the -f option.");
}
if (maxload1 > 0 && maxload1 < MINLOAD && !force) {
fatal_error(EX_USAGE, "Error:\n"
"Using this maximal load average might reboot the system too often!\n"
"To force this load average use the -f option.");
}
/* make sure we get our own log directory */
if (mkdir(logdir, 0750) && errno != EEXIST) {
fatal_error(EX_SYSERR, "Cannot create directory %s (%s)", logdir, strerror(errno));
}
/* set up pinging if in ping mode */
if (target_list != NULL) {
open_netcheck(target_list);
}
/* allocate some memory to store a filename, this is needed later on even
* if the system runs out of memory */
filename_buf = (char *)xcalloc(strlen(logdir) + sizeof("/repair-bin.stdout") + 1, sizeof(char));
#if !defined(DEBUG)
if (!foreground) {
/* Become a daemon process: */
/* make sure we're on the root partition */
if (chdir("/") < 0) {
perror(progname);
exit(1);
}
/* fork to go into the background */
if ((child_pid = fork()) < 0) {
perror(progname);
exit(1);
} else if (child_pid > 0) {
/* fork was okay */
/* wait for child to exit */
if (waitpid(child_pid, NULL, 0) != child_pid) {
perror(progname);
exit(1);
}
/* and exit myself */
exit(0);
}
/* and fork again to make sure we inherit all rights from init */
if ((child_pid = fork()) < 0) {
perror(progname);
exit(1);
} else if (child_pid > 0)
exit(0);
/* now we're free */
/* Okay, we're a daemon */
/* but we're still attached to the tty */
/* create our own session */
setsid();
/* As daemon we don't do any console IO */
close(0);
close(1);
close(2);
open_logging(NULL, MSG_TO_SYSLOG); /* Close terminal output, keep syslog open. */
}
#endif /* !DEBUG */
/* tuck my process id away */
if (write_pid_file(PIDFILE)) {
fatal_error(EX_USAGE, "unable to gain lock via PID file");
}
/* Log the starting message */
log_message(LOG_INFO, "starting daemon (%d.%d):", MAJOR_VERSION, MINOR_VERSION);
log_message(LOG_INFO, "int=%ds realtime=%s sync=%s soft=%s mla=%d mem=%d",
tint, realtime ? "yes" : "no", sync_it ? "yes" : "no", softboot ? "yes" : "no", maxload1, minpages);
if (target_list == NULL)
log_message(LOG_INFO, "ping: no machine to check");
else
for (act = target_list; act != NULL; act = act->next)
log_message(LOG_INFO, "ping: %s", act->name);
if (file_list == NULL)
log_message(LOG_INFO, "file: no file to check");
else
for (act = file_list; act != NULL; act = act->next)
log_message(LOG_INFO, "file: %s:%d", act->name, act->parameter.file.mtime);
if (pidfile_list == NULL)
log_message(LOG_INFO, "pidfile: no server process to check");
else
for (act = pidfile_list; act != NULL; act = act->next)
log_message(LOG_INFO, "pidfile: %s", act->name);
if (iface_list == NULL)
log_message(LOG_INFO, "interface: no interface to check");
else
for (act = iface_list; act != NULL; act = act->next)
log_message(LOG_INFO, "interface: %s", act->name);
if (temp_list == NULL)
log_message(LOG_INFO, "temperature: no sensors to check");
else {
log_message(LOG_INFO, "temperature: maximum = %d", maxtemp);
for (act = temp_list; act != NULL; act = act->next)
log_message(LOG_INFO, "temperature: %s", act->name);
}
log_message(LOG_INFO, "test=%s(%ld) repair=%s(%ld) alive=%s heartbeat=%s to=%s no_act=%s force=%s",
(tbinary == NULL) ? "none" : tbinary, test_timeout,
(rbinary == NULL) ? "none" : rbinary, repair_timeout,
(devname == NULL) ? "none" : devname,
(heartbeat == NULL) ? "none" : heartbeat,
(admin == NULL) ? "none" : admin,
(no_act == TRUE) ? "yes" : "no",
(force == TRUE) ? "yes" : "no");
/* open the device */
if (no_act == FALSE) {
open_watchdog(devname, dev_timeout);
open_tempcheck(temp_list);
}
open_heartbeat();
open_loadcheck();
open_memcheck();
/* set signal term to set our run flag to 0 so that */
/* we make sure watchdog device is closed when receiving SIGTERM */
signal(SIGTERM, sigterm_handler);
lock_our_memory(realtime, schedprio, daemon_pid);
/* main loop: update after seconds */
while (_running) {
wd_action(keep_alive(), rbinary, NULL, 0);
/* sync system if we have to */
do_check(sync_system(sync_it), rbinary, NULL);
/* check file table */
do_check(check_file_table(), rbinary, NULL);
/* check load average */
do_check(check_load(), rbinary, NULL);
/* check free memory */
do_check(check_memory(), rbinary, NULL);
/* check allocatable memory */
do_check(check_allocatable(), rbinary, NULL);
/* check temperature */
for (act = temp_list; act != NULL; act = act->next)
do_check(check_temp(act), rbinary, NULL);
/* in filemode stat file */
for (act = file_list; act != NULL; act = act->next)
do_check(check_file_stat(act), rbinary, act->name);
/* in pidmode kill -0 processes */
for (act = pidfile_list; act != NULL; act = act->next)
do_check(check_pidfile(act), rbinary, act->name);
/* in network mode check the given devices for input */
for (act = iface_list; act != NULL; act = act->next)
do_check(check_iface(act), rbinary, act->name);
/* in ping mode ping the ip address */
for (act = target_list; act != NULL; act = act->next)
do_check(check_net
(act->name, act->parameter.net.sock_fp, act->parameter.net.to,
act->parameter.net.packet, tint, pingcount), rbinary, act->name);
/* in user mode execute the given binary or just test fork() call */
do_check(check_bin(tbinary, test_timeout, 0), rbinary, NULL);
#ifdef TESTBIN_PATH
/* test/repair binaries in the watchdog.d directory */
for (act = tr_bin_list; act != NULL; act = act->next)
/* Use version 1 for testbin-path */
do_check2(check_bin(act->name, test_timeout, 1), act->name, rbinary, NULL);
#endif
/* finally sleep for a full cycle */
/* we have just triggered the device with the last check */
usleep(tint * 1000000);
/* do verbose logging */
if (verbose && logtick && (--ticker == 0)) {
ticker = logtick;
count += logtick;
log_message(LOG_INFO, "still alive after %ld interval(s)", count);
}
}
terminate();
/* not reached */
exit(EXIT_SUCCESS);
}
watchdog-5.14.orig/src/nfsmount.h 0000644 0000000 0000000 00000024273 12076233263 013715 0 ustar /*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _NFSMOUNT_H_RPCGEN
#define _NFSMOUNT_H_RPCGEN
#include
#ifdef __cplusplus
extern "C" {
#endif
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user or with the express written consent of
* Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
/*
* Copyright (c) 1985, 1990 by Sun Microsystems, Inc.
*/
/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */
#ifndef _rpcsvc_mount_h
#define _rpcsvc_mount_h
#include
#define MOUNTPORT 635
#define MNTPATHLEN 1024
#define MNTNAMLEN 255
#define FHSIZE 32
#define FHSIZE3 64
typedef char fhandle[FHSIZE];
typedef struct {
u_int fhandle3_len;
char *fhandle3_val;
} fhandle3;
enum mountstat3 {
MNT_OK = 0,
MNT3ERR_PERM = 1,
MNT3ERR_NOENT = 2,
MNT3ERR_IO = 5,
MNT3ERR_ACCES = 13,
MNT3ERR_NOTDIR = 20,
MNT3ERR_INVAL = 22,
MNT3ERR_NAMETOOLONG = 63,
MNT3ERR_NOTSUPP = 10004,
MNT3ERR_SERVERFAULT = 10006,
};
typedef enum mountstat3 mountstat3;
struct fhstatus {
u_int fhs_status;
union {
fhandle fhs_fhandle;
} fhstatus_u;
};
typedef struct fhstatus fhstatus;
struct mountres3_ok {
fhandle3 fhandle;
struct {
u_int auth_flavours_len;
int *auth_flavours_val;
} auth_flavours;
};
typedef struct mountres3_ok mountres3_ok;
struct mountres3 {
mountstat3 fhs_status;
union {
mountres3_ok mountinfo;
} mountres3_u;
};
typedef struct mountres3 mountres3;
typedef char *dirpath;
typedef char *name;
typedef struct mountbody *mountlist;
struct mountbody {
name ml_hostname;
dirpath ml_directory;
mountlist ml_next;
};
typedef struct mountbody mountbody;
typedef struct groupnode *groups;
struct groupnode {
name gr_name;
groups gr_next;
};
typedef struct groupnode groupnode;
typedef struct exportnode *exports;
struct exportnode {
dirpath ex_dir;
groups ex_groups;
exports ex_next;
};
typedef struct exportnode exportnode;
struct ppathcnf {
int pc_link_max;
short pc_max_canon;
short pc_max_input;
short pc_name_max;
short pc_path_max;
short pc_pipe_buf;
u_char pc_vdisable;
char pc_xxx;
short pc_mask[2];
};
typedef struct ppathcnf ppathcnf;
#endif /*!_rpcsvc_mount_h*/
#define MOUNTPROG 100005
#define MOUNTVERS 1
#if defined(__STDC__) || defined(__cplusplus)
#define MOUNTPROC_NULL 0
extern void * mountproc_null_1(void *, CLIENT *);
extern void * mountproc_null_1_svc(void *, struct svc_req *);
#define MOUNTPROC_MNT 1
extern fhstatus * mountproc_mnt_1(dirpath *, CLIENT *);
extern fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *);
#define MOUNTPROC_DUMP 2
extern mountlist * mountproc_dump_1(void *, CLIENT *);
extern mountlist * mountproc_dump_1_svc(void *, struct svc_req *);
#define MOUNTPROC_UMNT 3
extern void * mountproc_umnt_1(dirpath *, CLIENT *);
extern void * mountproc_umnt_1_svc(dirpath *, struct svc_req *);
#define MOUNTPROC_UMNTALL 4
extern void * mountproc_umntall_1(void *, CLIENT *);
extern void * mountproc_umntall_1_svc(void *, struct svc_req *);
#define MOUNTPROC_EXPORT 5
extern exports * mountproc_export_1(void *, CLIENT *);
extern exports * mountproc_export_1_svc(void *, struct svc_req *);
#define MOUNTPROC_EXPORTALL 6
extern exports * mountproc_exportall_1(void *, CLIENT *);
extern exports * mountproc_exportall_1_svc(void *, struct svc_req *);
extern int mountprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define MOUNTPROC_NULL 0
extern void * mountproc_null_1();
extern void * mountproc_null_1_svc();
#define MOUNTPROC_MNT 1
extern fhstatus * mountproc_mnt_1();
extern fhstatus * mountproc_mnt_1_svc();
#define MOUNTPROC_DUMP 2
extern mountlist * mountproc_dump_1();
extern mountlist * mountproc_dump_1_svc();
#define MOUNTPROC_UMNT 3
extern void * mountproc_umnt_1();
extern void * mountproc_umnt_1_svc();
#define MOUNTPROC_UMNTALL 4
extern void * mountproc_umntall_1();
extern void * mountproc_umntall_1_svc();
#define MOUNTPROC_EXPORT 5
extern exports * mountproc_export_1();
extern exports * mountproc_export_1_svc();
#define MOUNTPROC_EXPORTALL 6
extern exports * mountproc_exportall_1();
extern exports * mountproc_exportall_1_svc();
extern int mountprog_1_freeresult ();
#endif /* K&R C */
#define MOUNTVERS_POSIX 2
#if defined(__STDC__) || defined(__cplusplus)
extern void * mountproc_null_2(void *, CLIENT *);
extern void * mountproc_null_2_svc(void *, struct svc_req *);
extern fhstatus * mountproc_mnt_2(dirpath *, CLIENT *);
extern fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *);
extern mountlist * mountproc_dump_2(void *, CLIENT *);
extern mountlist * mountproc_dump_2_svc(void *, struct svc_req *);
extern void * mountproc_umnt_2(dirpath *, CLIENT *);
extern void * mountproc_umnt_2_svc(dirpath *, struct svc_req *);
extern void * mountproc_umntall_2(void *, CLIENT *);
extern void * mountproc_umntall_2_svc(void *, struct svc_req *);
extern exports * mountproc_export_2(void *, CLIENT *);
extern exports * mountproc_export_2_svc(void *, struct svc_req *);
extern exports * mountproc_exportall_2(void *, CLIENT *);
extern exports * mountproc_exportall_2_svc(void *, struct svc_req *);
#define MOUNTPROC_PATHCONF 7
extern ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *);
extern ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *);
extern int mountprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
extern void * mountproc_null_2();
extern void * mountproc_null_2_svc();
extern fhstatus * mountproc_mnt_2();
extern fhstatus * mountproc_mnt_2_svc();
extern mountlist * mountproc_dump_2();
extern mountlist * mountproc_dump_2_svc();
extern void * mountproc_umnt_2();
extern void * mountproc_umnt_2_svc();
extern void * mountproc_umntall_2();
extern void * mountproc_umntall_2_svc();
extern exports * mountproc_export_2();
extern exports * mountproc_export_2_svc();
extern exports * mountproc_exportall_2();
extern exports * mountproc_exportall_2_svc();
#define MOUNTPROC_PATHCONF 7
extern ppathcnf * mountproc_pathconf_2();
extern ppathcnf * mountproc_pathconf_2_svc();
extern int mountprog_2_freeresult ();
#endif /* K&R C */
#define MOUNT_V3 3
#if defined(__STDC__) || defined(__cplusplus)
#define MOUNTPROC3_NULL 0
extern void * mountproc3_null_3(void *, CLIENT *);
extern void * mountproc3_null_3_svc(void *, struct svc_req *);
#define MOUNTPROC3_MNT 1
extern mountres3 * mountproc3_mnt_3(dirpath *, CLIENT *);
extern mountres3 * mountproc3_mnt_3_svc(dirpath *, struct svc_req *);
#define MOUNTPROC3_DUMP 2
extern mountlist * mountproc3_dump_3(void *, CLIENT *);
extern mountlist * mountproc3_dump_3_svc(void *, struct svc_req *);
#define MOUNTPROC3_UMNT 3
extern void * mountproc3_umnt_3(dirpath *, CLIENT *);
extern void * mountproc3_umnt_3_svc(dirpath *, struct svc_req *);
#define MOUNTPROC3_UMNTALL 4
extern void * mountproc3_umntall_3(void *, CLIENT *);
extern void * mountproc3_umntall_3_svc(void *, struct svc_req *);
#define MOUNTPROC3_EXPORT 5
extern exports * mountproc3_export_3(void *, CLIENT *);
extern exports * mountproc3_export_3_svc(void *, struct svc_req *);
extern int mountprog_3_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define MOUNTPROC3_NULL 0
extern void * mountproc3_null_3();
extern void * mountproc3_null_3_svc();
#define MOUNTPROC3_MNT 1
extern mountres3 * mountproc3_mnt_3();
extern mountres3 * mountproc3_mnt_3_svc();
#define MOUNTPROC3_DUMP 2
extern mountlist * mountproc3_dump_3();
extern mountlist * mountproc3_dump_3_svc();
#define MOUNTPROC3_UMNT 3
extern void * mountproc3_umnt_3();
extern void * mountproc3_umnt_3_svc();
#define MOUNTPROC3_UMNTALL 4
extern void * mountproc3_umntall_3();
extern void * mountproc3_umntall_3_svc();
#define MOUNTPROC3_EXPORT 5
extern exports * mountproc3_export_3();
extern exports * mountproc3_export_3_svc();
extern int mountprog_3_freeresult ();
#endif /* K&R C */
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_fhandle (XDR *, fhandle);
extern bool_t xdr_fhandle3 (XDR *, fhandle3*);
extern bool_t xdr_mountstat3 (XDR *, mountstat3*);
extern bool_t xdr_fhstatus (XDR *, fhstatus*);
extern bool_t xdr_mountres3_ok (XDR *, mountres3_ok*);
extern bool_t xdr_mountres3 (XDR *, mountres3*);
extern bool_t xdr_dirpath (XDR *, dirpath*);
extern bool_t xdr_name (XDR *, name*);
extern bool_t xdr_mountlist (XDR *, mountlist*);
extern bool_t xdr_mountbody (XDR *, mountbody*);
extern bool_t xdr_groups (XDR *, groups*);
extern bool_t xdr_groupnode (XDR *, groupnode*);
extern bool_t xdr_exports (XDR *, exports*);
extern bool_t xdr_exportnode (XDR *, exportnode*);
extern bool_t xdr_ppathcnf (XDR *, ppathcnf*);
#else /* K&R C */
extern bool_t xdr_fhandle ();
extern bool_t xdr_fhandle3 ();
extern bool_t xdr_mountstat3 ();
extern bool_t xdr_fhstatus ();
extern bool_t xdr_mountres3_ok ();
extern bool_t xdr_mountres3 ();
extern bool_t xdr_dirpath ();
extern bool_t xdr_name ();
extern bool_t xdr_mountlist ();
extern bool_t xdr_mountbody ();
extern bool_t xdr_groups ();
extern bool_t xdr_groupnode ();
extern bool_t xdr_exports ();
extern bool_t xdr_exportnode ();
extern bool_t xdr_ppathcnf ();
#endif /* K&R C */
#ifdef __cplusplus
}
#endif
#endif /* !_NFSMOUNT_H_RPCGEN */
watchdog-5.14.orig/src/iface.c 0000644 0000000 0000000 00000003214 12233767421 013101 0 ustar #ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include "extern.h"
#include "watch_err.h"
#define NETDEV_LINE_LEN 128
int check_iface(struct list *dev)
{
FILE *file = fopen("/proc/net/dev", "r");
if (file == NULL) {
int err = errno;
log_message(LOG_ERR, "cannot open /proc/net/dev (errno = %d = '%s')", err, strerror(err));
if (softboot)
return (err);
return (ENOERR);
}
/* read the file line by line */
while (!feof(file)) {
char line[NETDEV_LINE_LEN];
if (fgets(line, NETDEV_LINE_LEN, file) == NULL) {
if (!ferror(file))
break;
else {
int err = errno;
log_message(LOG_ERR, "cannot read /proc/net/dev (errno = %d = '%s')", err, strerror(err));
fclose(file);
if (softboot)
return (err);
return (ENOERR);
}
} else {
int i = 0;
for (; line[i] == ' ' || line[i] == '\t'; i++) ;
if (strncmp(line + i, dev->name, strlen(dev->name)) == 0) {
unsigned long bytes = strtoul(line + i + strlen(dev->name) + 1, NULL, 10);
/* do verbose logging */
if (verbose && logtick && ticker == 1)
log_message(LOG_INFO, "device %s received %lu bytes", dev->name, bytes);
if (dev->parameter.iface.bytes == bytes) {
fclose(file);
log_message(LOG_ERR, "device %s did not receive anything since last check", dev->name);
return (ENETUNREACH);
} else
dev->parameter.iface.bytes = bytes;
}
}
}
if (fclose(file) != 0) {
int err = errno;
log_message(LOG_ERR, "cannot close /proc/net/dev (errno = %d = '%s')", err, strerror(err));
if (softboot)
return (err);
return (ENOERR);
}
return (ENOERR);
}
watchdog-5.14.orig/src/net.c 0000644 0000000 0000000 00000013251 12326763500 012617 0 ustar /* > net.c
*
* Code for checking network access. The open_netcheck() funcion is from set-up
* code originally in watchdog.c
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include /* for gethostname() etc */
#include /* for gethostbyname() */
#include /* for MAXHOSTNAMELEN */
#include
#include
#include
#include "extern.h"
#include "watch_err.h"
/*
* in_cksum --
* Checksum routine for Internet Protocol family headers (C Version)
*/
static int in_cksum(unsigned short *addr, int len)
{
int nleft = len, sum = 0;
unsigned short *w = addr, answer = 0;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
} /* mop up an odd byte, if necessary */
if (nleft == 1) {
sum += htons(*(u_char *) w << 8);
}
/* add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return (answer);
}
int check_net(char *target, int sock_fp, struct sockaddr to, unsigned char *packet, int time, int count)
{
int i;
unsigned char outpack[MAXPACKET];
if (target == NULL)
return (ENOERR);
/* try "ping-count" times */
for (i = 0; i < count; i++) {
struct sockaddr_in from;
int fdmask, j;
socklen_t fromlen;
struct timeval timeout, dtimeout;
struct icmphdr *icp = (struct icmphdr *)outpack;
/* setup a ping message */
icp->type = ICMP_ECHO;
icp->code = icp->checksum = 0;
icp->un.echo.sequence = htons(i + 1);
icp->un.echo.id = daemon_pid; /* ID */
/* compute ICMP checksum here */
icp->checksum = in_cksum((unsigned short *)icp, DATALEN + 8);
/* and send it out */
j = sendto(sock_fp, (char *)outpack, DATALEN + 8, 0, &to, sizeof(struct sockaddr));
if (j < 0) {
int err = errno;
/* if our kernel tells us the network is unreachable we are done */
if (err == ENETUNREACH) {
log_message(LOG_ERR, "network is unreachable (target: %s)", target);
return (ENETUNREACH);
} else {
log_message(LOG_ERR, "sendto gave errno = %d = '%s'", err, strerror(err));
if (softboot)
return (err);
}
} else {
gettimeofday(&timeout, NULL);
/* set the timeout value */
j = time / count;
/* we have to wait at least one second */
if (j == 0)
j = 1;
timeout.tv_sec += j;
/* wait for reply */
fdmask = 1 << sock_fp;
while (1) {
gettimeofday(&dtimeout, NULL);
dtimeout.tv_sec = timeout.tv_sec - dtimeout.tv_sec;
dtimeout.tv_usec = timeout.tv_usec - dtimeout.tv_usec;
if (dtimeout.tv_usec < 0) {
dtimeout.tv_usec += 1000000;
dtimeout.tv_sec--;
}
/* Is this loop really needed? I have yet to see a usec value >= 1000000. */
while (dtimeout.tv_usec >= 1000000) {
dtimeout.tv_usec -= 1000000;
dtimeout.tv_sec++;
}
if (dtimeout.tv_sec < 0)
break;
if (verbose && logtick && ticker == 1)
log_message(LOG_ERR, "ping select timeout = %2ld.%06ld seconds",
dtimeout.tv_sec, dtimeout.tv_usec);
if (select
(sock_fp + 1, (fd_set *) & fdmask, (fd_set *) NULL, (fd_set *) NULL,
&dtimeout) >= 1) {
/* read reply */
fromlen = sizeof(from);
if (recvfrom
(sock_fp, (char *)packet, DATALEN + MAXIPLEN + MAXICMPLEN, 0,
(struct sockaddr *)&from, &fromlen) < 0) {
int err = errno;
if (err != EINTR)
log_message(LOG_ERR, "recvfrom gave errno = %d = '%s'", err, strerror(err));
if (softboot)
return (err);
continue;
}
/* check if packet is our ECHO */
icp = (struct icmphdr *)(packet + (((struct ip *)packet)->ip_hl << 2));
if (icp->type == ICMP_ECHOREPLY && icp->un.echo.id == daemon_pid) {
if (from.sin_addr.s_addr ==
((struct sockaddr_in *)&to)->sin_addr.s_addr) {
if (verbose && logtick && ticker == 1)
log_message(LOG_INFO, "got answer from target %s", target);
return (ENOERR);
}
}
}
}
}
}
log_message(LOG_ERR, "no response from ping (target: %s)", target);
return (ENETUNREACH);
}
/*
* Set up pinging if in ping mode
*/
int open_netcheck(struct list *tlist)
{
struct list *act;
int hold = 0;
if (tlist != NULL) {
for (act = tlist; act != NULL; act = act->next) {
struct protoent *proto;
struct pingmode *net = &act->parameter.net; /* 'net' is alias of act->parameter.net */
/* setup the socket */
memset(&(net->to), 0, sizeof(struct sockaddr));
((struct sockaddr_in *)&(net->to))->sin_family = AF_INET;
if ((((struct sockaddr_in *)&(net->to))->sin_addr.s_addr =
inet_addr(act->name)) == (unsigned int)-1) {
fatal_error(EX_USAGE, "unknown host %s", act->name);
}
net->packet = (unsigned char *)xcalloc((unsigned int)(DATALEN + MAXIPLEN + MAXICMPLEN), sizeof(char));
if (!(proto = getprotobyname("icmp"))) {
fatal_error(EX_SYSERR, "unknown protocol icmp.");
}
if ((net->sock_fp = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0
|| fcntl(net->sock_fp, F_SETFD, 1)) {
fatal_error(EX_SYSERR, "error opening socket (%s)", strerror(errno));
}
/* this is necessary for broadcast pings to work */
(void)setsockopt(net->sock_fp, SOL_SOCKET, SO_BROADCAST, (char *)&hold, sizeof(hold));
hold = 48 * 1024;
(void)setsockopt(net->sock_fp, SOL_SOCKET, SO_RCVBUF, (char *)&hold, sizeof(hold));
}
}
return 0;
}
watchdog-5.14.orig/src/nfsmount.c 0000644 0000000 0000000 00000051777 12233767421 013724 0 ustar /* $Header: /cvsroot/watchdog/watchdog/src/nfsmount.c,v 1.2 2006/07/31 09:39:23 meskes Exp $ */
/*
* nfsmount.c -- Linux NFS mount
* Copyright (C) 1993 Rick Sladkey
*
* 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.
*
* Wed Feb 8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port
* numbers to be specified on the command line.
*
* Fri, 8 Mar 1996 18:01:39, Swen Thuemmler :
* Omit the call to connect() for Linux version 1.3.11 or later.
*
* Wed Oct 1 23:55:28 1997: Dick Streefland
* Implemented the "bg", "fg" and "retry" mount options for NFS.
*
* 1999-02-22 Arkadiusz Miķkiewicz
* - added Native Language Support
*
* Modified by Olaf Kirch and Trond Myklebust for new NFS code,
* plus NFSv3 stuff.
*/
/*
* nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
*/
#include "config.h"
#if HAVE_NFS
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "sundries.h"
#include "nfsmount.h"
#include
#include "mount_constants.h"
#include "nfs_mount4.h"
#define HAVE_inet_aton
#ifndef NFS_PORT
#define NFS_PORT 2049
#endif
#ifndef NFS_FHSIZE
#define NFS_FHSIZE 32
#endif
static char *nfs_strerror(int stat);
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
static int linux_version_code(void)
{
struct utsname my_utsname;
int p, q, r;
if (uname(&my_utsname) == 0) {
p = atoi(strtok(my_utsname.release, "."));
q = atoi(strtok(NULL, "."));
r = atoi(strtok(NULL, "."));
return MAKE_VERSION(p, q, r);
}
return 0;
}
/*
* nfs_mount_version according to the sources seen at compile time.
*/
int nfs_mount_version = NFS_MOUNT_VERSION;
/*
* Unfortunately, the kernel prints annoying console messages
* in case of an unexpected nfs mount version (instead of
* just returning some error). Therefore we'll have to try
* and figure out what version the kernel expects.
*
* Variables:
* NFS_MOUNT_VERSION: these nfsmount sources at compile time
* nfs_mount_version: version this source and running kernel can handle
*/
static void find_kernel_nfs_mount_version(void)
{
static int kernel_version = 0;
if (kernel_version)
return;
kernel_version = linux_version_code();
if (kernel_version) {
if (kernel_version < MAKE_VERSION(2, 1, 32))
nfs_mount_version = 1;
else if (kernel_version < MAKE_VERSION(2, 2, 18))
nfs_mount_version = 3;
else if (kernel_version < MAKE_VERSION(2, 3, 0))
nfs_mount_version = 4; /* since 2.2.18pre9 */
else if (kernel_version < MAKE_VERSION(2, 3, 99))
nfs_mount_version = 3;
else
nfs_mount_version = 4; /* since 2.3.99pre4 */
}
if (nfs_mount_version > NFS_MOUNT_VERSION)
nfs_mount_version = NFS_MOUNT_VERSION;
}
static struct pmap *get_mountport(struct sockaddr_in *server_addr,
long unsigned prog, long unsigned version, long unsigned proto, long unsigned port)
{
struct pmaplist *pmap;
static struct pmap p = { 0, 0, 0, 0 };
server_addr->sin_port = PMAPPORT;
pmap = pmap_getmaps(server_addr);
if (version > MAX_NFSPROT)
version = MAX_NFSPROT;
if (!prog)
prog = MOUNTPROG;
p.pm_prog = prog;
p.pm_vers = version;
p.pm_prot = proto;
p.pm_port = port;
while (pmap) {
if (pmap->pml_map.pm_prog != prog)
goto next;
if (!version && p.pm_vers > pmap->pml_map.pm_vers)
goto next;
if (version > 2 && pmap->pml_map.pm_vers != version)
goto next;
if (version && version <= 2 && pmap->pml_map.pm_vers > 2)
goto next;
if (pmap->pml_map.pm_vers > MAX_NFSPROT ||
(proto && p.pm_prot && pmap->pml_map.pm_prot != proto) || (port && pmap->pml_map.pm_port != port))
goto next;
memcpy(&p, &pmap->pml_map, sizeof(p));
next:
pmap = pmap->pml_next;
}
if (!p.pm_vers)
p.pm_vers = MOUNTVERS;
if (!p.pm_port)
p.pm_port = MOUNTPORT;
if (!p.pm_prot)
p.pm_prot = IPPROTO_TCP;
return &p;
}
int nfsmount(const char *spec, const char *node, int *flags, char **extra_opts, char **mount_opts, int running_bg)
{
static char *prev_bg_host;
char hostdir[1024];
CLIENT *mclient;
char *hostname;
char *dirname;
char *old_opts;
char *mounthost = NULL;
char new_opts[1024];
struct timeval total_timeout;
enum clnt_stat clnt_stat;
static struct nfs_mount_data data;
char *opt, *opteq;
int val;
struct hostent *hp;
struct sockaddr_in server_addr;
struct sockaddr_in mount_server_addr;
struct pmap *pm_mnt;
int msock, fsock;
struct timeval retry_timeout;
union {
struct fhstatus nfsv2;
struct mountres3 nfsv3;
} status;
struct stat statbuf;
char *s;
int port;
int mountport;
int proto;
int bg;
int soft;
int intr;
int posix;
int nocto;
int noac;
int nolock;
int broken_suid;
int retry;
int tcp;
int mountprog;
int mountvers;
int nfsprog;
int nfsvers;
int retval;
time_t t;
time_t prevt;
time_t timeout;
find_kernel_nfs_mount_version();
retval = EX_FAIL;
msock = fsock = -1;
mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) {
fprintf(stderr, "mount: " "excessively long host:dir argument\n");
goto fail;
}
strcpy(hostdir, spec);
if ((s = strchr(hostdir, ':'))) {
hostname = hostdir;
dirname = s + 1;
*s = '\0';
/* Ignore all but first hostname in replicated mounts
until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) {
*s = '\0';
fprintf(stderr, "mount: warning: " "multiple hostnames not supported\n");
}
} else {
fprintf(stderr, "mount: " "directory to mount not in host:dir format\n");
goto fail;
}
server_addr.sin_family = AF_INET;
#ifdef HAVE_inet_aton
if (!inet_aton(hostname, &server_addr.sin_addr))
#endif
{
if ((hp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, "mount: can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, "mount: got bad hp->h_length\n");
hp->h_length = sizeof(struct in_addr);
}
memcpy(&server_addr.sin_addr, hp->h_addr, hp->h_length);
}
}
memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr));
/* add IP address to mtab options for use when unmounting */
s = inet_ntoa(server_addr.sin_addr);
old_opts = *extra_opts;
if (!old_opts)
old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
fprintf(stderr, "mount: " "excessively long option argument\n");
goto fail;
}
sprintf(new_opts, "%s%saddr=%s", old_opts, *old_opts ? "," : "", s);
*extra_opts = xstrdup(new_opts);
/* Set default options.
* rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
* let the kernel decide.
* timeo is filled in after we know whether it'll be TCP or UDP. */
memset(&data, 0, sizeof(data));
data.retrans = 3;
data.acregmin = 3;
data.acregmax = 60;
data.acdirmin = 30;
data.acdirmax = 60;
#if NFS_MOUNT_VERSION >= 2
data.namlen = NAME_MAX;
#endif
bg = 0;
soft = 0;
intr = 0;
posix = 0;
nocto = 0;
nolock = 0;
broken_suid = 0;
noac = 0;
retry = 10000; /* 10000 minutes ~ 1 week */
tcp = 0;
mountprog = MOUNTPROG;
mountvers = 0;
port = 0;
mountport = 0;
nfsprog = NFS_PROGRAM;
nfsvers = 0;
/* parse options */
for (opt = strtok(old_opts, ","); opt; opt = strtok(NULL, ",")) {
if ((opteq = strchr(opt, '='))) {
val = atoi(opteq + 1);
*opteq = '\0';
if (!strcmp(opt, "rsize"))
data.rsize = val;
else if (!strcmp(opt, "wsize"))
data.wsize = val;
else if (!strcmp(opt, "timeo"))
data.timeo = val;
else if (!strcmp(opt, "retrans"))
data.retrans = val;
else if (!strcmp(opt, "acregmin"))
data.acregmin = val;
else if (!strcmp(opt, "acregmax"))
data.acregmax = val;
else if (!strcmp(opt, "acdirmin"))
data.acdirmin = val;
else if (!strcmp(opt, "acdirmax"))
data.acdirmax = val;
else if (!strcmp(opt, "actimeo")) {
data.acregmin = val;
data.acregmax = val;
data.acdirmin = val;
data.acdirmax = val;
} else if (!strcmp(opt, "retry"))
retry = val;
else if (!strcmp(opt, "port"))
port = val;
else if (!strcmp(opt, "mountport"))
mountport = val;
else if (!strcmp(opt, "mounthost"))
mounthost = xstrndup(opteq + 1, strcspn(opteq + 1, " \t\n\r,"));
else if (!strcmp(opt, "mountprog"))
mountprog = val;
else if (!strcmp(opt, "mountvers"))
mountvers = val;
else if (!strcmp(opt, "nfsprog"))
nfsprog = val;
else if (!strcmp(opt, "nfsvers") || !strcmp(opt, "vers"))
nfsvers = val;
else if (!strcmp(opt, "proto")) {
if (!strncmp(opteq + 1, "tcp", 3))
tcp = 1;
else if (!strncmp(opteq + 1, "udp", 3))
tcp = 0;
else
printf("Warning: Unrecognized proto= option.\n");
} else if (!strcmp(opt, "namlen")) {
#if NFS_MOUNT_VERSION >= 2
if (nfs_mount_version >= 2)
data.namlen = val;
else
#endif
printf("Warning: Option namlen is not supported.\n");
} else if (!strcmp(opt, "addr"))
/* ignore */ ;
else {
printf("unknown nfs mount parameter: " "%s=%d\n", opt, val);
goto fail;
}
} else {
val = 1;
if (!strncmp(opt, "no", 2)) {
val = 0;
opt += 2;
}
if (!strcmp(opt, "bg"))
bg = val;
else if (!strcmp(opt, "fg"))
bg = !val;
else if (!strcmp(opt, "soft"))
soft = val;
else if (!strcmp(opt, "hard"))
soft = !val;
else if (!strcmp(opt, "intr"))
intr = val;
else if (!strcmp(opt, "posix"))
posix = val;
else if (!strcmp(opt, "cto"))
nocto = !val;
else if (!strcmp(opt, "ac"))
noac = !val;
else if (!strcmp(opt, "tcp"))
tcp = val;
else if (!strcmp(opt, "udp"))
tcp = !val;
else if (!strcmp(opt, "lock")) {
if (nfs_mount_version >= 3)
nolock = !val;
else
printf("Warning: option nolock is not supported.\n");
} else if (!strcmp(opt, "broken_suid")) {
broken_suid = val;
} else {
if (!sloppy) {
printf("unknown nfs mount option: " "%s%s\n", val ? "" : "no", opt);
goto fail;
}
}
}
}
proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP;
data.flags = (soft ? NFS_MOUNT_SOFT : 0)
| (intr ? NFS_MOUNT_INTR : 0)
| (posix ? NFS_MOUNT_POSIX : 0)
| (nocto ? NFS_MOUNT_NOCTO : 0)
| (noac ? NFS_MOUNT_NOAC : 0);
#if NFS_MOUNT_VERSION >= 2
if (nfs_mount_version >= 2)
data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
#endif
#if NFS_MOUNT_VERSION >= 3
if (nfs_mount_version >= 3)
data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif
#if NFS_MOUNT_VERSION >= 4
if (nfs_mount_version >= 4)
data.flags |= (broken_suid ? NFS_MOUNT_BROKEN_SUID : 0);
#endif
if (nfsvers > MAX_NFSPROT) {
fprintf(stderr, "NFSv%d not supported!\n", nfsvers);
return 0;
}
if (mountvers > MAX_NFSPROT) {
fprintf(stderr, "NFSv%d not supported!\n", nfsvers);
return 0;
}
if (nfsvers && !mountvers)
mountvers = (nfsvers < 3) ? 1 : nfsvers;
if (nfsvers && nfsvers < mountvers) {
mountvers = nfsvers;
}
/* Adjust options if none specified */
if (!data.timeo)
data.timeo = tcp ? 70 : 7;
#ifdef NFS_MOUNT_DEBUG
printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n", data.rsize, data.wsize, data.timeo, data.retrans);
printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
printf("port = %d, bg = %d, retry = %d, flags = %.8x\n", port, bg, retry, data.flags);
printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n", mountprog, mountvers, nfsprog, nfsvers);
printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d\n",
(data.flags & NFS_MOUNT_SOFT) != 0,
(data.flags & NFS_MOUNT_INTR) != 0,
(data.flags & NFS_MOUNT_POSIX) != 0,
(data.flags & NFS_MOUNT_NOCTO) != 0, (data.flags & NFS_MOUNT_NOAC) != 0);
#if NFS_MOUNT_VERSION >= 2
printf("tcp = %d\n", (data.flags & NFS_MOUNT_TCP) != 0);
#endif
#endif
data.version = nfs_mount_version;
*mount_opts = (char *)&data;
if (*flags & MS_REMOUNT)
return 0;
/*
* If the previous mount operation on the same host was
* backgrounded, and the "bg" for this mount is also set,
* give up immediately, to avoid the initial timeout.
*/
if (bg && !running_bg && prev_bg_host && strcmp(hostname, prev_bg_host) == 0) {
if (retry > 0)
retval = EX_BG;
return retval;
}
/* create mount deamon client */
/* See if the nfs host = mount host. */
if (mounthost) {
if (mounthost[0] >= '0' && mounthost[0] <= '9') {
mount_server_addr.sin_family = AF_INET;
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else {
if ((hp = gethostbyname(mounthost)) == NULL) {
fprintf(stderr, "mount: can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, "mount: got bad hp->h_length?\n");
hp->h_length = sizeof(struct in_addr);
}
mount_server_addr.sin_family = AF_INET;
memcpy(&mount_server_addr.sin_addr, hp->h_addr, hp->h_length);
}
}
}
/*
* The following loop implements the mount retries. On the first
* call, "running_bg" is 0. When the mount times out, and the
* "bg" option is set, the exit status EX_BG will be returned.
* For a backgrounded mount, there will be a second call by the
* child process with "running_bg" set to 1.
*
* The case where the mount point is not present and the "bg"
* option is set, is treated as a timeout. This is done to
* support nested mounts.
*
* The "retry" count specified by the user is the number of
* minutes to retry before giving up.
*
* Only the first error message will be displayed.
*/
retry_timeout.tv_sec = 3;
retry_timeout.tv_usec = 0;
total_timeout.tv_sec = 20;
total_timeout.tv_usec = 0;
timeout = time(NULL) + 60 * retry;
prevt = 0;
t = 30;
val = 1;
for (;;) {
if (bg && stat(node, &statbuf) == -1) {
/* no mount point yet - sleep */
if (running_bg) {
sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
val *= 2;
if (val > 30)
val = 30;
}
} else {
/* be careful not to use too many CPU cycles */
if (t - prevt < 30)
sleep(30);
pm_mnt = get_mountport(&mount_server_addr, mountprog, mountvers, proto, mountport);
/* contact the mount daemon via TCP */
mount_server_addr.sin_port = htons(pm_mnt->pm_port);
msock = RPC_ANYSOCK;
switch (pm_mnt->pm_prot) {
case IPPROTO_UDP:
mclient = clntudp_create(&mount_server_addr,
pm_mnt->pm_prog, pm_mnt->pm_vers, retry_timeout, &msock);
if (mclient)
break;
mount_server_addr.sin_port = htons(pm_mnt->pm_port);
msock = RPC_ANYSOCK;
case IPPROTO_TCP:
mclient = clnttcp_create(&mount_server_addr,
pm_mnt->pm_prog, pm_mnt->pm_vers, &msock, 0, 0);
break;
default:
mclient = 0;
}
if (mclient) {
/* try to mount hostname:dirname */
mclient->cl_auth = authunix_create_default();
/* make pointers in xdr_mountres3 NULL so
* that xdr_array allocates memory for us
*/
memset(&status, 0, sizeof(status));
if (pm_mnt->pm_vers == 3)
clnt_stat = clnt_call(mclient,
MOUNTPROC3_MNT,
(xdrproc_t) xdr_dirpath,
(caddr_t) & dirname,
(xdrproc_t) xdr_mountres3,
(caddr_t) & status, total_timeout);
else
clnt_stat = clnt_call(mclient,
MOUNTPROC_MNT,
(xdrproc_t) xdr_dirpath,
(caddr_t) & dirname,
(xdrproc_t) xdr_fhstatus,
(caddr_t) & status, total_timeout);
if (clnt_stat == RPC_SUCCESS)
break; /* we're done */
#if 0
/* errno? who sets errno? */
/* this fragment breaks bg mounting */
if (errno != ECONNREFUSED) {
clnt_perror(mclient, "mount");
goto fail; /* don't retry */
}
#endif
if (!running_bg && prevt == 0)
clnt_perror(mclient, "mount");
auth_destroy(mclient->cl_auth);
clnt_destroy(mclient);
mclient = 0;
close(msock);
} else {
if (!running_bg && prevt == 0)
clnt_pcreateerror("mount");
}
prevt = t;
}
if (!bg)
goto fail;
if (!running_bg) {
prev_bg_host = xstrdup(hostname);
if (retry > 0)
retval = EX_BG;
goto fail;
}
t = time(NULL);
if (t >= timeout)
goto fail;
}
nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers;
if (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) {
fprintf(stderr,
"mount: %s:%s failed, reason given by server: %s\n",
hostname, dirname, nfs_strerror(status.nfsv2.fhs_status));
goto fail;
}
memcpy(data.root.data, (char *)status.nfsv2.fhstatus_u.fhs_fhandle, NFS_FHSIZE);
#if NFS_MOUNT_VERSION >= 4
data.root.size = NFS_FHSIZE;
memcpy(data.old_root.data, (char *)status.nfsv2.fhstatus_u.fhs_fhandle, NFS_FHSIZE);
#endif
} else {
#if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) {
fprintf(stderr,
"mount: %s:%s failed, reason given by server: %s\n",
hostname, dirname, nfs_strerror(status.nfsv3.fhs_status));
goto fail;
}
fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle;
memset(data.old_root.data, 0, NFS_FHSIZE);
memset(&data.root, 0, sizeof(data.root));
data.root.size = fhandle->fhandle3_len;
memcpy(data.root.data, (char *)fhandle->fhandle3_val, fhandle->fhandle3_len);
data.flags |= NFS_MOUNT_VER3;
#endif
}
/* create nfs socket for kernel */
if (tcp) {
if (nfs_mount_version < 3) {
printf("NFS over TCP is not supported.\n");
goto fail;
}
fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
} else
fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fsock < 0) {
perror("nfs socket");
goto fail;
}
if (bindresvport(fsock, 0) < 0) {
perror("nfs bindresvport");
goto fail;
}
if (port == 0) {
server_addr.sin_port = PMAPPORT;
port = pmap_getport(&server_addr, nfsprog, nfsvers, tcp ? IPPROTO_TCP : IPPROTO_UDP);
if (port == 0)
port = NFS_PORT;
#ifdef NFS_MOUNT_DEBUG
else
printf("used portmapper to find NFS port\n");
#endif
}
#ifdef NFS_MOUNT_DEBUG
printf("using port %d for nfs deamon\n", port);
#endif
server_addr.sin_port = htons(port);
/*
* connect() the socket for kernels 1.3.10 and below only,
* to avoid problems with multihomed hosts.
* --Swen
*/
if (linux_version_code() <= 66314 && connect(fsock, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
perror("nfs connect");
goto fail;
}
/* prepare data structure for kernel */
data.fd = fsock;
memcpy((char *)&data.addr, (char *)&server_addr, sizeof(data.addr));
strncpy(data.hostname, hostname, sizeof(data.hostname));
/* clean up */
auth_destroy(mclient->cl_auth);
clnt_destroy(mclient);
close(msock);
return 0;
/* abort */
fail:
if (msock != -1) {
if (mclient) {
auth_destroy(mclient->cl_auth);
clnt_destroy(mclient);
}
close(msock);
}
if (fsock != -1)
close(fsock);
return retval;
}
/*
* We need to translate between nfs status return values and
* the local errno values which may not be the same.
*
* Andreas Schwab : change errno:
* "after #include the symbol errno is reserved for any use,
* it cannot even be used as a struct tag or field name".
*/
#ifndef EDQUOT
#define EDQUOT ENOSPC
#endif
static struct {
enum nfs_stat stat;
int errnum;
} nfs_errtbl[] = {
{
NFS_OK, 0}, {
NFSERR_PERM, EPERM}, {
NFSERR_NOENT, ENOENT}, {
NFSERR_IO, EIO}, {
NFSERR_NXIO, ENXIO}, {
NFSERR_ACCES, EACCES}, {
NFSERR_EXIST, EEXIST}, {
NFSERR_NODEV, ENODEV}, {
NFSERR_NOTDIR, ENOTDIR}, {
NFSERR_ISDIR, EISDIR},
#ifdef NFSERR_INVAL
{
NFSERR_INVAL, EINVAL}, /* that Sun forgot */
#endif
{
NFSERR_FBIG, EFBIG}, {
NFSERR_NOSPC, ENOSPC}, {
NFSERR_ROFS, EROFS}, {
NFSERR_NAMETOOLONG, ENAMETOOLONG}, {
NFSERR_NOTEMPTY, ENOTEMPTY}, {
NFSERR_DQUOT, EDQUOT}, {
NFSERR_STALE, ESTALE},
#ifdef EWFLUSH
{
NFSERR_WFLUSH, EWFLUSH},
#endif
/* Throw in some NFSv3 values for even more fun (HP returns these) */
{
71, EREMOTE}, {
-1, EIO}
};
static char *nfs_strerror(int stat)
{
int i;
static char buf[256];
for (i = 0; nfs_errtbl[i].stat != -1; i++) {
if (nfs_errtbl[i].stat == stat)
return strerror(nfs_errtbl[i].errnum);
}
sprintf(buf, "unknown nfs status return value: %d", stat);
return buf;
}
#if 0
int my_getport(struct in_addr server, struct timeval *timeo, ...)
{
struct sockaddr_in sin;
struct pmap pmap;
CLIENT *clnt;
int sock = RPC_ANYSOCK, port;
pmap.pm_prog = prog;
pmap.pm_vers = vers;
pmap.pm_prot = prot;
pmap.pm_port = 0;
sin.sin_family = AF_INET;
sin.sin_addr = server;
sin.sin_port = htons(111);
clnt = clntudp_create(&sin, 100000, 2, *timeo, &sock);
status = clnt_call(clnt, PMAP_GETPORT, &pmap, (xdrproc_t) xdr_pmap, &port, (xdrproc_t) xdr_uint);
if (status != SUCCESS) {
/* natter */
port = 0;
}
clnt_destroy(clnt);
close(sock);
return port;
}
#endif
#endif
watchdog-5.14.orig/src/memory.c 0000644 0000000 0000000 00000006074 12420273575 013351 0 ustar /* > memory.c
*
* Code for periodically checking the 'free' memory in the system. Added in the
* functions open_memcheck() and close_memcheck() based on stuff from old watchdog.c
* and shutdown.c to make it more self-contained.
*
* TO DO:
* Should we have separate configuration for checking swap use?
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include "extern.h"
#include "watch_err.h"
#define FREEMEM "MemFree:"
#define FREESWAP "SwapFree:"
static int mem_fd = -1;
static const char mem_name[] = "/proc/meminfo";
/*
* Open the memory information file if such as test is configured.
*/
int open_memcheck(void)
{
int rv = -1;
if (minpages > 0) {
/* open the memory info file */
mem_fd = open(mem_name, O_RDONLY);
if (mem_fd == -1) {
int err = errno;
log_message(LOG_ERR, "cannot open %s (errno = %d = '%s')", mem_name, err, strerror(err));
} else {
rv = 0;
}
}
return rv;
}
/*
* Read and check the contents of the memory information file.
*/
int check_memory(void)
{
char buf[1024], *ptr1, *ptr2;
unsigned int free;
/* is the memory file open? */
if (mem_fd == -1)
return (ENOERR);
/* position pointer at start of file */
if (lseek(mem_fd, 0, SEEK_SET) < 0) {
int err = errno;
log_message(LOG_ERR, "lseek %s gave errno = %d = '%s'", mem_name, err, strerror(err));
if (softboot)
return (err);
return (ENOERR);
}
/* read the file */
if (read(mem_fd, buf, sizeof(buf)) < 0) {
int err = errno;
log_message(LOG_ERR, "read %s gave errno = %d = '%s'", mem_name, err, strerror(err));
if (softboot)
return (err);
return (ENOERR);
}
ptr1 = strstr(buf, FREEMEM);
ptr2 = strstr(buf, FREESWAP);
if (!ptr1 || !ptr2) {
log_message(LOG_ERR, "%s contains invalid data (read = %s)", mem_name, buf);
if (softboot)
return (EINVMEM);
return (ENOERR);
}
/* we only care about integer values */
free = atoi(ptr1 + strlen(FREEMEM)) + atoi(ptr2 + strlen(FREESWAP));
if (verbose && logtick && ticker == 1)
log_message(LOG_INFO, "currently there are %d kB of free memory available", free);
if (free < minpages * (EXEC_PAGESIZE / 1024)) {
log_message(LOG_ERR, "memory %d kB is less than %d pages", free, minpages);
return (ENOMEM);
}
return (ENOERR);
}
/*
* Close the special memor data file (if open).
*/
int close_memcheck(void)
{
int rv = -1;
if (mem_fd != -1 && close(mem_fd) == -1) {
log_message(LOG_ALERT, "cannot close %s (errno = %d)", mem_name, errno);
}
mem_fd = -1;
return rv;
}
int check_allocatable(void)
{
int i;
char *mem;
if (minalloc <= 0)
return 0;
/*
* Map and fault in the pages
*/
mem = mmap(NULL, EXEC_PAGESIZE * minalloc, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, 0, 0);
if (mem == MAP_FAILED) {
i = errno;
log_message(LOG_ALERT, "cannot allocate %d bytes (errno = %d)",
EXEC_PAGESIZE * minalloc, i);
return i;
}
munmap(mem, EXEC_PAGESIZE * minalloc);
return 0;
}
watchdog-5.14.orig/src/heartbeat.c 0000644 0000000 0000000 00000006675 12233767421 014007 0 ustar /* > heartbeat.c
*
* Groups together the code for the special heart-beat timestamps file
* used for debug.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include "watch_err.h"
#include "extern.h"
static FILE *hb = NULL;
static int lastts, nrts;
static char *timestamps = NULL;
static void next_value(void)
{
if (nrts < hbstamps)
nrts++;
++lastts;
lastts = lastts % hbstamps;
}
/*
* Open the heartbeat file based on the global variable 'heartbeat' and allocate enough
* memory for a buffer based on the global variable 'hbstamps'.
*/
int open_heartbeat(void)
{
int rv = 0;
if (heartbeat != NULL) {
hb = ((hb = fopen(heartbeat, "r+")) == NULL) ? fopen(heartbeat, "w+") : hb;
if (hb == NULL) {
log_message(LOG_ERR, "cannot open %s (errno = %d = '%s')", heartbeat, errno, strerror(errno));
rv = -1;
} else {
char rbuf[TS_SIZE + 1];
/* Allocate memory for keeping the timestamps in */
nrts = 0;
lastts = 0;
timestamps = (char *)xcalloc(hbstamps, TS_SIZE);
/* read any previous timestamps */
rewind(hb);
while (fgets(rbuf, TS_SIZE + 1, hb) != NULL) {
memcpy(timestamps + (TS_SIZE * lastts), rbuf, TS_SIZE);
if (nrts < hbstamps)
nrts++;
++lastts;
lastts = lastts % hbstamps;
}
/* Write an indication that the watchdog has started to the heartbeat file */
/* copy it to the buffer */
sprintf(rbuf, "%*s\n", TS_SIZE - 1, "--restart--");
memcpy(timestamps + (lastts * TS_SIZE), rbuf, TS_SIZE);
/* success */
next_value();
}
}
return rv;
}
/* write a heartbeat file */
int write_heartbeat(void)
{
time_t timenow;
struct tm *tm;
char tbuf[TS_SIZE + 1];
char tbufw[TS_SIZE + 1];
if (hb == NULL)
return (ENOERR);
/* MJ 16/2/2001 keep a rolling buffer in a file of writes to the
watchdog device, any gaps in this will indicate a reboot */
timenow = time(NULL);
if (timenow != -1) {
tm = gmtime(&timenow);
/* Get the seconds since seconds since 00:00:00, Jan 1, 1970 */
strftime(tbuf, TS_SIZE - 1, "%s", tm);
/* Make it the right width */
sprintf(tbufw, "%*s\n", TS_SIZE - 1, tbuf);
/* copy it to the buffer */
memcpy(timestamps + (lastts * TS_SIZE), tbufw, TS_SIZE);
/* success */
next_value();
/* write the buffer to the file */
rewind(hb);
if (nrts == hbstamps) {
/* write from the logical start of the buffer to the physical end */
if (fwrite(timestamps + (lastts * TS_SIZE), TS_SIZE, hbstamps - lastts, hb) == 0) {
int err = errno;
log_message(LOG_ERR, "write heartbeat file gave error %d = '%s'!", err, strerror(err));
}
/* write from the physical start of the buffer to the logical end */
if (fwrite(timestamps, TS_SIZE, lastts, hb) == 0) {
int err = errno;
log_message(LOG_ERR, "write heartbeat file gave error %d = '%s'!", err, strerror(err));
}
} else {
/* write from the physical start of the buffer to the logical end */
if (fwrite(timestamps, TS_SIZE, nrts, hb) == 0) {
int err = errno;
log_message(LOG_ERR, "write heartbeat file gave error %d = '%s'!", err, strerror(err));
}
}
fflush(hb);
}
return (ENOERR);
}
int close_heartbeat(void)
{
int rv = 0;
if (hb != NULL && fclose(hb) == -1) {
log_message(LOG_ALERT, "cannot close %s (errno = %d)", heartbeat, errno);
rv = -1;
}
hb = NULL;
if (timestamps != NULL) {
free(timestamps);
timestamps = NULL;
}
return rv;
}
watchdog-5.14.orig/src/mntent.c 0000644 0000000 0000000 00000010506 12233767421 013341 0 ustar /* $Header: /cvsroot/watchdog/watchdog/src/mntent.c,v 1.2 2006/07/31 09:39:23 meskes Exp $ */
/* Private version of the libc *mntent() routines. */
/* Note slightly different prototypes. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include /* for strchr */
#include /* for isdigit */
#include "wd_mntent.h"
#include "sundries.h" /* for xmalloc */
/* Unfortunately the classical Unix /etc/mtab and /etc/fstab
do not handle directory names containing spaces.
Here we mangle them, replacing a space by \040.
What do other Unices do? */
static char need_escaping[] = { ' ', '\t', '\n', '\\' };
static char *mangle(const char *s)
{
char *ss, *sp;
int n;
n = (int)strlen(s);
ss = sp = xmalloc(4 * n + 1);
while (1) {
for (n = 0; n < sizeof(need_escaping); n++) {
if (*s == need_escaping[n]) {
*sp++ = '\\';
*sp++ = '0' + ((*s & 0300) >> 6);
*sp++ = '0' + ((*s & 070) >> 3);
*sp++ = '0' + (*s & 07);
goto next;
}
}
*sp++ = *s;
if (*s == 0)
break;
next:
s++;
}
return ss;
}
static int is_space_or_tab(char c)
{
return (c == ' ' || c == '\t');
}
static char *skip_spaces(char *s)
{
while (is_space_or_tab(*s))
s++;
return s;
}
static char *skip_nonspaces(char *s)
{
while (*s && !is_space_or_tab(*s))
s++;
return s;
}
#define isoctal(a) (((a) & ~7) == '0')
/* returns malloced pointer - no more strdup required */
static char *unmangle(char *s)
{
char *ret, *ss, *sp;
ss = skip_nonspaces(s);
ret = sp = xmalloc(ss - s + 1);
while (s != ss) {
if (*s == '\\' && isoctal(s[1]) && isoctal(s[2]) && isoctal(s[3])) {
*sp++ = 64 * (s[1] & 7) + 8 * (s[2] & 7) + (s[3] & 7);
s += 4;
} else
*sp++ = *s++;
}
*sp = 0;
return ret;
}
/*
* fstat'ing the file and allocating a buffer holding all of it
* may be a bad idea: if the file is /proc/mounttab, the stat
* returns 0.
* (On the other hand, mangling and unmangling is meaningless
* for /proc/mounttab.)
*/
mntFILE *my_setmntent(const char *file, char *mode)
{
mntFILE *mfp = xmalloc(sizeof(*mfp));
mfp->mntent_fp = fopen(file, mode);
mfp->mntent_file = xstrdup(file);
mfp->mntent_errs = (mfp->mntent_fp == NULL);
mfp->mntent_softerrs = 0;
mfp->mntent_lineno = 0;
return mfp;
}
void my_endmntent(mntFILE * mfp)
{
if (mfp) {
if (mfp->mntent_fp)
fclose(mfp->mntent_fp);
if (mfp->mntent_file)
free(mfp->mntent_file);
free(mfp);
}
}
int my_addmntent(mntFILE * mfp, struct mntent *mnt)
{
char *m1, *m2, *m3, *m4;
int res;
if (fseek(mfp->mntent_fp, 0, SEEK_END))
return 1; /* failure */
m1 = mangle(mnt->mnt_fsname);
m2 = mangle(mnt->mnt_dir);
m3 = mangle(mnt->mnt_type);
m4 = mangle(mnt->mnt_opts);
res = ((fprintf(mfp->mntent_fp, "%s %s %s %s %d %d\n", m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno)
< 0) ? 1 : 0);
free(m1);
free(m2);
free(m3);
free(m4);
return res;
}
/* Read the next entry from the file fp. Stop reading at an incorrect entry. */
struct mntent *my_getmntent(mntFILE * mfp)
{
static char buf[4096];
static struct mntent me;
char *s;
again:
if (mfp->mntent_errs || mfp->mntent_softerrs >= ERR_MAX)
return NULL;
/* read the next non-blank non-comment line */
do {
if (fgets(buf, sizeof(buf), mfp->mntent_fp) == NULL)
return NULL;
s = strchr(buf, '\n');
if (s == NULL) {
/* extremely long line - assume file was corrupted */
mfp->mntent_errs = 1;
goto err;
}
*s = 0;
s = skip_spaces(buf);
} while (*s == '\0' || *s == '#');
me.mnt_fsname = unmangle(s);
s = skip_nonspaces(s);
s = skip_spaces(s);
me.mnt_dir = unmangle(s);
s = skip_nonspaces(s);
s = skip_spaces(s);
me.mnt_type = unmangle(s);
s = skip_nonspaces(s);
s = skip_spaces(s);
me.mnt_opts = unmangle(s);
s = skip_nonspaces(s);
s = skip_spaces(s);
if (isdigit(*s)) {
me.mnt_freq = atoi(s);
while (isdigit(*s))
s++;
} else
me.mnt_freq = 0;
if (*s && !is_space_or_tab(*s))
goto err;
s = skip_spaces(s);
if (isdigit(*s)) {
me.mnt_passno = atoi(s);
while (isdigit(*s))
s++;
} else
me.mnt_passno = 0;
if (*s && !is_space_or_tab(*s))
goto err;
/* allow more stuff, e.g. comments, on this line */
return &me;
err:
mfp->mntent_softerrs++;
fprintf(stderr, "[mntent]: line %d in %s is bad%s\n",
mfp->mntent_lineno, mfp->mntent_file,
(mfp->mntent_errs || mfp->mntent_softerrs >= ERR_MAX) ? "; rest of file ignored" : "");
goto again;
}
watchdog-5.14.orig/src/logmessage.c 0000644 0000000 0000000 00000007567 12233767421 014177 0 ustar /* > logmessage.c
*
* Code for creating messages and sending them to stderr and/or to syslog.
* Also has fatal_error() function to the same then exit.
*
* NOTE: We can't use malloc() here as one reason for a call could be the
* out-of-memory condition, so we use a modest stack-based buffer for the
* string "printing" before dumping it to the terminal and/or syslog.
*
* (c) 2013 Paul S. Crawford (psc@sat.dundee.ac.uk) licensed under GPL v2
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "logmessage.h"
#define MAX_MESSAGE 1024
#define MAX_PROG_NAME 256
static int output_message(int level, char *buf);
static int using_syslog = 0;
static int using_terminal = 0;
static char progname[MAX_PROG_NAME];
/*
* Prepare for message printing.
*
* On the 1st call to this should include the program's name (e.g. argv[])
* but after that you can use NULL.
*
* The integer flags enable/disable output to either the terminal (via 'stderr')
* or to syslog (assuming it is compiled as such, otherwise terminal as well).
*/
int open_logging(const char *name, int flags)
{
int rv = 0;
if (name != NULL)
strncpy(progname, name, sizeof(progname) - 1);
using_terminal = (flags & MSG_TO_STDERR);
if (flags & MSG_TO_SYSLOG) {
if (!using_syslog) {
#if USE_SYSLOG
openlog(progname, LOG_PID, LOG_DAEMON);
#endif /*USE_SYSLOG */
using_syslog = 1; /* Future messages to syslog. */
}
} else {
close_logging();
}
return rv;
}
/*
* Output a message with a given priority level. Used internally for both
* log_message() and fatal_error() calls. When using syslog we can output
* twice, but without syslog either mode is directed to the terminal once.
*/
static int output_message(int level, char *buf)
{
FILE *fp = stderr;
int rv = 0;
#if USE_SYSLOG
if (using_syslog) {
syslog(level, "%s", buf);
}
if (using_terminal) {
#else
if (using_terminal || using_syslog) {
#endif /* !USE_SYSLOG */
rv = fprintf(fp, "%s: %s\n", progname, buf);
if(rv < 0 || fflush(fp)) {
/* Error writing out to terminal - don't bother trying again. */
using_terminal = 0;
#if USE_SYSLOG
syslog(level, "failed writing message terminal (rv=%d, errno='%s')", rv, strerror(errno));
#endif /* USE_SYSLOG */
}
}
return rv;
}
/*
* Log a message to syslog and/or the terminal.
*
* NOTE: Unlike syslog you can't use '%m' formatting for error codes, instead use
* the string '%s' and give it strerror(errno) as an argument.
*/
int log_message(int level, const char *fmt, ...)
{
int rv = 0;
char buf[MAX_MESSAGE];
va_list args;
memset(buf, 0, sizeof(buf));
va_start(args, fmt);
#if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
vsnprintf(buf, sizeof(buf) - 1, fmt, args);
#else
vsprintf(buf, fmt, args);
#endif
va_end(args);
rv = output_message(level, buf);
return rv;
}
/*
* Function to log a message then exit program with a given error code.
*/
void fatal_error(int exitcode, const char *fmt, ...)
{
char buf[MAX_MESSAGE];
va_list args;
memset(buf, 0, sizeof(buf));
va_start(args, fmt);
#if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
vsnprintf(buf, sizeof(buf) - 1, fmt, args);
#else
vsprintf(buf, fmt, args);
#endif
va_end(args);
output_message(LOG_ERR, buf);
close_logging();
#if defined(DEBUG)
/*
* This should trigger a core dump when in debug mode, allowing trace-back
* to find out why we were leaving unexpectedly.
*/
assert(!buf);
#endif /*DEBUG*/
exit(exitcode);
}
/*
* Stop any logging via syslog.
*
* Return is 0 is stopped, or -1 if not in use.
*
* Note you don't need to use this, it is also possible to call something
* like open_logging(NULL, MSG_TO_STDERR) to close syslog.
*/
int close_logging(void)
{
int rv = -1;
/* Log the closing message */
if (using_syslog) {
#if USE_SYSLOG
closelog();
#endif /* USE_SYSLOG */
using_syslog = 0;
rv = 0;
}
return rv;
}
watchdog-5.14.orig/src/test_binary.c 0000644 0000000 0000000 00000010423 12420301016 014333 0 ustar #ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include "extern.h"
#include "watch_err.h"
struct process {
char proc_name[PATH_MAX];
pid_t pid;
time_t time;
struct process *next;
};
static struct process *process_head = NULL;
static void add_process(const char *name, pid_t pid)
{
struct process *node = (struct process *)xmalloc(sizeof(struct process));
snprintf(node->proc_name, sizeof(node->proc_name), "%s", name);
node->pid = pid;
node->time = time(NULL);
node->next = process_head;
process_head = node;
}
static void remove_process(pid_t pid)
{
struct process *last, *current;
last = NULL;
current = process_head;
while (current != NULL && current->pid != pid) {
last = current;
current = current->next;
}
if (current != NULL) {
if (last == NULL)
process_head = current->next;
else
last->next = current->next;
free(current);
}
}
/* See if any test processes have exceeded the timeout */
static int check_processes(const char *name, time_t timeout)
{
struct process *current;
time_t now = time(NULL);
current = process_head;
while (current != NULL) {
if (!strcmp(current->proc_name, name) && now - current->time > timeout) {
remove_process(current->pid);
return (ETOOLONG);
}
current = current->next;
}
return (ENOERR);
}
/* execute test binary */
int check_bin(char *tbinary, time_t timeout, int version)
{
pid_t child_pid;
int result, res = 0;
if (tbinary == NULL)
return ENOERR;
if (timeout > 0)
res = check_processes(tbinary, timeout);
if (res == ETOOLONG) {
log_message(LOG_ERR, "test-binary %s exceeded time limit %ld", tbinary, timeout);
return res;
}
child_pid = fork();
if (!child_pid) {
/* Don't want the stdout and stderr of our test program
* to cause trouble, so make them go to their respective files */
strcpy(filename_buf, logdir);
strcat(filename_buf, "/test-bin.stdout");
if (!freopen(filename_buf, "a+", stdout))
exit(errno);
strcpy(filename_buf, logdir);
strcat(filename_buf, "/test-bin.stderr");
if (!freopen(filename_buf, "a+", stderr))
exit(errno);
/* now start binary */
if (version == 0) {
execl(tbinary, tbinary, NULL);
} else {
execl(tbinary, tbinary, "test", NULL);
}
/* execl should only return in case of an error */
/* so we return that error */
exit(errno);
} else if (child_pid < 0) { /* fork failed */
int err = errno;
if (errno == EAGAIN) { /* process table full */
log_message(LOG_ERR, "process table is full!");
return (EREBOOT);
} else if (softboot)
return (err);
else
return (ENOERR);
} else {
int ret, err;
/* fork was okay, add child to process list */
add_process(tbinary, child_pid);
/* wait for child(s) to stop, but only after a short sleep */
/* only sleep for /2 seconds to make sure we finish on time */
usleep(tint * 500000);
do {
ret = waitpid(-1, &result, WNOHANG);
err = errno;
if (ret > 0)
remove_process(ret);
} while (ret > 0 && WIFEXITED(result) != 0 && WEXITSTATUS(result) == 0);
/* check result: */
/* ret < 0 => error */
/* ret == 0 => no more child returned, however we may already have caught the actual child */
/* WIFEXITED(result) == 0 => child did not exit normally but was killed by signal which was not caught */
/* WEXITSTATUS(result) != 0 => child returned an error code */
if (ret > 0) {
if (WIFEXITED(result) != 0) {
/* if one of the scripts returns an error code just return that code */
log_message(LOG_ERR, "test binary %s returned %d", tbinary, WEXITSTATUS(result));
return (WEXITSTATUS(result));
} else if (WIFSIGNALED(result) != 0) {
/* if one of the scripts was killed return ECHKILL */
log_message(LOG_ERR, "test binary %s was killed by uncaught signal %d", tbinary, WTERMSIG(result));
return (ECHKILL);
}
} else {
/* in case there are still old childs running due to an error */
/* log that error */
if (ret != 0 && err != 0 && err != ECHILD) {
errno = err;
log_message(LOG_ERR, "child %d did not exit immediately (error = %d = '%s')", child_pid, err, strerror(err));
if (softboot)
return (err);
}
}
}
return (ENOERR);
}
watchdog-5.14.orig/src/wd_identify.c 0000644 0000000 0000000 00000005152 12326205111 014324 0 ustar /*************************************************************/
/* Small utility to identify hardware watchdog */
/* */
/* Idea and most of the implementation by */
/* Corey Minyard */
/* */
/* The rest was written by me, Michael Meskes */
/* meskes@debian.org */
/* */
/*************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "extern.h"
static void usage(char *progname)
{
fprintf(stderr, "%s version %d.%d, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION);
fprintf(stderr, "%s [-c | --config-file ]\n", progname);
exit(1);
}
int main(int argc, char *const argv[])
{
char *configfile = CONFIG_FILENAME;
int c;
struct watchdog_info ident;
char *opts = "c:";
struct option long_options[] = {
{"config-file", required_argument, NULL, 'c'},
{NULL, 0, NULL, 0}
};
int watchdog = -1;
char *progname = basename(argv[0]);
open_logging(progname, MSG_TO_STDERR);
/* check for the one option we understand */
while ((c = getopt_long(argc, argv, opts, long_options, NULL)) != EOF) {
switch (c) {
case 'c':
configfile = optarg;
break;
default:
usage(progname);
}
}
read_config(configfile);
/* this program has no other function than identifying the hardware behind
* this device i.e. if there is no device given we better punt */
if (devname == NULL) {
printf("No watchdog hardware configured in \"%s\"\n", configfile);
exit(0);
}
/* open the device */
watchdog = open(devname, O_WRONLY);
if (watchdog == -1) {
log_message(LOG_ERR, "cannot open %s (errno = %d = '%s')", devname, errno, strerror(errno));
exit(1);
}
/* Print watchdog identity */
if (ioctl(watchdog, WDIOC_GETSUPPORT, &ident) < 0) {
log_message(LOG_ERR, "cannot get watchdog identity (errno = %d = '%s')", errno, strerror(errno));
} else {
ident.identity[sizeof(ident.identity) - 1] = '\0'; /* Be sure */
printf("%s\n", ident.identity);
}
if (write(watchdog, "V", 1) < 0)
log_message(LOG_ERR, "write watchdog device gave error %d = '%s'!", errno, strerror(errno));
if (close(watchdog) == -1)
log_message(LOG_ALERT, "cannot close watchdog (errno = %d = '%s')", errno, strerror(errno));
close_logging();
exit(0);
}
watchdog-5.14.orig/src/file_stat.c 0000644 0000000 0000000 00000002224 12233767421 014004 0 ustar #ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include "extern.h"
#include "watch_err.h"
int check_file_stat(struct list *file)
{
struct stat buf;
/* in filemode stat file */
if (stat(file->name, &buf) == -1) {
int err = errno;
log_message(LOG_ERR, "cannot stat %s (errno = %d = '%s')", file->name, err, strerror(err));
/* on error ENETDOWN|ENETUNREACH we react as if we're in ping mode */
if (softboot || err == ENETDOWN || err == ENETUNREACH)
return (err);
} else if (file->parameter.file.mtime != 0) {
/* do verbose logging */
if (verbose && logtick && ticker == 1) {
char text[25];
/* Remove the trailing '\n' of the ctime() formatted string. */
strncpy(text, ctime(&buf.st_mtime), sizeof(text)-1);
text[sizeof(text)-1] = 0;
log_message(LOG_INFO, "file %s was last changed at %s", file->name, text);
}
if (time(NULL) - buf.st_mtime > file->parameter.file.mtime) {
/* file wasn't changed often enough */
log_message(LOG_ERR, "file %s was not changed in %d seconds.", file->name, file->parameter.file.mtime);
return (ENOCHANGE);
}
}
return (ENOERR);
}
watchdog-5.14.orig/src/wd_keepalive.c 0000644 0000000 0000000 00000011747 12326205111 014465 0 ustar /**********************************************************
* Copyright: Appliance Studio Ltd
* Michael Meskes
* License: GPL
*
* Filename: $Id: wd_keepalive.c,v 1.6 2007/08/17 09:24:54 meskes Exp $
* Author: Marcel Jansen, 22 February 2001
* Michael Meskes, since then
* Purpose: This program can be run during critical periods
* when the normal watchdog shouldn't be run. It will
* read from the same configuration file, it will do
* no checks but will keep writing to the device
*
***********************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "extern.h"
#define TRUE 1
#define FALSE 0
volatile sig_atomic_t _running = 1;
static void usage(char *progname)
{
fprintf(stderr, "%s version %d.%d, usage:\n", progname, MAJOR_VERSION, MINOR_VERSION);
fprintf(stderr, "%s [-c | --config-file ]\n", progname);
exit(1);
}
/* write a log entry on exit */
static void log_end(void)
{
/* Log the closing message */
log_message(LOG_INFO, "stopping watchdog keepalive daemon (%d.%d)", MAJOR_VERSION, MINOR_VERSION);
close_logging();
usleep(100000); /* 0.1s to make sure log is written */
return;
}
/* Dummy function for keep_alive.c use */
int write_heartbeat(void)
{
return 0;
}
/* close the device and check for error */
static void close_all(void)
{
close_watchdog();
}
void sigterm_handler(int arg)
{
_running = 0;
}
/* on exit we close the device and log that we stop */
void terminate(void)
{
unlock_our_memory();
close_all();
remove_pid_file();
log_end();
exit(0);
}
int main(int argc, char *const argv[])
{
char *configfile = CONFIG_FILENAME;
pid_t child_pid;
int count = 0;
int c;
char *progname;
/* allow all options watchdog understands too */
char *opts = "d:i:n:fsvbql:p:t:c:r:m:a:";
struct option long_options[] = {
{"config-file", required_argument, NULL, 'c'},
{"force", no_argument, NULL, 'f'},
{"sync", no_argument, NULL, 's'},
{"no-action", no_argument, NULL, 'q'},
{"verbose", no_argument, NULL, 'v'},
{"softboot", no_argument, NULL, 'b'},
{NULL, 0, NULL, 0}
};
progname = basename(argv[0]);
open_logging(progname, MSG_TO_STDERR | MSG_TO_SYSLOG);
/* check for the one option we understand */
while ((c = getopt_long(argc, argv, opts, long_options, NULL)) != EOF) {
switch (c) {
case 'c':
configfile = optarg;
break;
case 'n':
case 'p':
case 'a':
case 'r':
case 'd':
case 't':
case 'l':
case 'm':
case 'i':
case 'f':
case 's':
case 'b':
case 'q':
case 'v':
break;
default:
usage(progname);
}
}
read_config(configfile);
/* make sure we're on the root partition */
if (chdir("/") < 0) {
perror(progname);
exit(1);
}
#if !defined(DEBUG)
/* fork to go into the background */
if ((child_pid = fork()) < 0) {
perror(progname);
exit(1);
} else if (child_pid > 0) {
/* fork was okay */
/* wait for child to exit */
if (waitpid(child_pid, NULL, 0) != child_pid) {
perror(progname);
exit(1);
}
/* and exit myself */
exit(0);
}
/* and fork again to make sure we inherit all rights from init */
if ((child_pid = fork()) < 0) {
perror(progname);
exit(1);
} else if (child_pid > 0)
exit(0);
#endif /* !DEBUG */
/* now we're free */
#if !defined(DEBUG)
/* Okay, we're a daemon */
/* but we're still attached to the tty */
/* create our own session */
setsid();
/* with USE_SYSLOG we don't do any console IO */
close(0);
close(1);
close(2);
#endif /* !DEBUG */
/* tuck my process id away */
if (write_pid_file(KA_PIDFILE)) {
fatal_error(EX_USAGE, "unable to gain lock via PID file");
}
/* Log the starting message */
open_logging(NULL, MSG_TO_SYSLOG);
log_message(LOG_INFO, "starting watchdog keepalive daemon (%d.%d):", MAJOR_VERSION, MINOR_VERSION);
if (devname == NULL)
log_message(LOG_INFO, " no watchdog device configured, aborting");
else
log_message(LOG_INFO, " int=%d alive=%s realtime=%s", tint, devname, realtime ? "yes" : "no");
/* this daemon has no other function than writing to this device
* i.e. if there is no device given we better punt */
if (devname == NULL)
terminate();
/* open the device */
if (open_watchdog(devname, dev_timeout) < 0) {
remove_pid_file();
log_end();
exit(1);
}
/* set signal term to call sigterm_handler() */
/* to make sure watchdog device is closed */
signal(SIGTERM, sigterm_handler);
lock_our_memory(realtime, schedprio, daemon_pid);
/* main loop: update after seconds */
while (_running) {
keep_alive();
/* finally sleep some seconds */
sleep(tint);
count++;
}
terminate();
/* not reached */
return 0;
}
watchdog-5.14.orig/src/xmalloc.c 0000644 0000000 0000000 00000002542 12233767421 013474 0 ustar /* > xmalloc.c
*
* Versions of memory allocation that exit with error message if failure occurs.
* Based on old sundries.c but with some minor improvements and the code
* in it that was for mount.c/umount.c support removed.
*
* (c) 2013 Paul S. Crawford (psc@sat.dundee.ac.uk) licensed under GPL v2, based
* on older code in sundries.c
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include "xmalloc.h"
#include "logmessage.h"
void *xmalloc(size_t size)
{
void *t;
if (size == 0)
return NULL;
t = malloc(size);
if (t == NULL)
fatal_error(EX_SYSERR, "xmalloc failed for %lu bytes", (unsigned long)size);
return t;
}
void *xcalloc(size_t nmemb, size_t size)
{
void *t;
if (nmemb == 0 || size == 0)
return NULL;
t = calloc(nmemb, size);
if (t == NULL)
fatal_error(EX_SYSERR, "xcalloc failed for %lu x %lu bytes", (unsigned long)nmemb, (unsigned long)size);
return t;
}
char *xstrdup(const char *s)
{
char *t;
if (s == NULL)
return NULL;
t = strdup(s);
if (t == NULL)
fatal_error(EX_SYSERR, "xstrdup failed for %lu byte string", (unsigned long)strlen(s));
return t;
}
char *xstrndup(const char *s, int n)
{
char *t;
if (s == NULL || n < 0)
fatal_error(EX_SOFTWARE, "bad xstrndup call (%sn = %d)", s == NULL ? "" : "s = NULL, ", n);
t = xmalloc(n + 1);
strncpy(t, s, n);
t[n] = 0;
return t;
}
watchdog-5.14.orig/src/Makefile.am 0000644 0000000 0000000 00000001224 12326772040 013715 0 ustar sbin_PROGRAMS = watchdog wd_keepalive wd_identify
watchdog_SOURCES = file_stat.c file_table.c fstab.c iface.c ifdown.c keep_alive.c \
load.c lomount.c memory.c mntent.c mount.c net.c nfsmount.c \
nfsmount_clnt.c nfsmount_xdr.c pidfile.c shutdown.c sundries.c \
temp.c test_binary.c umount.c version.c watchdog.c \
logmessage.c xmalloc.c heartbeat.c lock_mem.c daemon-pid.c configfile.c
wd_keepalive_SOURCES = wd_keepalive.c logmessage.c lock_mem.c daemon-pid.c xmalloc.c \
configfile.c keep_alive.c
wd_identify_SOURCES = wd_identify.c logmessage.c xmalloc.c configfile.c
AM_CPPFLAGS = -I@top_srcdir@/include
distclean-depend:
rm -rf .deps
watchdog-5.14.orig/src/mount.c 0000644 0000000 0000000 00000103674 12233772561 013210 0 ustar /* $Header: /cvsroot/watchdog/watchdog/src/mount.c,v 1.2 2006/07/31 09:39:23 meskes Exp $ */
/*
* A mount(8) for Linux 0.99.
* mount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
*
* Thu Jul 14 07:32:40 1994: faith@cs.unc.edu added changes from Adam
* J. Richter (adam@adam.yggdrasil.com) so that /proc/filesystems is used
* if no -t option is given. I modified his patches so that, if
* /proc/filesystems is not available, the behavior of mount is the same as
* it was previously.
*
* Wed Sep 14 22:43:00 1994: Mitchum DSouza
* (mitch@mrc-applied-psychology.cambridge.ac.uk) added support for mounting
* the "loop" device.
*
* Wed Sep 14 22:55:10 1994: Sander van Malssen (svm@kozmix.hacktic.nl)
* added support for remounting readonly file systems readonly.
*
* Wed Feb 8 09:23:18 1995: Mike Grupenhoff added
* a probe of the superblock for the type before /proc/filesystems is
* checked.
*
* Wed Feb 8 12:27:00 1995: Andries.Brouwer@cwi.nl fixed up error messages.
* Sat Jun 3 20:44:38 1995: Patches from Andries.Brouwer@cwi.nl applied.
* Tue Sep 26 22:38:20 1995: aeb@cwi.nl, many changes
* Fri Feb 23 13:47:00 1996: aeb@cwi.nl, loop device related changes
*
* Fri Apr 5 01:13:33 1996: quinlan@bucknell.edu, fixed up iso9660 autodetect
*
* Since then, many changes - aeb.
*
* Wed Oct 1 23:55:28 1997: Dick Streefland
* Implemented the "bg", "fg" and "retry" mount options for NFS.
*
* Tue Aug 4 15:54:31 1998: aeb@cwi.nl:
* Open fd 0,1,2 so that printf's do not clobber /etc/mtab or so.
* Mangle filenames with embedded spaces. Add ufsmagic. Add locking.
* Avoid unnecessary error messages about /proc.
* Improve support for noncanonical names in /etc/fstab.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "mount_constants.h"
#include "sundries.h"
#include "wd_mntent.h"
#include "fstab.h"
#include "lomount.h"
#include "loop.h"
#include "linux_fs.h"
#define PROC_FILESYSTEMS "/proc/filesystems"
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
#define DO_PS_FIDDLING
#ifdef DO_PS_FIDDLING
#define PROC_NAME "mount: "
static int argc0;
static char **argv0;
static char **envp0;
extern char **environ;
#endif
/* True for fake mount (-f). */
int fake = 0;
/* Don't write a entry in /etc/mtab (-n). */
int mount_nomtab = 0;
/* True for explicit readonly (-r). */
int readonly = 0;
/* Nonzero for chatty (-v). */
int mount_verbose = 0;
/* Nonzero for sloppy (-s). */
int sloppy = 0;
/* True for explicit read/write (-w). */
int readwrite = 0;
/* True for all mount (-a). */
int all = 0;
/* True for fork() during all mount (-F). */
int optfork = 0;
/* True if ruid != euid. */
int mount_suid = 0;
/* Map from -o and fstab option strings to the flag argument to mount(2). */
struct opt_map {
const char *opt; /* option name */
int skip; /* skip in mtab option string */
int inv; /* true if flag value should be inverted */
int mask; /* flag mask value */
};
/* Custom mount options for our own purposes. */
/* We can use the high-order 16 bits, since the mount call
has MS_MGC_VAL there. */
#define MS_NOAUTO 0x80000000
#define MS_USER 0x40000000
#define MS_LOOP 0x00010000
/* Options that we keep the mount system call from seeing. */
#define MS_NOSYS (MS_NOAUTO|MS_USER|MS_LOOP)
/* Options that we keep from appearing in the options field in the mtab. */
#define MS_NOMTAB (MS_REMOUNT|MS_NOAUTO|MS_USER)
/* OPTIONS that we make ordinary users have by default. */
#define MS_SECURE (MS_NOEXEC|MS_NOSUID|MS_NODEV)
const struct opt_map opt_map[] = {
{"defaults", 0, 0, 0}, /* default options */
{"ro", 1, 0, MS_RDONLY}, /* read-only */
{"rw", 1, 1, MS_RDONLY}, /* read-write */
{"exec", 0, 1, MS_NOEXEC}, /* permit execution of binaries */
{"noexec", 0, 0, MS_NOEXEC}, /* don't execute binaries */
{"mount_suid", 0, 1, MS_NOSUID}, /* honor mount_suid executables */
{"nomount_suid", 0, 0, MS_NOSUID}, /* don't honor mount_suid executables */
{"dev", 0, 1, MS_NODEV}, /* interpret device files */
{"nodev", 0, 0, MS_NODEV}, /* don't interpret devices */
{"sync", 0, 0, MS_SYNCHRONOUS}, /* synchronous I/O */
{"async", 0, 1, MS_SYNCHRONOUS}, /* asynchronous I/O */
{"remount", 0, 0, MS_REMOUNT}, /* Alter flags of mounted FS */
{"auto", 0, 1, MS_NOAUTO}, /* Can be mounted using -a */
{"noauto", 0, 0, MS_NOAUTO}, /* Can only be mounted explicitly */
{"user", 0, 0, MS_USER}, /* Allow ordinary user to mount */
{"nouser", 0, 1, MS_USER}, /* Forbid ordinary user to mount */
/* add new options here */
#ifdef MS_NOSUB
{"sub", 0, 1, MS_NOSUB}, /* allow submounts */
{"nosub", 0, 0, MS_NOSUB}, /* don't allow submounts */
#endif
#ifdef MS_SILENT
{"quiet", 0, 0, MS_SILENT}, /* be quiet */
{"loud", 0, 1, MS_SILENT}, /* print out messages. */
#endif
#ifdef MS_MANDLOCK
{"mand", 0, 0, MS_MANDLOCK}, /* Allow mandatory locks on this FS */
{"nomand", 0, 1, MS_MANDLOCK}, /* Forbid mandatory locks on this FS */
#endif
{"loop", 1, 0, MS_LOOP}, /* use a loop device */
#ifdef MS_NOATIME
{"atime", 0, 1, MS_NOATIME}, /* Update access time */
{"noatime", 0, 0, MS_NOATIME}, /* Do not update access time */
#endif
#ifdef MS_NODIRATIME
{"diratime", 0, 1, MS_NODIRATIME}, /* Update dir access times */
{"nodiratime", 0, 0, MS_NODIRATIME}, /* Do not update dir access times */
#endif
{NULL, 0, 0, 0}
};
char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption;
struct string_opt_map {
char *tag;
int skip;
char **valptr;
} string_opt_map[] = {
{
"loop=", 0, &opt_loopdev}, {
"vfs=", 1, &opt_vfstype}, {
"offset=", 0, &opt_offset}, {
"encryption=", 0, &opt_encryption}, {
NULL, 0, NULL}
};
static void clear_string_opts(void)
{
struct string_opt_map *m;
for (m = &string_opt_map[0]; m->tag; m++)
*(m->valptr) = NULL;
}
static int parse_string_opt(char *s)
{
struct string_opt_map *m;
int lth;
for (m = &string_opt_map[0]; m->tag; m++) {
lth = strlen(m->tag);
if (!strncmp(s, m->tag, lth)) {
*(m->valptr) = xstrdup(s + lth);
return 1;
}
}
return 0;
}
int mount_mount_quiet = 0;
/* Report on a single mount. */
static void print_one(const struct mntentchn *mc)
{
if (mount_mount_quiet)
return;
printf("%s on %s", mc->mnt_fsname, mc->mnt_dir);
if (mc->mnt_type != NULL && *(mc->mnt_type) != '\0')
printf(" type %s", mc->mnt_type);
if (mc->mnt_opts != NULL)
printf(" (%s)", mc->mnt_opts);
printf("\n");
}
/* Report on everything in mtab (of the specified types if any). */
static int print_all(string_list types)
{
struct mntentchn *mc;
for (mc = mtab_head()->nxt; mc; mc = mc->nxt) {
if (matching_type(mc->mnt_type, types))
print_one(mc);
}
exit(0);
}
/* Look for OPT in opt_map table and return mask value. If OPT isn't found,
tack it onto extra_opts (which is non-NULL). */
static inline void parse_opt(const char *opt, int *mask, char *extra_opts)
{
const struct opt_map *om;
for (om = opt_map; om->opt != NULL; om++)
if (streq(opt, om->opt)) {
if (om->inv)
*mask &= ~om->mask;
else
*mask |= om->mask;
if (om->mask == MS_USER)
*mask |= MS_SECURE;
#ifdef MS_SILENT
if (om->mask == MS_SILENT && om->inv) {
mount_mount_quiet = 1;
mount_verbose = 0;
}
#endif
return;
}
if (*extra_opts)
strcat(extra_opts, ",");
strcat(extra_opts, opt);
}
/* Take -o options list and compute 4th and 5th args to mount(2). flags
gets the standard options and extra_opts anything we don't recognize. */
static void parse_opts(char *opts, int *flags, char **extra_opts)
{
char *opt;
*flags = 0;
*extra_opts = NULL;
clear_string_opts();
if (opts != NULL) {
*extra_opts = xmalloc(strlen(opts) + 1);
**extra_opts = '\0';
for (opt = strtok(opts, ","); opt; opt = strtok(NULL, ","))
if (!parse_string_opt(opt))
parse_opt(opt, flags, *extra_opts);
}
if (readonly)
*flags |= MS_RDONLY;
if (readwrite)
*flags &= ~MS_RDONLY;
}
/* Try to build a canonical options string. */
static char *fix_opts_string(int flags, char *extra_opts)
{
const struct opt_map *om;
const struct string_opt_map *m;
char *new_opts;
new_opts = (flags & MS_RDONLY) ? "ro" : "rw";
for (om = opt_map; om->opt != NULL; om++) {
if (om->skip)
continue;
if (om->inv || !om->mask || (flags & om->mask) != om->mask)
continue;
new_opts = xstrconcat3(new_opts, ",", om->opt);
flags &= ~om->mask;
}
for (m = &string_opt_map[0]; m->tag; m++) {
if (!m->skip && *(m->valptr))
new_opts = xstrconcat4(new_opts, ",", m->tag, *(m->valptr));
}
if (extra_opts && *extra_opts) {
new_opts = xstrconcat3(new_opts, ",", extra_opts);
}
return new_opts;
}
/* Most file system types can be recognized by a `magic' number
in the superblock. Note that the order of the tests is
significant: by coincidence a filesystem can have the
magic numbers for several file system types simultaneously.
For example, the romfs magic lives in the 1st sector;
xiafs does not touch the 1st sector and has its magic in
the 2nd sector; ext2 does not touch the first two sectors. */
static inline unsigned short swapped(unsigned short a)
{
return (a >> 8) | (a << 8);
}
/*
char *fstype(const char *device);
Probes the device and attempts to determine the type of filesystem
contained within.
Original routine by ; made into a function
for mount(8) by Mike Grupenhoff .
Read the superblock only once - aeb
Added a test for iso9660 - aeb
Added a test for high sierra (iso9660) - quinlan@bucknell.edu
Corrected the test for xiafs - aeb
Added romfs - aeb
Added ufs from a patch by jj. But maybe there are several types of ufs?
Currently supports: minix, ext, ext2, xiafs, iso9660, romfs, ufs
*/
char *magic_known[] = { "minix", "ext", "ext2", "xiafs", "iso9660", "romfs",
"ufs"
};
static int tested(const char *device)
{
char **m;
for (m = magic_known; m - magic_known < SIZE(magic_known); m++)
if (!strcmp(*m, device))
return 1;
return 0;
}
static char *fstype(const char *device)
{
int fd;
char *type = NULL;
union {
struct minix_super_block ms;
struct ext_super_block es;
struct ext2_super_block e2s;
} sb;
union {
struct xiafs_super_block xiasb;
char romfs_magic[8];
} xsb;
struct ufs_super_block ufssb;
union {
struct iso_volume_descriptor iso;
struct hs_volume_descriptor hs;
} isosb;
struct stat statbuf;
/* opening and reading an arbitrary unknown path can have
undesired side effects - first check that `device' refers
to a block device */
if (stat(device, &statbuf) || !S_ISBLK(statbuf.st_mode))
return 0;
fd = open(device, O_RDONLY);
if (fd < 0)
return 0;
if (lseek(fd, 1024, SEEK_SET) != 1024 || read(fd, (char *)&sb, sizeof(sb)) != sizeof(sb))
goto io_error;
if (ext2magic(sb.e2s) == EXT2_SUPER_MAGIC
|| ext2magic(sb.e2s) == EXT2_PRE_02B_MAGIC || ext2magic(sb.e2s) == swapped(EXT2_SUPER_MAGIC))
type = "ext2";
else if (minixmagic(sb.ms) == MINIX_SUPER_MAGIC || minixmagic(sb.ms) == MINIX_SUPER_MAGIC2)
type = "minix";
else if (extmagic(sb.es) == EXT_SUPER_MAGIC)
type = "ext";
if (!type) {
if (lseek(fd, 0, SEEK_SET) != 0 || read(fd, (char *)&xsb, sizeof(xsb)) != sizeof(xsb))
goto io_error;
if (xiafsmagic(xsb.xiasb) == _XIAFS_SUPER_MAGIC)
type = "xiafs";
else if (!strncmp(xsb.romfs_magic, "-rom1fs-", 8))
type = "romfs";
}
if (!type) {
if (lseek(fd, 8192, SEEK_SET) != 8192 || read(fd, (char *)&ufssb, sizeof(ufssb)) != sizeof(ufssb))
goto io_error;
if (ufsmagic(ufssb) == UFS_SUPER_MAGIC) /* also test swapped version? */
type = "ufs";
}
if (!type) {
if (lseek(fd, 0x8000, SEEK_SET) != 0x8000 || read(fd, (char *)&isosb, sizeof(isosb)) != sizeof(isosb))
goto io_error;
if (strncmp(isosb.iso.id, ISO_STANDARD_ID, sizeof(isosb.iso.id)) == 0
|| strncmp(isosb.hs.id, HS_STANDARD_ID, sizeof(isosb.hs.id)) == 0)
type = "iso9660";
}
close(fd);
return (type);
io_error:
perror(device);
close(fd);
return 0;
}
FILE *procfs;
static void procclose(void)
{
if (procfs)
fclose(procfs);
procfs = 0;
}
static int procopen(void)
{
return ((procfs = fopen(PROC_FILESYSTEMS, "r")) != NULL);
}
static char *procnext(void)
{
char line[100];
static char fsname[50];
while (fgets(line, sizeof(line), procfs)) {
if (sscanf(line, "nodev %[^\n]\n", fsname) == 1)
continue;
if (sscanf(line, " %[^ \n]\n", fsname) != 1)
continue;
return fsname;
}
return 0;
}
static int is_in_proc(char *type)
{
char *fsname;
if (procopen()) {
while ((fsname = procnext()) != NULL)
if (!strcmp(fsname, type))
return 1;
}
return 0;
}
static int already(char *spec, char *node)
{
struct mntentchn *mc;
int ret = 1;
if ((mc = getmntfile(node)) != NULL)
error("mount: according to mtab, %s is already mounted on %s", mc->mnt_fsname, node);
else if ((mc = getmntfile(spec)) != NULL)
error("mount: according to mtab, %s is mounted on %s", spec, mc->mnt_dir);
else
ret = 0;
return ret;
}
/* Create mtab with a root entry. */
static void create_mtab(void)
{
struct mntentchn *fstab;
struct mntent mnt;
int flags;
char *extra_opts;
mntFILE *mfp;
lock_mtab();
mfp = my_setmntent(MOUNTED, "a+");
if (mfp == NULL || mfp->mntent_fp == NULL)
die(EX_FILEIO, "mount: can't open %s for writing: %s", MOUNTED, strerror(errno));
/* Find the root entry by looking it up in fstab */
if ((fstab = getfsfile("/")) || (fstab = getfsfile("root"))) {
parse_opts(xstrdup(fstab->mnt_opts), &flags, &extra_opts);
mnt.mnt_dir = "/";
mnt.mnt_fsname = canonicalize(fstab->mnt_fsname);
mnt.mnt_type = fstab->mnt_type;
mnt.mnt_opts = fix_opts_string(flags, extra_opts);
mnt.mnt_freq = mnt.mnt_passno = 0;
if (my_addmntent(mfp, &mnt) == 1)
die(EX_FILEIO, "mount: error writing %s: %s", MOUNTED, strerror(errno));
}
if (fchmod(fileno(mfp->mntent_fp), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0)
if (errno != EROFS)
die(EX_FILEIO, "mount: error changing mode of %s: %s", MOUNTED, strerror(errno));
my_endmntent(mfp);
unlock_mtab();
}
/* count successful mount system calls */
static int mountcount = 0;
static int mount5(char *special, char *dir, char *type, int flags, void *data)
{
int ret = mount(special, dir, type, 0xC0ED0000 | (flags), data);
if (ret == 0)
mountcount++;
return ret;
}
/* Mount a single file system. Return status,
so don't exit on non-fatal errors. */
static int try_mount5(char *spec, char *node, char **type, int flags, char *mount_opts)
{
char *fsname;
if (*type && strcasecmp(*type, "auto") == 0)
*type = NULL;
if (!*type && !(flags & MS_REMOUNT)) {
*type = fstype(spec);
if (mount_verbose) {
printf("mount: you didn't specify a filesystem type for %s\n", spec);
if (*type)
printf(" I will try type %s\n", *type);
else
printf(" I will try all types mentioned in %s\n", PROC_FILESYSTEMS);
}
}
if (*type || (flags & MS_REMOUNT))
return mount5(spec, node, *type, flags & ~MS_NOSYS, mount_opts);
if (!procopen())
return -1;
while ((fsname = procnext()) != NULL) {
if (tested(fsname))
continue;
if (mount5(spec, node, fsname, flags & ~MS_NOSYS, mount_opts) == 0) {
*type = xstrdup(fsname);
procclose();
return 0;
} else if (errno != EINVAL) {
*type = "guess";
procclose();
return 1;
}
}
procclose();
*type = NULL;
return -1;
}
/*
* try_mount_one()
* Try to mount one file system. When "bg" is 1, this is a retry
* in the background. One additional exit code EX_BG is used here.
* It is used to instruct the caller to retry the mount in the
* background.
*/
static int try_mount_one(char *spec0, char *node0, char *type0, char *opts0, int freq, int pass, int bg)
{
struct mntentchn mcn;
struct mntent mnt;
int mnt_err;
int flags;
char *extra_opts; /* written in mtab */
char *mount_opts; /* actually used on system call */
static int added_ro = 0;
int loop, looptype, offset;
char *spec, *node, *type, *opts, *loopdev, *loopfile;
struct stat statbuf;
spec = xstrdup(spec0);
node = xstrdup(node0);
type = xstrdup(type0);
opts = xstrdup(opts0);
parse_opts(xstrdup(opts), &flags, &extra_opts);
/* root may allow certain types of mounts by ordinary users */
if (mount_suid && !(flags & MS_USER)) {
if (already(spec, node))
die(EX_USAGE, "mount failed");
else
die(EX_USAGE, "mount: only root can mount %s on %s", spec, node);
}
/* quietly succeed for fstab entries that don't get mounted automatically */
if (all && (flags & MS_NOAUTO))
return 0;
mount_opts = extra_opts;
/*
* In the case of a loop mount, either type is of the form lo@/dev/loop5
* or the option "-o loop=/dev/loop5" or just "-o loop" is given, or
* mount just has to figure things out for itself from the fact that
* spec is not a block device. We do not test for a block device
* immediately: maybe later other types of mountable objects will occur.
*/
loopdev = opt_loopdev;
looptype = (type && strncmp("lo@", type, 3) == 0);
if (looptype) {
if (loopdev)
error("mount: loop device specified twice");
loopdev = type + 3;
type = opt_vfstype;
} else if (opt_vfstype) {
if (type)
error("mount: type specified twice");
else
type = opt_vfstype;
}
loop = ((flags & MS_LOOP) || loopdev || opt_offset || opt_encryption);
loopfile = spec;
if (loop) {
flags |= MS_LOOP;
if (fake) {
if (mount_verbose)
printf("mount: skipping the setup of a loop device\n");
} else {
int loopro = (flags & MS_RDONLY);
if (!loopdev || !*loopdev)
loopdev = find_unused_loop_device();
if (!loopdev)
return EX_SYSERR; /* no more loop devices */
if (mount_verbose)
printf("mount: going to use the loop device %s\n", loopdev);
offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0;
if (set_loop(loopdev, loopfile, offset, opt_encryption, &loopro))
return EX_FAIL;
spec = loopdev;
if (loopro)
flags |= MS_RDONLY;
}
}
if (!fake && type && streq(type, "nfs")) {
#if HAVE_NFS
mnt_err = nfsmount(spec, node, &flags, &extra_opts, &mount_opts, bg);
if (mnt_err)
return mnt_err;
#else
die(EX_SOFTWARE, "mount: this version was compiled " "without support for the type `nfs'");
#endif
}
/*
* Call mount.TYPE for types that require a separate
* mount program. For the moment these types are ncp and smb.
*/
if (type)
#ifndef ALWAYS_STAT
if (streq(type, "smb") || streq(type, "ncp"))
#else
if (strlen(type) < 100)
#endif
{
char mountprog[120];
sprintf(mountprog, "/sbin/mount.%s", type);
if (stat(mountprog, &statbuf) == 0) {
if (fork() == 0) {
char *oo, *mountargs[10];
int i = 0;
setuid(getuid());
setgid(getgid());
oo = fix_opts_string(flags, extra_opts);
mountargs[i++] = mountprog;
mountargs[i++] = spec;
mountargs[i++] = node;
if (mount_nomtab)
mountargs[i++] = "-n";
if (mount_verbose)
mountargs[i++] = "-v";
if (oo && *oo) {
mountargs[i++] = "-o";
mountargs[i++] = oo;
}
mountargs[i] = NULL;
execv(mountprog, mountargs);
exit(1); /* exec failed */
} else if (fork() != -1) {
int status;
wait(&status);
return status;
} else
error("cannot fork: %s", strerror(errno));
}
}
block_signals(SIG_BLOCK);
if (fake || (try_mount5(spec, node, &type, flags & ~MS_NOSYS, mount_opts)) == 0)
/* Mount succeeded, report this (if mount_verbose) and write mtab entry. */
{
if (loop)
opt_loopdev = loopdev;
mcn.mnt_fsname = mnt.mnt_fsname = canonicalize(loop ? loopfile : spec);
mcn.mnt_dir = mnt.mnt_dir = canonicalize(node);
mcn.mnt_type = mnt.mnt_type = type ? type : "unknown";
mcn.mnt_opts = mnt.mnt_opts = fix_opts_string(flags & ~MS_NOMTAB, extra_opts);
mcn.nxt = 0;
mnt.mnt_freq = freq;
mnt.mnt_passno = pass;
/* We get chatty now rather than after the update to mtab since the
mount succeeded, even if the write to /etc/mtab should fail. */
if (mount_verbose)
print_one(&mcn);
if (!mount_nomtab && mtab_is_writable()) {
if (flags & MS_REMOUNT)
update_mtab(mnt.mnt_dir, &mnt);
else {
mntFILE *mfp;
lock_mtab();
mfp = my_setmntent(MOUNTED, "a+");
if (mfp == NULL || mfp->mntent_fp == NULL) {
error("mount: can't open %s: %s", MOUNTED, strerror(errno));
} else {
if ((my_addmntent(mfp, &mnt)) == 1)
error("mount: error writing %s: %s", MOUNTED, strerror(errno));
my_endmntent(mfp);
}
unlock_mtab();
}
}
block_signals(SIG_UNBLOCK);
return 0;
}
mnt_err = errno;
if (loop)
del_loop(spec);
block_signals(SIG_UNBLOCK);
/* Mount failed, complain, but don't die. */
if (type == 0)
error("mount: you must specify the filesystem type");
else
switch (mnt_err) {
case EPERM:
if (geteuid() == 0) {
if (stat(node, &statbuf) || !S_ISDIR(statbuf.st_mode))
error("mount: mount point %s is not a directory", node);
else
error("mount: permission denied");
} else
error("mount: must be superuser to use mount");
break;
case EBUSY:
if (flags & MS_REMOUNT) {
error("mount: %s is busy", node);
} else if (!strcmp(type, "proc") && !strcmp(node, "/proc")) {
/* heuristic: if /proc/version exists, then probably proc is mounted */
if (stat("/proc/version", &statbuf)) /* proc mounted? */
error("mount: %s is busy", node); /* no */
else if (!all || mount_verbose) /* yes, don't mention it */
error("mount: proc already mounted");
} else {
error("mount: %s already mounted or %s busy", spec, node);
already(spec, node);
}
break;
case ENOENT:
if (lstat(node, &statbuf))
error("mount: mount point %s does not exist", node);
else if (stat(node, &statbuf))
error("mount: mount point %s is a symbolic link to nowhere", node);
else if (stat(spec, &statbuf))
error("mount: special device %s does not exist", spec);
else {
errno = mnt_err;
perror("mount");
}
break;
case ENOTDIR:
error("mount: mount point %s is not a directory", node);
break;
case EINVAL:
{
int fd, size;
if (flags & MS_REMOUNT) {
error("mount: %s not mounted already, or bad option", node);
} else {
error("mount: wrong fs type, bad option, bad superblock on %s,\n"
" or too many mounted file systems", spec);
if (stat(spec, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)
&& (fd = open(spec, O_RDONLY)) >= 0) {
if (ioctl(fd, BLKGETSIZE, &size) == 0 && size <= 2)
error
(" (aren't you trying to mount an extended partition,\n"
" instead of some logical partition inside?)");
close(fd);
}
}
break;
}
case EMFILE:
error("mount table full");
break;
case EIO:
error("mount: %s: can't read superblock", spec);
break;
case ENODEV:
if (is_in_proc(type) || !strcmp(type, "guess"))
error("mount: %s has wrong major or minor number", spec);
else if (procfs) {
char *lowtype, *p;
int u;
error("mount: fs type %s not supported by kernel", type);
/* maybe this loser asked for FAT or ISO9660 or isofs */
lowtype = xstrdup(type);
u = 0;
for (p = lowtype; *p; p++) {
if (tolower(*p) != *p) {
*p = tolower(*p);
u++;
}
}
if (u && is_in_proc(lowtype))
error("mount: probably you meant %s", lowtype);
else if (!strncmp(lowtype, "iso", 3) && is_in_proc("iso9660"))
error("mount: maybe you meant iso9660 ?");
free(lowtype);
} else
error("mount: %s has wrong device number or fs type %s not supported", spec, type);
break;
case ENOTBLK:
if (stat(spec, &statbuf)) /* strange ... */
error("mount: %s is not a block device, and stat fails?", spec);
else if (S_ISBLK(statbuf.st_mode))
error("mount: the kernel does not recognize %s as a block device\n"
" (maybe `insmod driver'?)", spec);
else if (S_ISREG(statbuf.st_mode))
error("mount: %s is not a block device (maybe try `-o loop'?)", spec);
else
error("mount: %s is not a block device", spec);
break;
case ENXIO:
error("mount: %s is not a valid block device", spec);
break;
case EACCES: /* pre-linux 1.1.38, 1.1.41 and later */
case EROFS: /* linux 1.1.38 and later */
if (added_ro) {
error("mount: block device %s is not permitted on its filesystem", spec);
break;
} else {
added_ro = 1;
if (loop) {
opts = opts0;
type = type0;
}
if (opts) {
opts = realloc(xstrdup(opts), strlen(opts) + 4);
strcat(opts, ",ro");
} else
opts = "ro";
if (type && !strcmp(type, "guess"))
type = 0;
error("mount: %s%s is write-protected, mounting read-only",
loop ? "" : "block device ", spec0);
return try_mount_one(spec0, node0, type, opts, freq, pass, bg);
}
break;
default:
error("mount: %s", strerror(mnt_err));
break;
}
return EX_FAIL;
}
/*
* set_proc_name()
* Update the argument vector, so that this process may be easily
* identified in a "ps" listing.
*/
static void set_proc_name(char *spec)
{
#ifdef DO_PS_FIDDLING
int i, l;
/*
* Move the environment so we can reuse the memory.
* (Code borrowed from sendmail.)
* WARNING: ugly assumptions on memory layout here; if this ever causes
* problems, #undef DO_PS_FIDDLING
*/
for (i = 0; envp0[i] != NULL; i++)
continue;
environ = (char **)xmalloc(sizeof(char *) * (i + 1));
for (i = 0; envp0[i] != NULL; i++)
environ[i] = xstrdup(envp0[i]);
environ[i] = NULL;
if (i > 0)
l = envp0[i - 1] + strlen(envp0[i - 1]) - argv0[0];
else
l = argv0[argc0 - 1] + strlen(argv0[argc0 - 1]) - argv0[0];
if (l > sizeof(PROC_NAME)) {
strcpy(argv0[0], PROC_NAME);
strncpy(argv0[0] + sizeof(PROC_NAME) - 1, spec, l - sizeof(PROC_NAME) - 1);
argv0[1] = NULL;
}
#endif
}
int mount_one(char *spec, char *node, char *type, char *opts, char *cmdlineopts, int freq, int pass)
{
int status;
int status2;
/* Merge the fstab and command line options. */
if (opts == NULL)
opts = cmdlineopts;
else if (cmdlineopts != NULL)
opts = xstrconcat3(opts, ",", cmdlineopts);
if (type == NULL) {
if (strchr(spec, ':') != NULL) {
type = "nfs";
if (mount_verbose)
printf("mount: no type was given - " "I'll assume nfs because of the colon\n");
}
}
/*
* Try to mount the file system. When the exit status is EX_BG,
* we will retry in the background. Otherwise, we're done.
*/
status = try_mount_one(spec, node, type, opts, freq, pass, 0);
if (status != EX_BG)
return status;
/*
* Retry in the background.
*/
printf("mount: backgrounding \"%s\"\n", spec);
fflush(stdout); /* prevent duplicate output */
if (fork() > 0)
return 0; /* parent returns "success" */
spec = xstrdup(spec); /* arguments will be destroyed */
node = xstrdup(node); /* by set_proc_name() */
type = xstrdup(type);
opts = xstrdup(opts);
set_proc_name(spec); /* make a nice "ps" listing */
status2 = try_mount_one(spec, node, type, opts, freq, pass, 1);
if (mount_verbose && status2)
printf("mount: giving up \"%s\"\n", spec);
exit(0); /* child stops here */
}
/* Check if an fsname/dir pair was already in the old mtab. */
static int mounted(char *spec, char *node)
{
struct mntentchn *mc;
spec = canonicalize(spec);
node = canonicalize(node);
for (mc = mtab_head()->nxt; mc; mc = mc->nxt)
if (streq(spec, mc->mnt_fsname) && streq(node, mc->mnt_dir))
return 1;
return 0;
}
/* Mount all filesystems of the specified types except swap and root. */
/* With the --fork option: fork and let different incarnations of
mount handle different filesystems. However, try to avoid several
simultaneous mounts on the same physical disk, since that is very slow. */
#define DISKMAJOR(m) (((int) m) & ~0xf)
static int mount_all(string_list types, char *options)
{
struct mntentchn *mc, *mtmp;
int status = 0;
struct stat statbuf;
struct child {
pid_t pid;
char *group;
struct mntentchn *mec;
struct mntentchn *meclast;
struct child *nxt;
} childhead, *childtail, *cp;
char major[22];
char *g, *colon;
/* build a chain of what we have to do, or maybe
several chains, one for each major or NFS host */
childhead.nxt = 0;
childtail = &childhead;
for (mc = fstab_head()->nxt; mc; mc = mc->nxt) {
if (matching_type(mc->mnt_type, types)
&& !streq(mc->mnt_dir, "/")
&& !streq(mc->mnt_dir, "root")) {
if (mounted(mc->mnt_fsname, mc->mnt_dir)) {
if (mount_verbose)
printf("mount: %s already mounted on %s\n", mc->mnt_fsname, mc->mnt_dir);
} else {
mtmp = (struct mntentchn *)xmalloc(sizeof(*mtmp));
*mtmp = *mc;
mtmp->nxt = 0;
g = NULL;
if (optfork) {
if (stat(mc->mnt_fsname, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
sprintf(major, "#%x", DISKMAJOR(statbuf.st_rdev));
g = major;
}
#if HAVE_NFS
if (strcmp(mc->mnt_type, "nfs") == 0) {
g = xstrdup(mc->mnt_fsname);
colon = strchr(g, ':');
if (colon)
*colon = '\0';
}
#endif
}
if (g) {
for (cp = childhead.nxt; cp; cp = cp->nxt)
if (cp->group && strcmp(cp->group, g) == 0) {
cp->meclast->nxt = mtmp;
cp->meclast = mtmp;
goto fnd;
}
}
cp = (struct child *)xmalloc(sizeof *cp);
cp->nxt = 0;
cp->mec = cp->meclast = mtmp;
cp->group = xstrdup(g);
cp->pid = 0;
childtail->nxt = cp;
childtail = cp;
fnd: ;
}
}
}
/* now do everything */
for (cp = childhead.nxt; cp; cp = cp->nxt) {
pid_t p = -1;
if (optfork) {
p = fork();
if (p == -1)
error("mount: cannot fork: %s", strerror(errno));
else if (p != 0)
cp->pid = p;
}
/* if child, or not forked, do the mounting */
if (p == 0 || p == -1) {
for (mc = cp->mec; mc; mc = mc->nxt)
status |= mount_one(mc->mnt_fsname, mc->mnt_dir,
mc->mnt_type, mc->mnt_opts, options, 0, 0);
if (mountcount)
status |= EX_SOMEOK;
if (p == 0)
exit(status);
}
}
/* wait for children, if any */
while ((cp = childhead.nxt) != NULL) {
childhead.nxt = cp->nxt;
if (cp->pid) {
int ret;
keep_waiting:
if (waitpid(cp->pid, &ret, 0) == -1) {
if (errno == EINTR)
goto keep_waiting;
perror("waitpid");
} else if (WIFEXITED(ret))
status |= WEXITSTATUS(ret);
else
status |= EX_SYSERR;
}
}
if (mountcount)
status |= EX_SOMEOK;
return status;
}
extern char version[];
static struct option longopts[] = {
{"all", 0, 0, 'a'},
{"fake", 0, 0, 'f'},
{"fork", 0, 0, 'F'},
{"help", 0, 0, 'h'},
{"no-mtab", 0, 0, 'n'},
{"read-only", 0, 0, 'r'},
{"ro", 0, 0, 'r'},
{"mount_verbose", 0, 0, 'v'},
{"version", 0, 0, 'V'},
{"read-write", 0, 0, 'w'},
{"rw", 0, 0, 'w'},
{"options", 1, 0, 'o'},
{"types", 1, 0, 't'},
{NULL, 0, 0, 0}
};
const char *mount_usage_string = "\
usage: mount [-hV]\n\
mount -a [-nfFrsvw] [-t vfstypes]\n\
mount [-nfrsvw] [-o options] special | node\n\
mount [-nfrsvw] [-t vfstype] [-o options] special node\n\
";
static void usage(FILE * fp, int n)
{
fprintf(fp, "%s", mount_usage_string);
unlock_mtab();
exit(n);
}
int main_but_defunct(int argc, char *argv[])
{
int c, result = 0;
char *options = NULL, *spec;
string_list types = NULL;
struct mntentchn *mc;
int fd;
/* People report that a mount called from init without console
writes error messages to /etc/mtab
Let us try to avoid getting fd's 0,1,2 */
while ((fd = open("/dev/null", O_RDWR)) == 0 || fd == 1 || fd == 2) ;
if (fd > 2)
close(fd);
#ifdef DO_PS_FIDDLING
argc0 = argc;
argv0 = argv;
envp0 = environ;
#endif
while ((c = getopt_long(argc, argv, "afFhno:rsvVwt:", longopts, NULL))
!= EOF)
switch (c) {
case 'a': /* mount everything in fstab */
++all;
break;
case 'f': /* fake (don't actually do mount(2) call) */
++fake;
break;
case 'F':
++optfork;
break;
case 'h': /* help */
usage(stdout, 0);
break;
case 'n': /* mount without writing in /etc/mtab */
++mount_nomtab;
break;
case 'o': /* specify mount options */
if (options)
options = xstrconcat3(options, ",", optarg);
else
options = xstrdup(optarg);
break;
case 'r': /* mount readonly */
readonly = 1;
readwrite = 0;
break;
case 's': /* allow sloppy mount options */
sloppy = 1;
break;
case 't': /* specify file system types */
types = parse_list(optarg);
break;
case 'v': /* be chatty - very chatty if repeated */
++mount_verbose;
break;
case 'V': /* version */
printf("mount: %s\n", version);
exit(0);
case 'w': /* mount read/write */
readwrite = 1;
readonly = 0;
break;
case 0:
break;
case '?':
default:
usage(stderr, EX_USAGE);
}
argc -= optind;
argv += optind;
if (argc == 0 && !all) {
if (options)
usage(stderr, EX_USAGE);
return print_all(types);
}
if (getuid() != geteuid()) {
mount_suid = 1;
if (types || options || readwrite || mount_nomtab || all || fake || argc != 1)
die(EX_USAGE, "mount: only root can do that");
}
if (!mount_nomtab && mtab_does_not_exist()) {
if (mount_verbose > 1)
printf("mount: no %s found - creating it..\n", MOUNTED);
create_mtab();
}
switch (argc) {
case 0:
/* mount -a */
result = mount_all(types, options);
if (result == 0 && mount_verbose)
error("not mounted anything");
break;
case 1:
/* mount [-nfrvw] [-o options] special | node */
if (types != NULL)
usage(stderr, EX_USAGE);
/* Try to find the other pathname in fstab. */
spec = canonicalize(*argv);
if ((mc = getmntfile(spec)) == NULL &&
(mc = getfsspec(spec)) == NULL && (mc = getfsfile(spec)) == NULL &&
/* Try noncanonical name in fstab
perhaps /dev/cdrom or /dos is a symlink */
(mc = getfsspec(*argv)) == NULL && (mc = getfsfile(*argv)) == NULL)
die(EX_USAGE, "mount: can't find %s in %s or %s", spec, MOUNTED, _PATH_FSTAB);
result = mount_one(xstrdup(mc->mnt_fsname), xstrdup(mc->mnt_dir),
xstrdup(mc->mnt_type), mc->mnt_opts, options, 0, 0);
break;
case 2:
/* mount [-nfrvw] [-t vfstype] [-o options] special node */
if (types == NULL)
result = mount_one(argv[0], argv[1], NULL, NULL, options, 0, 0);
else if (cdr(types) == NULL)
result = mount_one(argv[0], argv[1], car(types), NULL, options, 0, 0);
else
usage(stderr, EX_USAGE);
break;
default:
usage(stderr, EX_USAGE);
}
if (result == EX_SOMEOK)
result = 0;
exit(result);
}
watchdog-5.14.orig/src/Makefile.in 0000644 0000000 0000000 00000051671 12421467317 013745 0 ustar # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
sbin_PROGRAMS = watchdog$(EXEEXT) wd_keepalive$(EXEEXT) \
wd_identify$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)"
PROGRAMS = $(sbin_PROGRAMS)
am_watchdog_OBJECTS = file_stat.$(OBJEXT) file_table.$(OBJEXT) \
fstab.$(OBJEXT) iface.$(OBJEXT) ifdown.$(OBJEXT) \
keep_alive.$(OBJEXT) load.$(OBJEXT) lomount.$(OBJEXT) \
memory.$(OBJEXT) mntent.$(OBJEXT) mount.$(OBJEXT) \
net.$(OBJEXT) nfsmount.$(OBJEXT) nfsmount_clnt.$(OBJEXT) \
nfsmount_xdr.$(OBJEXT) pidfile.$(OBJEXT) shutdown.$(OBJEXT) \
sundries.$(OBJEXT) temp.$(OBJEXT) test_binary.$(OBJEXT) \
umount.$(OBJEXT) version.$(OBJEXT) watchdog.$(OBJEXT) \
logmessage.$(OBJEXT) xmalloc.$(OBJEXT) heartbeat.$(OBJEXT) \
lock_mem.$(OBJEXT) daemon-pid.$(OBJEXT) configfile.$(OBJEXT)
watchdog_OBJECTS = $(am_watchdog_OBJECTS)
watchdog_LDADD = $(LDADD)
am_wd_identify_OBJECTS = wd_identify.$(OBJEXT) logmessage.$(OBJEXT) \
xmalloc.$(OBJEXT) configfile.$(OBJEXT)
wd_identify_OBJECTS = $(am_wd_identify_OBJECTS)
wd_identify_LDADD = $(LDADD)
am_wd_keepalive_OBJECTS = wd_keepalive.$(OBJEXT) logmessage.$(OBJEXT) \
lock_mem.$(OBJEXT) daemon-pid.$(OBJEXT) xmalloc.$(OBJEXT) \
configfile.$(OBJEXT) keep_alive.$(OBJEXT)
wd_keepalive_OBJECTS = $(am_wd_keepalive_OBJECTS)
wd_keepalive_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(watchdog_SOURCES) $(wd_identify_SOURCES) \
$(wd_keepalive_SOURCES)
DIST_SOURCES = $(watchdog_SOURCES) $(wd_identify_SOURCES) \
$(wd_keepalive_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFIG_FILENAME = @CONFIG_FILENAME@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SENDMAIL = @PATH_SENDMAIL@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TESTBIN_PATH = @TESTBIN_PATH@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
watchdog_SOURCES = file_stat.c file_table.c fstab.c iface.c ifdown.c keep_alive.c \
load.c lomount.c memory.c mntent.c mount.c net.c nfsmount.c \
nfsmount_clnt.c nfsmount_xdr.c pidfile.c shutdown.c sundries.c \
temp.c test_binary.c umount.c version.c watchdog.c \
logmessage.c xmalloc.c heartbeat.c lock_mem.c daemon-pid.c configfile.c
wd_keepalive_SOURCES = wd_keepalive.c logmessage.c lock_mem.c daemon-pid.c xmalloc.c \
configfile.c keep_alive.c
wd_identify_SOURCES = wd_identify.c logmessage.c xmalloc.c configfile.c
AM_CPPFLAGS = -I@top_srcdir@/include
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
} \
; done
uninstall-sbinPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(sbindir)" && rm -f $$files
clean-sbinPROGRAMS:
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
watchdog$(EXEEXT): $(watchdog_OBJECTS) $(watchdog_DEPENDENCIES) $(EXTRA_watchdog_DEPENDENCIES)
@rm -f watchdog$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(watchdog_OBJECTS) $(watchdog_LDADD) $(LIBS)
wd_identify$(EXEEXT): $(wd_identify_OBJECTS) $(wd_identify_DEPENDENCIES) $(EXTRA_wd_identify_DEPENDENCIES)
@rm -f wd_identify$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(wd_identify_OBJECTS) $(wd_identify_LDADD) $(LIBS)
wd_keepalive$(EXEEXT): $(wd_keepalive_OBJECTS) $(wd_keepalive_DEPENDENCIES) $(EXTRA_wd_keepalive_DEPENDENCIES)
@rm -f wd_keepalive$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(wd_keepalive_OBJECTS) $(wd_keepalive_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/configfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/daemon-pid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_stat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_table.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/heartbeat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iface.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifdown.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keep_alive.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/load.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lock_mem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logmessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lomount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mntent.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfsmount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfsmount_clnt.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfsmount_xdr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pidfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shutdown.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sundries.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/temp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_binary.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/umount.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watchdog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wd_identify.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wd_keepalive.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(sbindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-sbinPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-sbinPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-sbinPROGRAMS \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-sbinPROGRAMS
distclean-depend:
rm -rf .deps
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
watchdog-5.14.orig/src/shutdown.c 0000644 0000000 0000000 00000030654 12326207324 013707 0 ustar #ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define _XOPEN_SOURCE 500 /* for getsid(2) */
#define _BSD_SOURCE /* for acct(2) */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "watch_err.h"
#include "extern.h"
#if defined __GLIBC__
#include "ext2_mnt.h"
#include
#include
#include
#else /* __GLIBC__ */
#include
#endif /* __GLIBC__ */
#include
#ifndef NSIG
#define NSIG _NSIG
#endif
#ifndef __GLIBC__
#ifndef RB_AUTOBOOT
#define RB_AUTOBOOT 0xfee1dead,672274793,0x01234567 /* Perform a hard reset now. */
#define RB_ENABLE_CAD 0xfee1dead,672274793,0x89abcdef /* Enable reboot using Ctrl-Alt-Delete keystroke. */
#define RB_HALT_SYSTEM 0xfee1dead,672274793,0xcdef0123 /* Halt the system. */
#define RB_POWER_OFF 0xfee1dead,672274793,0x4321fedc /* Stop system and switch power off if possible. */
#endif /*RB_AUTOBOOT*/
#endif /* !__GLIBC__ */
extern void umount_all(void *);
extern int ifdown(void);
#if 0
extern int mount_one(char *, char *, char *, char *, int, int);
static struct mntent rootfs;
#endif
extern volatile sig_atomic_t _running; /* From watchdog.c */
extern int dev_timeout; /* From watchdog.c */
jmp_buf ret2dog;
/* Info about a process. */
typedef struct _proc_ {
pid_t pid; /* Process ID. */
int sid; /* Session ID. */
struct _proc_ *next; /* Pointer to next struct. */
} PROC;
/* A version of sleep() that keeps the watchdog timer alive. */
static void safe_sleep(int nsec)
{
int i;
keep_alive();
for (i=0; imnt_type, MNTTYPE_SWAP))
if (swapoff(mnt->mnt_fsname) < 0)
perror(mnt->mnt_fsname);
/* quota only if mounted at boot time && filesytem=ext2 */
if (hasmntopt(mnt, MNTOPT_NOAUTO) || strcmp(mnt->mnt_type, MNTTYPE_EXT2))
continue;
/* group quota? */
if (hasmntopt(mnt, MNTOPT_GRPQUOTA))
if (quotactl(QCMD(Q_QUOTAOFF, GRPQUOTA), mnt->mnt_fsname, 0, (caddr_t) 0) < 0)
perror(mnt->mnt_fsname);
/* user quota */
if (hasmntopt(mnt, MNTOPT_USRQUOTA))
if (quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), mnt->mnt_fsname, 0, (caddr_t) 0) < 0)
perror(mnt->mnt_fsname);
#if 0
/* not needed anymore */
/* while we're at it we add the remount option */
if (strcmp(mnt->mnt_dir, "/") == 0) {
/* save entry if root partition */
rootfs.mnt_freq = mnt->mnt_freq;
rootfs.mnt_passno = mnt->mnt_passno;
rootfs.mnt_fsname = strdup(mnt->mnt_fsname);
rootfs.mnt_dir = strdup(mnt->mnt_dir);
rootfs.mnt_type = strdup(mnt->mnt_type);
/* did we get enough memory? */
if (rootfs.mnt_fsname == NULL || rootfs.mnt_dir == NULL || rootfs.mnt_type == NULL) {
log_message(LOG_ERR, "out of memory");
}
if ((rootfs.mnt_opts = malloc(strlen(mnt->mnt_opts) + strlen("remount,ro") + 2)) == NULL) {
log_message(LOG_ERR, "out of memory");
} else
sprintf(rootfs.mnt_opts, "%s,remount,ro", mnt->mnt_opts);
}
#endif
}
endmntent(fp);
}
/* Parts of the following two functions are taken from Miquel van */
/* Smoorenburg's killall5 program. */
static PROC *plist;
/* get a list of all processes */
static int readproc()
{
DIR *dir;
struct dirent *d;
pid_t act_pid;
PROC *p;
/* Open the /proc directory. */
if ((dir = opendir("/proc")) == NULL) {
log_message(LOG_ERR, "cannot opendir /proc");
return (-1);
}
/* Don't worry about free'ing the list first, we are going down anyway. */
plist = NULL;
/* Walk through the directory. */
while ((d = readdir(dir)) != NULL) {
/* See if this is a process */
if ((act_pid = atoi(d->d_name)) == 0)
continue;
/*
* Get a PROC struct. If this fails, which is likely if we have an
* out-of-memory error, we return gracefully with what we have managed
* so hopefully a 2nd call after killing some processes will give us more.
*/
if ((p = (PROC *) calloc(1, sizeof(PROC))) == NULL) {
log_message(LOG_ERR, "out of memory");
closedir(dir);
return (-1);
}
p->sid = getsid(act_pid);
p->pid = act_pid;
/* Link it into the list. */
p->next = plist;
plist = p;
}
closedir(dir);
/* Done. */
return (0);
}
static void killall5(int sig)
{
PROC *p;
int sid = -1;
/*
* Ignoring SIGKILL and SIGSTOP do not make sense, but
* someday kill(-1, sig) might kill ourself if we don't
* do this. This certainly is a valid concern for SIGTERM-
* Linux 2.1 might send the calling process the signal too.
*/
/* Since we ignore all signals, we don't have to worry here. MM */
/* Now stop all processes. */
kill(-1, SIGSTOP);
/* Find out our own 'sid'. */
if (readproc() < 0) {
kill(-1, SIGCONT);
return;
}
for (p = plist; p; p = p->next)
if (p->pid == daemon_pid) {
sid = p->sid;
break;
}
/* Now kill all processes except our session. */
for (p = plist; p; p = p->next)
if (p->pid != daemon_pid && /* Skip our process */
p->sid != sid && /* Skip our session */
p->sid != 0) /* Skip any kernel process. */
kill(p->pid, sig);
/* And let them continue. */
kill(-1, SIGCONT);
}
/* shut down the system */
void do_shutdown(int errorcode)
{
int i = 0, fd;
char *seedbck = RANDOM_SEED;
/* soft-boot the system */
/* do not close open files here, they will be closed later anyway */
/* close_all(); */
/* if we will halt the system we should try to tell a sysadmin */
if (admin != NULL) {
/* send mail to the system admin */
FILE *ph;
char exe[128];
struct stat buf;
/* Only can send an email if sendmail binary exists so check
* that first, or else we will get a broken pipe in pclose.
* We cannot let the shell check, because a non-existant or
* non-executable sendmail binary means that the pipe is closed faster
* than we can write to it. */
if ((stat(PATH_SENDMAIL, &buf) != 0) || ((buf.st_mode & S_IXUSR) == 0)) {
log_message(LOG_ERR, "%s does not exist or is not executable (errno = %d)", PATH_SENDMAIL, errno);
} else {
sprintf(exe, "%s -i %s", PATH_SENDMAIL, admin);
ph = popen(exe, "w");
if (ph == NULL) {
log_message(LOG_ERR, "cannot start %s (errno = %d)", PATH_SENDMAIL, errno);
} else {
char myname[MAXHOSTNAMELEN + 1];
struct hostent *hp;
/* get my name */
gethostname(myname, sizeof(myname));
fprintf(ph, "To: %s\n", admin);
if (ferror(ph) != 0) {
log_message(LOG_ERR, "cannot send mail (errno = %d)", errno);
} else {
/* if possible use the full name including domain */
if ((hp = gethostbyname(myname)) != NULL)
fprintf(ph, "Subject: %s is going down!\n\n", hp->h_name);
else
fprintf(ph, "Subject: %s is going down!\n\n", myname);
if (ferror(ph) != 0) {
log_message(LOG_ERR, "cannot send mail (errno = %d)", errno);
} else {
if (errorcode == ETOOHOT)
fprintf(ph,
"Message from watchdog:\nIt is too hot to keep on working. The system will be halted!\n");
else
fprintf(ph,
"Message from watchdog:\nThe system will be rebooted because of error %d!\n", errorcode);
if (ferror(ph) != 0) {
log_message(LOG_ERR, "cannot send mail (errno = %d)", errno);
}
}
}
if (pclose(ph) == -1) {
log_message(LOG_ERR, "cannot finish mail (errno = %d)", errno);
}
/* finally give the system a little bit of time to deliver */
}
}
}
/* now tell syslog what's happening */
log_message(LOG_ALERT, "shutting down the system because of error %d", errorcode);
close_logging();
safe_sleep(10); /* make sure log is written and mail is send */
/* We cannot start shutdown, since init might not be able to fork. */
/* That would stop the reboot process. So we try rebooting the system */
/* ourselves. Note, that it is very likely we cannot start any rc */
/* script either, so we do it all here. */
/* Close all files except the watchdog device. */
for (i = 0; i < 3; i++)
if (!isatty(i))
close(i);
for (i = 3; i < 20; i++)
if (i != get_watchdog_fd())
close(i);
close(255);
/* Ignore all signals. */
for (i = 1; i < NSIG; i++)
signal(i, SIG_IGN);
/* Stop init; it is insensitive to the signals sent by the kernel. */
kill(1, SIGTSTP);
/* Kill all other processes. */
(void)killall5(SIGTERM);
safe_sleep(1);
/* Do this twice in case we have out-of-memory problems. */
(void)killall5(SIGTERM);
safe_sleep(4);
(void)killall5(SIGKILL);
keep_alive();
/* Out-of-memory safeguard again. */
(void)killall5(SIGKILL);
keep_alive();
/* Remove our PID file, as nothing should be capable of starting a 2nd daemon now. */
remove_pid_file();
/* Record the fact that we're going down */
if ((fd = open(_PATH_WTMP, O_WRONLY | O_APPEND)) >= 0) {
time_t t;
struct utmp wtmp;
memset(&wtmp, 0, sizeof(wtmp));
time(&t);
strcpy(wtmp.ut_user, "shutdown");
strcpy(wtmp.ut_line, "~");
strcpy(wtmp.ut_id, "~~");
wtmp.ut_pid = 0;
wtmp.ut_type = RUN_LVL;
wtmp.ut_time = t;
if (write(fd, (char *)&wtmp, sizeof(wtmp)) < 0)
log_message(LOG_ERR, "failed writing wtmp (%s)", strerror(errno));
close(fd);
}
/* save the random seed if a save location exists */
/* don't worry about error messages, we react here anyway */
if (strlen(seedbck) != 0) {
int fd_seed;
if ((fd_seed = open("/dev/urandom", O_RDONLY)) >= 0) {
int fd_bck;
if ((fd_bck = creat(seedbck, S_IRUSR | S_IWUSR)) >= 0) {
char buf[512];
if (read(fd_seed, buf, 512) == 512) {
if (write(fd_bck, buf, 512) < 0)
log_message(LOG_ERR, "failed writing urandom (%s)", strerror(errno));
}
close(fd_bck);
}
close(fd_seed);
}
}
/* Turn off accounting */
if (acct(NULL) < 0)
log_message(LOG_ERR, "failed stopping acct() (%s)", strerror(errno));
keep_alive();
/* Turn off quota and swap */
mnt_off();
/* umount all partitions */
if (setjmp(ret2dog) == 0)
umount_all(NULL);
#if 0
/* with the more recent version of mount code, this is not needed anymore */
/* remount / read-only */
if (setjmp(ret2dog) == 0)
mount_one(rootfs.mnt_fsname, rootfs.mnt_dir, rootfs.mnt_type,
rootfs.mnt_opts, rootfs.mnt_freq, rootfs.mnt_passno);
#endif
/* shut down interfaces (also taken from sysvinit source */
ifdown();
/* finally reboot */
if (errorcode != ETOOHOT) {
if (get_watchdog_fd() != -1) {
/* We have a hardware timer, try using that for a quick reboot first. */
set_watchdog_timeout(1);
sleep(dev_timeout * 4);
}
/* That failed, or was not possible, ask kernel to do it for us. */
reboot(RB_AUTOBOOT);
} else {
if (temp_poweroff) {
/* Tell system to power off if possible. */
reboot(RB_POWER_OFF);
} else {
/* Turn on hard reboot, CTRL-ALT-DEL will reboot now. */
reboot(RB_ENABLE_CAD);
/* And perform the `halt' system call. */
reboot(RB_HALT_SYSTEM);
}
}
/* unbelievable: we're still alive */
panic();
}
watchdog-5.14.orig/src/load.c 0000644 0000000 0000000 00000005561 12233767421 012760 0 ustar /* > load.c
*
* Code for checking the system load averages.
*
* TO DO:
* The 'repair' option possible in the watchdog call must fail as these are averages and
* so take time to drop. Really need some timer before deciding a reboot is the best option.
* For the time being this timer has to be implemented in the repair script.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include "extern.h"
#include "watch_err.h"
static int load_fd = -1;
static const char load_name[] = "/proc/loadavg";
/* ============================================================================ */
int open_loadcheck(void)
{
int rv = -1;
if (maxload1 > 0) {
/* open the load average file */
load_fd = open(load_name, O_RDONLY);
if (load_fd == -1) {
log_message(LOG_ERR, "cannot open %s (errno = %d = '%s')", load_name, errno, strerror(errno));
} else {
rv = 0;
}
}
return rv;
}
/* ============================================================================ */
int check_load(void)
{
int avg1, avg5, avg15;
char buf[40], *ptr;
/* is the load average file open? */
if (load_fd == -1 || maxload1 == 0 || maxload5 == 0 || maxload15 == 0)
return (ENOERR);
/* position pointer at start of file */
if (lseek(load_fd, 0, SEEK_SET) < 0) {
int err = errno;
log_message(LOG_ERR, "lseek %s gave errno = %d = '%s'", load_name, err, strerror(err));
if (softboot)
return (err);
return (ENOERR);
}
/* read the line (there is only one) */
if (read(load_fd, buf, sizeof(buf)) < 0) {
int err = errno;
log_message(LOG_ERR, "read %s gave errno = %d = '%s'", load_name, err, strerror(err));
if (softboot)
return (err);
return (ENOERR);
}
/* we only care about integer values */
avg1 = atoi(buf);
/* if we have incorrect data we might not be able to find */
/* the blanks we're looking for */
ptr = strchr(buf, ' ');
if (ptr != NULL) {
avg5 = atoi(ptr);
ptr = strchr(ptr + 1, ' ');
}
if (ptr != NULL)
avg15 = atoi(ptr);
else {
log_message(LOG_ERR, "%s does not contain any data (read = %s)", load_name, buf);
if (softboot)
return (ENOLOAD);
return (ENOERR);
}
if (verbose && logtick && ticker == 1)
log_message(LOG_INFO, "current load is %d %d %d", avg1, avg5, avg15);
if (avg1 > maxload1 || avg5 > maxload5 || avg15 > maxload15) {
log_message(LOG_ERR, "loadavg %d %d %d is higher than the given threshold %d %d %d!",
avg1, avg5, avg15,
maxload1, maxload5, maxload15);
return (EMAXLOAD);
}
return (ENOERR);
}
/* ============================================================================ */
int close_loadcheck(void)
{
int rv = -1;
if (load_fd != -1 && close(load_fd) == -1) {
log_message(LOG_ALERT, "cannot close %s (errno = %d)", load_name, errno);
} else {
rv = 0;
}
load_fd = -1;
return rv;
}
watchdog-5.14.orig/src/nfsmount_xdr.c 0000644 0000000 0000000 00000016607 12233767421 014572 0 ustar /*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "config.h"
#if HAVE_NFS
#include "nfsmount.h"
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user or with the express written consent of
* Sun Microsystems, Inc.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
/*
* Copyright (c) 1985, 1990 by Sun Microsystems, Inc.
*/
/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */
#include
bool_t xdr_fhandle(XDR * xdrs, fhandle objp)
{
if (!xdr_opaque(xdrs, objp, FHSIZE))
return FALSE;
return TRUE;
}
bool_t xdr_fhandle3(XDR * xdrs, fhandle3 * objp)
{
if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (u_int *) & objp->fhandle3_len, FHSIZE3))
return FALSE;
return TRUE;
}
bool_t xdr_mountstat3(XDR * xdrs, mountstat3 * objp)
{
if (!xdr_enum(xdrs, (enum_t *) objp))
return FALSE;
return TRUE;
}
bool_t xdr_fhstatus(XDR * xdrs, fhstatus * objp)
{
if (!xdr_u_int(xdrs, &objp->fhs_status))
return FALSE;
switch (objp->fhs_status) {
case 0:
if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle))
return FALSE;
break;
default:
break;
}
return TRUE;
}
bool_t xdr_mountres3_ok(XDR * xdrs, mountres3_ok * objp)
{
if (!xdr_fhandle3(xdrs, &objp->fhandle))
return FALSE;
if (!xdr_array
(xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) & objp->auth_flavours.auth_flavours_len,
~0, sizeof(int), (xdrproc_t) xdr_int))
return FALSE;
return TRUE;
}
bool_t xdr_mountres3(XDR * xdrs, mountres3 * objp)
{
if (!xdr_mountstat3(xdrs, &objp->fhs_status))
return FALSE;
switch (objp->fhs_status) {
case MNT_OK:
if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo))
return FALSE;
break;
default:
break;
}
return TRUE;
}
bool_t xdr_dirpath(XDR * xdrs, dirpath * objp)
{
if (!xdr_string(xdrs, objp, MNTPATHLEN))
return FALSE;
return TRUE;
}
bool_t xdr_name(XDR * xdrs, name * objp)
{
if (!xdr_string(xdrs, objp, MNTNAMLEN))
return FALSE;
return TRUE;
}
bool_t xdr_mountlist(XDR * xdrs, mountlist * objp)
{
if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct mountbody), (xdrproc_t) xdr_mountbody))
return FALSE;
return TRUE;
}
bool_t xdr_mountbody(XDR * xdrs, mountbody * objp)
{
if (!xdr_name(xdrs, &objp->ml_hostname))
return FALSE;
if (!xdr_dirpath(xdrs, &objp->ml_directory))
return FALSE;
if (!xdr_mountlist(xdrs, &objp->ml_next))
return FALSE;
return TRUE;
}
bool_t xdr_groups(XDR * xdrs, groups * objp)
{
if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct groupnode), (xdrproc_t) xdr_groupnode))
return FALSE;
return TRUE;
}
bool_t xdr_groupnode(XDR * xdrs, groupnode * objp)
{
if (!xdr_name(xdrs, &objp->gr_name))
return FALSE;
if (!xdr_groups(xdrs, &objp->gr_next))
return FALSE;
return TRUE;
}
bool_t xdr_exports(XDR * xdrs, exports * objp)
{
if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct exportnode), (xdrproc_t) xdr_exportnode))
return FALSE;
return TRUE;
}
bool_t xdr_exportnode(XDR * xdrs, exportnode * objp)
{
if (!xdr_dirpath(xdrs, &objp->ex_dir))
return FALSE;
if (!xdr_groups(xdrs, &objp->ex_groups))
return FALSE;
if (!xdr_exports(xdrs, &objp->ex_next))
return FALSE;
return TRUE;
}
bool_t xdr_ppathcnf(XDR * xdrs, ppathcnf * objp)
{
register int32_t *buf;
int i;
if (xdrs->x_op == XDR_ENCODE) {
/* On many machines XDR_INLINE returns a (long *) */
buf = (int32_t *) XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_int(xdrs, &objp->pc_link_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_max_canon))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_max_input))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_name_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_path_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_pipe_buf))
return FALSE;
} else {
IXDR_PUT_LONG(buf, objp->pc_link_max);
IXDR_PUT_SHORT(buf, objp->pc_max_canon);
IXDR_PUT_SHORT(buf, objp->pc_max_input);
IXDR_PUT_SHORT(buf, objp->pc_name_max);
IXDR_PUT_SHORT(buf, objp->pc_path_max);
IXDR_PUT_SHORT(buf, objp->pc_pipe_buf);
}
if (!xdr_u_char(xdrs, &objp->pc_vdisable))
return FALSE;
if (!xdr_char(xdrs, &objp->pc_xxx))
return FALSE;
buf = (int32_t *) XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t) xdr_short))
return FALSE;
} else {
{
register short *genp;
for (i = 0, genp = objp->pc_mask; i < 2; ++i) {
IXDR_PUT_SHORT(buf, *genp++);
}
}
}
return TRUE;
} else if (xdrs->x_op == XDR_DECODE) {
buf = (int32_t *) XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_int(xdrs, &objp->pc_link_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_max_canon))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_max_input))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_name_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_path_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_pipe_buf))
return FALSE;
} else {
objp->pc_link_max = IXDR_GET_LONG(buf);
objp->pc_max_canon = IXDR_GET_SHORT(buf);
objp->pc_max_input = IXDR_GET_SHORT(buf);
objp->pc_name_max = IXDR_GET_SHORT(buf);
objp->pc_path_max = IXDR_GET_SHORT(buf);
objp->pc_pipe_buf = IXDR_GET_SHORT(buf);
}
if (!xdr_u_char(xdrs, &objp->pc_vdisable))
return FALSE;
if (!xdr_char(xdrs, &objp->pc_xxx))
return FALSE;
buf = (int32_t *) XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t) xdr_short))
return FALSE;
} else {
{
register short *genp;
for (i = 0, genp = objp->pc_mask; i < 2; ++i) {
*genp++ = IXDR_GET_SHORT(buf);
}
}
}
return TRUE;
}
if (!xdr_int(xdrs, &objp->pc_link_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_max_canon))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_max_input))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_name_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_path_max))
return FALSE;
if (!xdr_short(xdrs, &objp->pc_pipe_buf))
return FALSE;
if (!xdr_u_char(xdrs, &objp->pc_vdisable))
return FALSE;
if (!xdr_char(xdrs, &objp->pc_xxx))
return FALSE;
if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t) xdr_short))
return FALSE;
return TRUE;
}
#endif
watchdog-5.14.orig/src/lock_mem.c 0000644 0000000 0000000 00000005634 12233767421 013630 0 ustar /* > lock_mem.c
*
* Common taken from watchdog.c & wd_keepalive.c that locks the process memory, and
* from shutdown.c etc that unlocks it again for a tidy exit.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include /* For OOM_SCORE_ADJ_MIN and OOM_DISABLE */
#include
#include
#include "extern.h"
#if defined(_POSIX_MEMLOCK)
static int mlocked = FALSE;
#endif /* _POSIX_MEMLOCK */
/*
* Function to lock the process and attempt to disable the Out-Of-Memory killer
* that Linux uses so the daemon is not kicked out unexpectedly. Calling arguments
* are:
* do_lock : Set to TRUE if you want to process locked.
* priority: Set to the real-time priority level you want.
* pid: This should be the current process' PID. Either from a call
* to getpid() just for this, or the value already found.
*/
void lock_our_memory(int do_lock, int priority, pid_t pid)
{
int oom_adjusted = 0;
#if defined( OOM_SCORE_ADJ_MIN) || defined( OOM_DISABLE )
FILE *fp = NULL;
struct stat s;
char buf[256];
#endif
#if defined(_POSIX_MEMLOCK)
if (do_lock == TRUE) {
unlock_our_memory();
/* lock all actual and future pages into memory */
if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
log_message(LOG_ERR, "cannot lock realtime memory (errno = %d = '%s')", errno, strerror(errno));
} else {
struct sched_param sp;
/* now set the scheduler */
sp.sched_priority = priority;
if (sched_setscheduler(0, SCHED_RR, &sp) != 0) {
log_message(LOG_ERR, "cannot set scheduler (errno = %d = '%s')", errno, strerror(errno));
} else
mlocked = TRUE;
}
}
#endif /* _POSIX_MEMLOCK */
/* tell oom killer to not kill this process */
if (pid > 0) {
#ifdef OOM_SCORE_ADJ_MIN
snprintf(buf, sizeof(buf), "/proc/%d/oom_score_adj", (int)pid);
if (!oom_adjusted) { /* Or do both ? */
if (!stat(buf, &s)) {
fp = fopen(buf, "w");
if (fp) {
fprintf(fp, "%d\n", OOM_SCORE_ADJ_MIN);
fclose(fp);
oom_adjusted = 1;
}
}
}
#endif /* OOM_SCORE_ADJ_MIN */
#ifdef OOM_DISABLE
snprintf(buf, sizeof(buf), "/proc/%d/oom_adj", (int)pid);
if (!oom_adjusted) { /* Or do both ? */
if (!stat(buf, &s)) {
fp = fopen(buf, "w");
if (fp) {
fprintf(fp, "%d\n", OOM_DISABLE);
fclose(fp);
oom_adjusted = 1;
}
}
}
#endif /* OOM_DISABLE */
if (!oom_adjusted) {
log_message(LOG_WARNING, "unable to disable oom handling!");
}
}
}
/*
* Release the lock on our memory (if used).
*/
void unlock_our_memory(void)
{
#if defined(_POSIX_MEMLOCK)
if (mlocked == TRUE) {
/* unlock all locked pages */
if (munlockall() != 0) {
log_message(LOG_ERR, "cannot unlock realtime memory (errno = %d = '%s')", errno, strerror(errno));
}
mlocked = FALSE;
}
#endif /* _POSIX_MEMLOCK */
}
watchdog-5.14.orig/src/umount.c 0000644 0000000 0000000 00000026611 12233767421 013367 0 ustar /* $Header: /cvsroot/watchdog/watchdog/src/umount.c,v 1.2 2006/07/31 09:39:23 meskes Exp $ */
/*
* A umount(8) for Linux 0.99.
* umount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
*
* Wed Sep 14 22:43:54 1994: Sebastian Lederer
* (lederer@next-pc.informatik.uni-bonn.de) added support for sending an
* unmount RPC call to the server when an NFS-filesystem is unmounted.
*
* Tue Sep 26 16:33:09 1995: Added patches from Greg Page (greg@caldera.com)
* so that NetWare filesystems can be unmounted.
*
* 951213: Marek Michalkiewicz :
* Ignore any RPC errors, so that you can umount an nfs mounted filesystem
* if the server is down.
*
* 960223: aeb - several minor changes
* 960324: aeb - added some changes from Rob Leslie
* 960823: aeb - also try umount(spec) when umount(node) fails
* 970307: aeb - canonise names from fstab
* 970726: aeb - remount read-only in cases where umount fails
*/
#include
#include
#include
#include
#include
#include
#include
#include "mount_constants.h"
#include "sundries.h"
#include "lomount.h"
#include "loop.h"
#include "fstab.h"
#if HAVE_NFS
#include
#include
#include
#include
#include
#include
#include "nfsmount.h"
#include
#endif
#ifdef notyet
/* Nonzero for force umount (-f). This needs kernel support we don't have. */
int force = 0;
#endif
/* When umount fails, attempt a read-only remount (-r). */
int remount = 0;
/* Don't write a entry in /etc/mtab (-n). */
int umount_nomtab = 0;
/* Nonzero for chatty (-v). This is a nonstandard flag (not in BSD). */
int umount_verbose = 0;
/* True if ruid != euid. */
int umount_suid = 0;
#if HAVE_NFS
static int xdr_dir(XDR * xdrsp, char *dirp)
{
return (xdr_string(xdrsp, &dirp, MNTPATHLEN));
}
static int nfs_umount_rpc_call(const char *spec, const char *opts)
{
register CLIENT *clp;
struct sockaddr_in saddr;
struct timeval pertry, try;
enum clnt_stat clnt_stat;
int so = RPC_ANYSOCK;
struct hostent *hostp;
char *hostname;
char *dirname;
char *p;
if (spec == NULL || (p = strchr(spec, ':')) == NULL)
return 0;
hostname = xstrndup(spec, p - spec);
dirname = xstrdup(p + 1);
#ifdef DEBUG
printf("host: %s, directory: %s\n", hostname, dirname);
#endif
if (opts && (p = strstr(opts, "addr="))) {
char *q;
free(hostname);
p += 5;
q = p;
while (*q && *q != ',')
q++;
hostname = xstrndup(p, q - p);
}
if (hostname[0] >= '0' && hostname[0] <= '9')
saddr.sin_addr.s_addr = inet_addr(hostname);
else {
if ((hostp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, "umount: can't get address for %s\n", hostname);
return 1;
}
if (hostp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, "umount: got bad hostp->h_length\n");
hostp->h_length = sizeof(struct in_addr);
}
memcpy(&saddr.sin_addr, hostp->h_addr, hostp->h_length);
}
saddr.sin_family = AF_INET;
saddr.sin_port = 0;
pertry.tv_sec = 3;
pertry.tv_usec = 0;
if ((clp = clntudp_create(&saddr, MOUNTPROG, MOUNTVERS, pertry, &so)) == NULL) {
clnt_pcreateerror("Cannot MOUNTPROG RPC");
return (1);
}
clp->cl_auth = authunix_create_default();
try.tv_sec = 20;
try.tv_usec = 0;
clnt_stat = clnt_call(clp, MOUNTPROC_UMNT,
(xdrproc_t) xdr_dir, dirname, (xdrproc_t) xdr_void, (caddr_t) 0, try);
if (clnt_stat != RPC_SUCCESS) {
clnt_perror(clp, "Bad UMNT RPC");
return (1);
}
auth_destroy(clp->cl_auth);
clnt_destroy(clp);
return (0);
}
#endif /* HAVE_NFS */
/* complain about a failed umount */
static void complain(int err, const char *dev)
{
switch (err) {
case ENXIO:
error("umount: %s: invalid block device", dev);
break;
case EINVAL:
error("umount: %s: not mounted", dev);
break;
case EIO:
error("umount: %s: can't write superblock", dev);
break;
case EBUSY:
/* Let us hope fstab has a line "proc /proc ..."
and not "none /proc ..." */
error("umount: %s: device is busy", dev);
break;
case ENOENT:
error("umount: %s: not found", dev);
break;
case EPERM:
error("umount: %s: must be superuser to umount", dev);
break;
case EACCES:
error("umount: %s: block devices not permitted on fs", dev);
break;
default:
error("umount: %s: %s", dev, strerror(err));
break;
}
}
/* Umount a single device. Return a status code, so don't exit
on a non-fatal error. We lock/unlock around each umount. */
static int umount_one(const char *spec, const char *node, const char *type, const char *opts)
{
int umnt_err, umnt_err2;
int isroot;
int res;
/* Special case for root. As of 0.99pl10 we can (almost) unmount root;
the kernel will remount it readonly so that we can carry on running
afterwards. The readonly remount is illegal if any files are opened
for writing at the time, so we can't update mtab for an unmount of
root. As it is only really a remount, this doesn't matter too
much. [sct May 29, 1993] */
isroot = (streq(node, "/") || streq(node, "root")
|| streq(node, "rootfs"));
if (isroot)
umount_nomtab++;
#if HAVE_NFS
/* Ignore any RPC errors, so that you can umount the filesystem
if the server is down. */
if (strcasecmp(type, "nfs") == 0)
nfs_umount_rpc_call(spec, opts);
#endif
umnt_err = umnt_err2 = 0;
res = umount(node);
if (res < 0) {
umnt_err = errno;
/* A device might have been mounted on a node that has since
been deleted or renamed, so if node fails, also try spec. */
/* if (umnt_err == ENOENT || umnt_err == EINVAL) */
if (umnt_err != EBUSY && strcmp(node, spec)) {
if (umount_verbose)
printf("could not umount %s - trying %s instead\n", node, spec);
res = umount(spec);
if (res < 0)
umnt_err2 = errno;
/* Do not complain about remote NFS mount points */
if (errno == ENOENT && strchr(spec, ':'))
umnt_err2 = 0;
}
}
if (res < 0 && remount && (umnt_err == EBUSY || umnt_err2 == EBUSY)) {
/* Umount failed - let us try a remount */
res = mount(spec, node, NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (res == 0) {
struct mntent remnt;
fprintf(stderr, "umount: %s busy - remounted read-only\n", spec);
remnt.mnt_type = remnt.mnt_fsname = NULL;
remnt.mnt_dir = xstrdup(node);
remnt.mnt_opts = "ro";
update_mtab(node, &remnt);
return 0;
} else if (errno != EBUSY) { /* hmm ... */
perror("remount");
fprintf(stderr, "umount: could not remount %s read-only\n", spec);
}
}
if (res >= 0) {
/* Umount succeeded, update mtab. */
if (umount_verbose)
printf("%s umounted\n", spec);
if (!umount_nomtab && mtab_is_writable()) {
struct mntentchn *mc;
/* Special stuff for loop devices */
if ((mc = getmntfile(spec)) || (mc = getmntfile(node))) {
char *opts;
/* old style mtab line? */
if (streq(mc->mnt_type, "loop"))
if (del_loop(spec))
goto fail;
/* new style mtab line? */
opts = mc->mnt_opts ? xstrdup(mc->mnt_opts) : "";
for (opts = strtok(opts, ","); opts; opts = strtok(NULL, ",")) {
if (!strncmp(opts, "loop=", 5)) {
if (del_loop(opts + 5))
goto fail;
break;
}
}
} else {
/* maybe spec is a loop device? */
/* no del_loop() - just delete it from mtab */
if ((mc = getmntoptfile(spec)) != NULL)
node = mc->mnt_dir;
}
/* Non-loop stuff */
update_mtab(node, NULL);
}
return 0;
}
fail:
/* Umount or del_loop failed, complain, but don't die. */
if (!umount_nomtab) {
/* remove obsolete entry */
if (umnt_err == EINVAL || umnt_err == ENOENT)
update_mtab(node, NULL);
}
if (umnt_err2)
complain(umnt_err2, spec);
if (umnt_err && umnt_err != umnt_err2)
complain(umnt_err, node);
return 1;
}
/* Unmount all filesystems of type VFSTYPES found in mtab. Since we are
concurrently updating mtab after every succesful umount, we have to
slurp in the entire file before we start. This isn't too bad, because
in any case it's important to umount mtab entries in reverse order
to mount, e.g. /usr/spool before /usr. */
int umount_all(string_list types)
{
struct mntentchn *mc, *hd;
int errors = 0;
hd = mtab_head();
if (!hd->prev)
die(2, "umount: cannot find list of filesystems to unmount");
for (mc = hd->prev; mc != hd; mc = mc->prev) {
if (matching_type(mc->mnt_type, types)) {
errors |= umount_one(mc->mnt_fsname, mc->mnt_dir, mc->mnt_type, mc->mnt_opts);
}
}
sync();
return errors;
}
extern char version[];
static struct option longopts[] = {
{"all", 0, 0, 'a'},
{"force", 0, 0, 'f'},
{"help", 0, 0, 'h'},
{"no-mtab", 0, 0, 'n'},
{"umount_verbose", 0, 0, 'v'},
{"version", 0, 0, 'V'},
{"read-only", 0, 0, 'r'},
{"types", 1, 0, 't'},
{NULL, 0, 0, 0}
};
char *umount_usage_string = "\
usage: umount [-hV]\n\
umount -a [-r] [-n] [-v] [-t vfstypes]\n\
umount [-r] [-n] [-v] special | node...\n\
";
static void usage(FILE * fp, int n)
{
fprintf(fp, "%s", umount_usage_string);
exit(n);
}
int umount_mount_quiet = 0;
int this_was_main_int_mount_c(int argc, char *argv[])
{
int c;
int all = 0;
string_list types = NULL;
string_list options;
struct mntentchn *mc, *fs;
char *file;
int result = 0;
while ((c = getopt_long(argc, argv, "afhnrvVt:", longopts, NULL)) != EOF)
switch (c) {
case 'a': /* umount everything */
++all;
break;
case 'f': /* force umount (needs kernel support) */
#if 0
++force;
#else
die(2, "umount: forced umount not supported yet");
#endif
break;
case 'h': /* help */
usage(stdout, 0);
break;
case 'n':
++umount_nomtab;
break;
case 'r': /* remount read-only if umount fails */
++remount;
break;
case 'v': /* make noise */
++umount_verbose;
break;
case 'V': /* version */
printf("umount: %s\n", version);
exit(0);
case 't': /* specify file system type */
types = parse_list(optarg);
break;
case 0:
break;
case '?':
default:
usage(stderr, 1);
}
if (getuid() != geteuid()) {
umount_suid = 1;
if (all || types || umount_nomtab)
die(2, "umount: only root can do that");
}
argc -= optind;
argv += optind;
if (all) {
if (types == NULL)
types = parse_list(xstrdup("noproc"));
result = umount_all(types);
} else if (argc < 1) {
usage(stderr, 2);
} else
while (argc--) {
file = canonicalize(*argv); /* mtab paths are canonicalized */
if (umount_verbose > 1)
printf("Trying to umount %s\n", file);
mc = getmntfile(file);
if (!mc && umount_verbose)
printf("Could not find %s in mtab\n", file);
if (umount_suid) {
if (!mc)
die(2, "umount: %s is not mounted (according to mtab)", file);
if (!(fs = getfsspec(file)) && !(fs = getfsfile(file)))
die(2, "umount: %s is not in the fstab (and you are not root)", file);
if ((!streq(mc->mnt_fsname, fs->mnt_fsname) &&
!streq(mc->mnt_fsname, canonicalize(fs->mnt_fsname)))
|| (!streq(mc->mnt_dir, fs->mnt_dir) &&
!streq(mc->mnt_dir, canonicalize(fs->mnt_dir)))) {
die(2, "umount: %s mount disagrees with the fstab", file);
}
options = parse_list(fs->mnt_opts);
while (options) {
if (streq(car(options), "user"))
break;
options = cdr(options);
}
if (!options)
die(2, "umount: only root can unmount %s from %s", fs->mnt_fsname, fs->mnt_dir);
}
if (mc)
result = umount_one(xstrdup(mc->mnt_fsname), xstrdup(mc->mnt_dir),
xstrdup(mc->mnt_type), xstrdup(mc->mnt_opts));
else
result = umount_one(*argv, *argv, *argv, *argv);
argv++;
}
exit(result);
}
watchdog-5.14.orig/src/pidfile.c 0000644 0000000 0000000 00000003606 12233767421 013453 0 ustar #ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include