Module Name: src
Committed By: pooka
Date: Thu Jul 29 14:07:39 UTC 2010
Modified Files:
src/libexec/lfs_cleanerd: lfs_cleanerd.c
Log Message:
Add a method for posting a semaphore when cleaner init has reached
the main loop. This is useful for very quickly executed lfs runs
such as those in tests, as an initialization phase cleaner may
prevent file system unmount.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/libexec/lfs_cleanerd/lfs_cleanerd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c
diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.23 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.24
--- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.23 Tue Feb 16 23:13:13 2010
+++ src/libexec/lfs_cleanerd/lfs_cleanerd.c Thu Jul 29 14:07:39 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.23 2010/02/16 23:13:13 mlelstv Exp $ */
+/* $NetBSD: lfs_cleanerd.c,v 1.24 2010/07/29 14:07:39 pooka Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1339,6 +1340,7 @@
{
int i, opt, error, r, loopcount, nodetach;
struct timeval tv;
+ sem_t *semaddr = NULL;
CLEANERINFO ci;
#ifndef USE_CLIENT_SERVER
char *cp, *pidname;
@@ -1358,7 +1360,7 @@
/*
* Parse command-line arguments
*/
- while ((opt = getopt(argc, argv, "bC:cdDfi:l:mn:qr:st:")) != -1) {
+ while ((opt = getopt(argc, argv, "bC:cdDfi:l:mn:qr:sS:t:")) != -1) {
switch (opt) {
case 'b': /* Use bytes written, not segments read */
use_bytes = 1;
@@ -1399,6 +1401,13 @@
case 's': /* Small writes */
do_small = 1;
break;
+ case 'S': /* semaphore */
+#ifndef LFS_CLEANER_AS_LIB
+ usage();
+ /*NOTREACHED*/
+#endif
+ semaddr = (void*)(uintptr_t)strtoull(optarg,NULL,0);
+ break;
case 't': /* timeout */
segwait_timeout = atoi(optarg);
break;
@@ -1530,6 +1539,8 @@
* Main cleaning loop.
*/
loopcount = 0;
+ if (semaddr)
+ sem_post(semaddr);
while (nfss > 0) {
int cleaned_one;
do {