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
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.
#

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[] =
"$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 <ant/da.h>
#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.
*
*/