bin/104044: [patch] rc.d/cleartmp works incorrectly

Yar Tikhiy yar at comp.chem.msu.su
Tue Oct 10 11:41:09 UTC 2006


The following reply was made to PR bin/104044; it has been noted by GNATS.

From: Yar Tikhiy <yar at comp.chem.msu.su>
To: Andrey Simonenko <simon at comsys.ntu-kpi.kiev.ua>
Cc: Florent Thoumie <flz at xbsd.org>, bug-followup at freebsd.org
Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly
Date: Tue, 10 Oct 2006 15:31:35 +0400

 On Tue, Oct 10, 2006 at 02:34:43PM +0400, Yar Tikhiy wrote:
 > 
 > > 2.	Ignore error code from rm and always run find, that is
 > > 	use "rm ... ; find ..." instead of "rm ... && find ...":
 > > 	one can create many files with long names and rm will not
 > > 	be called because of "Argument list too long" error, so
 > > 	find should do all of the work.
 > 
 > By the way, did you consider omitting the first rm at all and just
 > using "find ... -print0 | xargs -0 rm -rf" ?  The first rm can be
 > an optimization as long as we use find with -exec.  OTOH, xargs -0
 > would buy us the same performance and robustness without hacks.
 > Both find and xargs should be available to cleartmp.  Here's the
 > code.  Note "type -d" omitted.
 > 
 > 	if checkyesno ${rcvar1}; then
 > 		# This is not needed with mfs /tmp, but doesn't hurt anything.
 > 		echo "Clearing /tmp."
 > 		find -x /tmp/. ! -name . \
 > 			! \( -name lost+found -type d -user root \) \
 > 			! \( \( -name quota.user -or -name quota.group \) \
 > 				-type f -user root \) \
 > 			-prune -print0 | xargs -0 rm -rf
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 > 	elif ...
 
 It seems we can use just "-delete" here.  If run as root, find
 deletes entries with funny permissions or flags as well as rm does.
 BTW, find will descend into lost+found and delete its contents in
 both cases (rm w/ -prune, or -delete), which is good IMHO.
 
 -- 
 Yar


More information about the freebsd-rc mailing list