diff options
| author | perseant <perseant@NetBSD.org> | 2000-11-13 22:12:49 +0000 |
|---|---|---|
| committer | perseant <perseant@NetBSD.org> | 2000-11-13 22:12:49 +0000 |
| commit | 9683b76b99eb24dfa80c702e1562ac8138f5eea2 (patch) | |
| tree | cb6cb61b7e7c6e4fdf260f550766fcbfc0b5a38a /libexec | |
| parent | 2311fe3263ba602caf04972a6c382b7f99017c58 (diff) | |
Try to prevent running more than one active cleaner on a filesystem at a time.
Let lfs_cleanerd record its pid in /var/run like other daemons. Make
mount_lfs not start another cleaner when updating the mount, unless it is
being upgraded from read-only to read-write; when downgrading to read-only,
kill the cleaner using the recorded pids.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/lfs_cleanerd/Makefile | 4 | ||||
| -rw-r--r-- | libexec/lfs_cleanerd/cleanerd.c | 32 |
2 files changed, 32 insertions, 4 deletions
diff --git a/libexec/lfs_cleanerd/Makefile b/libexec/lfs_cleanerd/Makefile index 8c51c131856..ff852a030d7 100644 --- a/libexec/lfs_cleanerd/Makefile +++ b/libexec/lfs_cleanerd/Makefile @@ -1,10 +1,12 @@ -# $NetBSD: Makefile,v 1.6 1997/10/22 05:51:29 lukem Exp $ +# $NetBSD: Makefile,v 1.7 2000/11/13 22:12:50 perseant Exp $ # from: @(#)Makefile 8.1 (Berkeley) 6/5/93 PROG= lfs_cleanerd CPPFLAGS+=-I${.CURDIR} -DDIAGNOSTIC MAN= lfs_cleanerd.8 SRCS= cleanerd.c lfs_cksum.c library.c misc.c print.c +LDADD+=-lutil +DPADD+=${LIBUTIL} .PATH: ${.CURDIR}/../../sys/ufs/lfs diff --git a/libexec/lfs_cleanerd/cleanerd.c b/libexec/lfs_cleanerd/cleanerd.c index d78d09409c4..b136197080e 100644 --- a/libexec/lfs_cleanerd/cleanerd.c +++ b/libexec/lfs_cleanerd/cleanerd.c @@ -1,4 +1,4 @@ -/* $NetBSD: cleanerd.c,v 1.24 2000/11/11 22:40:13 perseant Exp $ */ +/* $NetBSD: cleanerd.c,v 1.25 2000/11/13 22:12:50 perseant Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ #if 0 static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95"; #else -__RCSID("$NetBSD: cleanerd.c,v 1.24 2000/11/11 22:40:13 perseant Exp $"); +__RCSID("$NetBSD: cleanerd.c,v 1.25 2000/11/13 22:12:50 perseant Exp $"); #endif #endif /* not lint */ @@ -60,6 +60,7 @@ __RCSID("$NetBSD: cleanerd.c,v 1.24 2000/11/11 22:40:13 perseant Exp $"); #include <string.h> #include <time.h> #include <unistd.h> +#include <util.h> #include <syslog.h> @@ -122,6 +123,7 @@ int clean_segments __P((FS_INFO *, SEGS_AND_BLOCKS *)); unsigned long cost_benefit __P((FS_INFO *, SEGUSE *)); int cost_compare __P((const void *, const void *)); void sig_report __P((int)); +void just_exit __P((int)); int main __P((int, char *[])); /* @@ -191,6 +193,8 @@ main(argc, argv) char *fs_name; /* name of filesystem to clean */ time_t now, lasttime; int loopcount; + char *pidname; /* Name of pid file base */ + char *cp; cmd_err = debug = do_quit = 0; clean_opts = 0; @@ -259,7 +263,22 @@ main(argc, argv) fs_name); exit(1); } - if(childpid != 0) { + if(childpid == 0) { + /* Record child's pid */ + pidname = malloc(strlen(fs_name) + 16); + sprintf(pidname, "lfs_cleanerd:s:%s", fs_name); + while((cp = strchr(pidname, '/')) != NULL) + *cp = '|'; + pidfile(pidname); + } else { + /* Record parent's pid */ + pidname = malloc(strlen(fs_name) + 16); + sprintf(pidname, "lfs_cleanerd:m:%s", fs_name); + while((cp = strchr(pidname, '/')) != NULL) + *cp = '|'; + pidfile(pidname); + signal(SIGINT, just_exit); + wait(NULL); /* If the child is looping, give up */ ++loopcount; @@ -932,3 +951,10 @@ sig_report(sig) if (sig == SIGINT) exit(0); } + +void +just_exit(sig) + int sig; +{ + exit(0); +} |
