Module Name: src
Committed By: apb
Date: Wed Oct 24 21:23:55 UTC 2012
Modified Files:
src/etc/rc.d: cleartmp
Log Message:
Avoid using glob patterns that might match enough files to give
"Arg list too long" errors. Change the "find" command to use
"-exec ... +" instead of "-exec ... \;" to make it more efficient.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/cleartmp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/etc/rc.d/cleartmp
diff -u src/etc/rc.d/cleartmp:1.10 src/etc/rc.d/cleartmp:1.11
--- src/etc/rc.d/cleartmp:1.10 Tue Dec 4 22:09:01 2007
+++ src/etc/rc.d/cleartmp Wed Oct 24 21:23:55 2012
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: cleartmp,v 1.10 2007/12/04 22:09:01 mjf Exp $
+# $NetBSD: cleartmp,v 1.11 2012/10/24 21:23:55 apb Exp $
#
# PROVIDE: cleartmp
@@ -17,11 +17,6 @@ stop_cmd=":"
cleartmp_start()
{
echo "Clearing temporary files."
- #
- # Prune quickly with one rm, then use find to clean up
- # /tmp/[lq]* (this is not needed with mfs /tmp, but
- # doesn't hurt anything).
- #
if checkyesno per_user_tmp && [ -d ${per_user_tmp_dir} ]; then
tmp_dir=${per_user_tmp_dir}
else
@@ -36,9 +31,20 @@ cleartmp_start()
fi
fi
- (cd ${tmp_dir} && rm -rf [a-km-pr-zA-Z]* &&
+ #
+ # Delete almost everything, except lost+found, quota.user,
+ # and quota.group in the top level. (This is not needed
+ # with mfs or tmpfs /tmp, but doesn't hurt anything).
+ #
+ # The find command, with "-exec ... +" instead of "-exec
+ # ... \;", will pass many file or dir names to each
+ # invocation of "rm -rf". We avoid using any glob
+ # patterns because of the risk of "Arg list too long"
+ # errors when there are very many files.
+ #
+ (cd ${tmp_dir} &&
find -x . ! -name . ! -name lost+found ! -name quota.user \
- ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
+ ! -name quota.group -exec rm -rf -- {} \+ -type d -prune)
}
load_rc_config $name