Added autodetection of /etc/m(nt)?tab.

This commit is contained in:
hjp 2000-06-04 16:11:12 +00:00
parent cce5d7184c
commit f9e1039b8b
3 changed files with 31 additions and 8 deletions

View File

@ -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 include GNUmakevars
ddm: ddm.o ddm: ddm.o
$(CC) $^ $(ANTLIB) -o $@ $(CC) $^ $(ANTLIB) -o $@
ddm.o: ddm.c cfg/mnttab.h
clean: clean:
rm ddm ddm.o rm ddm ddm.o
install: $(SBINDIR)/ddm install: $(SBINDIR)/ddm
cfg/%.h: cfg/%.sh
sh $< > $@
include GNUmakerules include GNUmakerules
-include ddm.d -include ddm.d
# $Log: GNUmakefile,v $ # $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. # Pre-Version. Options are still missing.
# #

10
ddm/cfg/mnttab.sh Normal file
View File

@ -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

View File

@ -1,5 +1,5 @@
char ddm_c_rcs_id[] = 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 * ddm - disk delay monitor
* *
@ -20,6 +20,8 @@ char ddm_c_rcs_id[] =
#include <ant/da.h> #include <ant/da.h>
#include "cfg/mnttab.h"
static double gettimestamp(void) { static double gettimestamp(void) {
struct timeval tm; struct timeval tm;
@ -42,10 +44,10 @@ int main(int argc, char**argv) {
/* Get list of directories /* Get list of directories
*/ */
ts = gettimestamp(); ts = gettimestamp();
fprintf(stderr, "%s: %.6f: open /etc/mtab\n", argv[0], ts); fprintf(stderr, "%s: %.6f: open %s\n", argv[0], MNTTAB, ts);
if ((mtp = setmntent("/etc/mtab", "r")) == NULL) { if ((mtp = setmntent(MNTTAB, "r")) == NULL) {
fprintf(stderr, "%s: cannot open /etc/mtab: %s\n", fprintf(stderr, "%s: cannot open %s: %s\n",
argv[0], strerror(errno)); argv[0], MNTTAB, strerror(errno));
exit(1); exit(1);
} }
for (i = 0;(me = getmntent(mtp)); i++) { for (i = 0;(me = getmntent(mtp)); i++) {
@ -113,7 +115,10 @@ int main(int argc, char**argv) {
/* /*
* $Log: ddm.c,v $ * $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. * Pre-Version. Options are still missing.
* *
*/ */