Subject: Adding -f option to mount_lfs(8)
To: None <tech-userlevel@netbsd.org>
From: Juan RP <juan@xtraeme.nopcode.org>
List: tech-userlevel
Date: 03/31/2005 00:50:36
I wanted to give a try to the -f option of lfs_cleanerd(8), but this
option wasn't supported, so I created a simple patch:

Is ok to commit?

Index: mount_lfs.8
===================================================================
RCS file: /cvsroot/src/sbin/mount_lfs/mount_lfs.8,v
retrieving revision 1.13
diff -b -u -r1.13 mount_lfs.8
--- mount_lfs.8 31 Jan 2005 05:19:19 -0000      1.13
+++ mount_lfs.8 30 Mar 2005 22:47:16 -0000
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)mount_lfs.8 8.5 (Berkeley) 3/30/94
 .\"
-.Dd March 30, 1994
+.Dd March 31, 2005
 .Dt MOUNT_LFS 8
 .Os
 .Sh NAME
@@ -71,6 +71,9 @@
 Run
 .Xr lfs_cleanerd 8
 in debug mode.
+.It Fl f
+Instruct the cleaner to use filesystem idle time as the criterion
+for aggressive cleaning, instead of system load.
 .It Fl o
 Options are specified with a
 .Fl o
Index: mount_lfs.c
===================================================================
RCS file: /cvsroot/src/sbin/mount_lfs/mount_lfs.c,v
retrieving revision 1.22
diff -b -u -r1.22 mount_lfs.c
--- mount_lfs.c 9 Feb 2005 14:31:29 -0000       1.22
+++ mount_lfs.c 30 Mar 2005 22:47:16 -0000
@@ -75,7 +75,7 @@
 static void    kill_daemon(char *);
 static void    kill_cleaner(char *);
 
-static int short_rds, cleaner_debug, cleaner_bytes;
+static int short_rds, cleaner_debug, cleaner_bytes, fs_idle;
 static char *nsegs;
 
 #ifndef MOUNT_NOMAIN
@@ -101,7 +101,7 @@
        nsegs = "4";
        mntflags = noclean = 0;
        cleaner_bytes = 1;
-       while ((ch = getopt(argc, argv, "bdN:no:s")) != -1)
+       while ((ch = getopt(argc, argv, "bdfN:no:s")) != -1)
                switch (ch) {
                case 'b':
                        cleaner_bytes = !cleaner_bytes;
@@ -109,6 +109,9 @@
                case 'd':
                        cleaner_debug = 1;
                        break;
+                case 'f':
+                        fs_idle = 1;
+                        break;
                case 'n':
                        noclean = 1;
                        break;
@@ -252,7 +255,7 @@
 static void
 invoke_cleaner(char *name)
 {
-       char *args[6], **ap = args;
+       char *args[7], **ap = args;

        /* Build the argument list. */
        *ap++ = _PATH_LFS_CLEANERD;
@@ -266,6 +269,8 @@
                *ap++ = "-s";
        if (cleaner_debug)
                *ap++ = "-d";
+        if (fs_idle)
+                *ap++ = "-f";
        *ap++ = name;
        *ap = NULL;

@@ -277,7 +282,7 @@
 usage(void)
 {
        (void)fprintf(stderr,
-               "usage: %s [-bdns] [-N nsegs] [-o options] special node\n",
+               "usage: %s [-bdfns] [-N nsegs] [-o options] special node\n",
                getprogname());
        exit(1);
 }