From owner-freebsd-rc@FreeBSD.ORG Mon Oct 16 13:19:09 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7169416A47C for ; Mon, 16 Oct 2006 13:19:09 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23DD843D6D for ; Mon, 16 Oct 2006 13:18:41 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k9GDIeq1052638 for ; Mon, 16 Oct 2006 17:18:40 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k9GDIeps052637 for freebsd-rc@freebsd.org; Mon, 16 Oct 2006 17:18:40 +0400 (MSD) (envelope-from yar) Date: Mon, 16 Oct 2006 17:18:39 +0400 From: Yar Tikhiy To: freebsd-rc@freebsd.org Message-ID: <20061016131839.GC49925@comp.chem.msu.su> References: <200610121040.k9CAeLB8080084@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200610121040.k9CAeLB8080084@freefall.freebsd.org> User-Agent: Mutt/1.5.9i Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Oct 2006 13:19:09 -0000 On Thu, Oct 12, 2006 at 10:40:21AM +0000, Andrey Simonenko wrote: > The following reply was made to PR bin/104044; it has been noted by GNATS. > > From: Andrey Simonenko > To: Yar Tikhiy > Cc: Florent Thoumie , bug-followup@freebsd.org > Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly > Date: Thu, 12 Oct 2006 13:36:29 +0300 > > On Tue, Oct 10, 2006 at 03:31:35PM +0400, Yar Tikhiy wrote: > > 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. JFTR: Using -delete was a stupid idea of mine. If we want to preserve lost+found and quota.* _only_ in /tmp itself, then we have to use "-prune -exec". The committed version doesn't use -delete. -- Yar