GENERIC make buildkernel error / fails - posix_fadvise
cliftonr at volcano.org
cliftonr at volcano.org
Sun Jan 22 19:00:48 UTC 2012
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 at iandicomputing.com /
cliftonr at volcano.org
Custom programming, network design, systems and network consulting
services
More information about the freebsd-stable
mailing list