From f9e1039b8b4ba19a2d44414761508f8586c1f443 Mon Sep 17 00:00:00 2001 From: hjp Date: Sun, 4 Jun 2000 16:11:12 +0000 Subject: [PATCH] Added autodetection of /etc/m(nt)?tab. --- ddm/GNUmakefile | 12 ++++++++++-- ddm/cfg/mnttab.sh | 10 ++++++++++ ddm/ddm.c | 17 +++++++++++------ 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 ddm/cfg/mnttab.sh diff --git a/ddm/GNUmakefile b/ddm/GNUmakefile index 79b20fe..c621601 100644 --- a/ddm/GNUmakefile +++ b/ddm/GNUmakefile @@ -1,20 +1,28 @@ -# $Id: GNUmakefile,v 1.1 2000-06-04 15:53:18 hjp Exp $ +# $Id: GNUmakefile,v 1.2 2000-06-04 16:11:12 hjp Exp $ include GNUmakevars ddm: ddm.o $(CC) $^ $(ANTLIB) -o $@ +ddm.o: ddm.c cfg/mnttab.h + clean: rm ddm ddm.o install: $(SBINDIR)/ddm +cfg/%.h: cfg/%.sh + sh $< > $@ + include GNUmakerules -include ddm.d # $Log: GNUmakefile,v $ -# Revision 1.1 2000-06-04 15:53:18 hjp +# Revision 1.2 2000-06-04 16:11:12 hjp +# Added autodetection of /etc/m(nt)?tab. +# +# Revision 1.1 2000/06/04 15:53:18 hjp # Pre-Version. Options are still missing. # diff --git a/ddm/cfg/mnttab.sh b/ddm/cfg/mnttab.sh new file mode 100644 index 0000000..ff19bea --- /dev/null +++ b/ddm/cfg/mnttab.sh @@ -0,0 +1,10 @@ +#!/bin/sh +for i in /etc/mnttab /etc/mtab +do + if [ -f $i ] + then + echo '#define MNTTAB "'$i'"' + exit 0 + fi +done +exit 1 diff --git a/ddm/ddm.c b/ddm/ddm.c index b2d5adc..d9ea8d9 100644 --- a/ddm/ddm.c +++ b/ddm/ddm.c @@ -1,5 +1,5 @@ char ddm_c_rcs_id[] = - "$Id: ddm.c,v 1.1 2000-06-04 15:53:19 hjp Exp $"; + "$Id: ddm.c,v 1.2 2000-06-04 16:11:12 hjp Exp $"; /* * ddm - disk delay monitor * @@ -20,6 +20,8 @@ char ddm_c_rcs_id[] = #include +#include "cfg/mnttab.h" + static double gettimestamp(void) { struct timeval tm; @@ -42,10 +44,10 @@ int main(int argc, char**argv) { /* Get list of directories */ ts = gettimestamp(); - fprintf(stderr, "%s: %.6f: open /etc/mtab\n", argv[0], ts); - if ((mtp = setmntent("/etc/mtab", "r")) == NULL) { - fprintf(stderr, "%s: cannot open /etc/mtab: %s\n", - argv[0], strerror(errno)); + fprintf(stderr, "%s: %.6f: open %s\n", argv[0], MNTTAB, ts); + if ((mtp = setmntent(MNTTAB, "r")) == NULL) { + fprintf(stderr, "%s: cannot open %s: %s\n", + argv[0], MNTTAB, strerror(errno)); exit(1); } for (i = 0;(me = getmntent(mtp)); i++) { @@ -113,7 +115,10 @@ int main(int argc, char**argv) { /* * $Log: ddm.c,v $ - * Revision 1.1 2000-06-04 15:53:19 hjp + * Revision 1.2 2000-06-04 16:11:12 hjp + * Added autodetection of /etc/m(nt)?tab. + * + * Revision 1.1 2000/06/04 15:53:19 hjp * Pre-Version. Options are still missing. * */