Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/etc/rc.d Avoid using glob patterns that might match enough f...
details: https://anonhg.NetBSD.org/src/rev/9f7a9356171c
branches: trunk
changeset: 782267:9f7a9356171c
user: apb <apb%NetBSD.org@localhost>
date: Wed Oct 24 21:23:55 2012 +0000
description:
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.
diffstat:
etc/rc.d/cleartmp | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diffs (46 lines):
diff -r f49fe1757173 -r 9f7a9356171c etc/rc.d/cleartmp
--- a/etc/rc.d/cleartmp Wed Oct 24 21:23:45 2012 +0000
+++ b/etc/rc.d/cleartmp Wed Oct 24 21:23:55 2012 +0000
@@ -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 @@
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 @@
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
Home |
Main Index |
Thread Index |
Old Index