[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: I've rewritten rm (remove.c) to use openat

From: Jim Meyering
Subject: FYI: I've rewritten rm (remove.c) to use openat
Date: Tue, 22 Nov 2005 22:58:54 +0100

I've rewritten rm to use the openat et al functions.
I.e., no more chdir or fchdir.

2005-11-22  Jim Meyering  <address@hidden>

        * src/remove.c: Rewrite.  Now, this module is reentrant on systems
        that provide openat (Solaris), and on systems like Linux+procfs
        where our openat emulation code is reentrant.  This also fixes a
        few low-probability leaks and eliminates some code that could,
        in very unusual circumstances, cause rm() (via a callee) to exit.

Currently, only Solaris provides the required functions in the kernel,
but lib/openat.c now includes an efficient emulation that works
for Linux (assuming PROCFS support).  If your Linux kernel lacks
procfs support or you're using some other system, the emulation
code falls back on using the non-reentrant save_cwd/restore_cwd-
based code.

This is a pretty big change, and will most probably provoke
a test failure or two, due to differing diagnostics on some systems.
All of the tests still do pass on a variety of systems
(Linux 2.6.x, Solaris 9,10, FreeBSD), but many of them
depend on errno values that can easily vary (e.g., EPERM vs EACCES)
and on behavior that is not well standardized.

I've been using it in at the front of my $PATH for more than a week
with no trouble -- but that's not saying much: in my experience,
if it passes the test suite on a decent selection of systems,
my personal usage patterns won't expose any problems.

Here are the diffs:


$ cvs -n diff -u -r1.134 -r1.135 src/remove.c|diffstat
 remove.c |  702 +++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 415 insertions(+), 287 deletions(-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]