Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jan 2012 13:00:46 -0600
From:      cliftonr@volcano.org
To:        <freebsd-stable@freebsd.org>
Subject:   Re: GENERIC make buildkernel error / fails - posix_fadvise
Message-ID:  <74dee0a775b93db4771f4de96eaf86c2@volcano.org>
In-Reply-To: <4F0F8E6F.8000909@FreeBSD.org>
References:  <20120111161110.4258969c.rpclark@tds.net> <CAN-pd=cPY=Eg1RintaBx6GAon3FsLm-X0h6yvSBxzq=EZ5ukbg@mail.gmail.com> <20120112200843.2a348d2f.rpclark@tds.net> <4F0F8E6F.8000909@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

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.
   -- Clifton

-- 
    Clifton Royston  --  cliftonr@iandicomputing.com / 
cliftonr@volcano.org
  Custom programming, network design, systems and network consulting 
services




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?74dee0a775b93db4771f4de96eaf86c2>