From owner-freebsd-stable@FreeBSD.ORG Sun Jan 22 20:45:12 2012 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C79DF1065672 for ; Sun, 22 Jan 2012 20:45:12 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 57E098FC0A for ; Sun, 22 Jan 2012 20:45:12 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 0A5C91DDA94; Sun, 22 Jan 2012 21:45:11 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id DA32828468; Sun, 22 Jan 2012 21:45:10 +0100 (CET) Date: Sun, 22 Jan 2012 21:45:10 +0100 From: Jilles Tjoelker To: cliftonr@volcano.org Message-ID: <20120122204510.GA33235@stack.nl> References: <20120111161110.4258969c.rpclark@tds.net> <20120112200843.2a348d2f.rpclark@tds.net> <4F0F8E6F.8000909@FreeBSD.org> <74dee0a775b93db4771f4de96eaf86c2@volcano.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74dee0a775b93db4771f4de96eaf86c2@volcano.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-stable@freebsd.org Subject: Re: GENERIC make buildkernel error / fails - posix_fadvise X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jan 2012 20:45:12 -0000 On Sun, Jan 22, 2012 at 01:00:46PM -0600, cliftonr@volcano.org wrote: > On 12.01.2012 15:52, Doug Barton wrote: > >>> chflags -R noschg /usr/obj/usr > >>> rm -rf /usr/obj/usr > > It's much faster to do: > > /bin/rm -rf ${obj}/* 2> /dev/null || /bin/chflags -R 0 ${obj}/* && > > /bin/rm -rf ${obj}/* > If I could just add one thing here, for those who might be tempted > to immediately cut and paste that elegant command line: > Consider, how does that command evaluate if the shell variable "obj" > is not set, and you're running that literal string as root? > A: You will very systematically wipe your entire server, starting > at the root, and doing a second pass to get any protected files you > missed. > I'd recommend something safer like approximately this (untested): > if ["X${obj}" != "X" -a -d ${obj}]; then cd ${obj} && (rest of cmds); > fi > Sorry for the wasted bandwidth, for those to whom it was obvious, > but anybody who has ever had to clean up after a junior admin's > attempt to do something a little too clever will appreciate why I'm > posting this. An easier way is to replace the first ${obj} with ${obj:?}, causing an error if obj is unset or null. One limitation is that it does not work with (t)csh. > On the efficiency front, for the core file deletion operators, I've > had good results with this trick (requires Perl and makes use of > its implicit-operand idioms): > find ${obj} | perl -nle unlink > If rm had an option to take files from standard input, or if > there's another program I'm not aware of which does this, it > could serve as the right-hand side of this. This does not handle all possible characters in filenames, such as a newline. The perlrun manpage suggests something with find's -print0 primary. Alternatively, use find's -unlink primary. -- Jilles Tjoelker