From 829497311b541b63e08aa17768c8e67e95b73638 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 5 Sep 2013 04:19:37 -0500 Subject: fix rm to handle "mkdir sub/sub && chmod 007 sub/sub && rm -rf sub". Previous version didn't delete it, but exited without error. Neither was right. --- toys/posix/rm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'toys/posix/rm.c') diff --git a/toys/posix/rm.c b/toys/posix/rm.c index 7954daec..d9ad60d4 100644 --- a/toys/posix/rm.c +++ b/toys/posix/rm.c @@ -47,10 +47,9 @@ static int do_rm(struct dirtree *try) // handle directory recursion if (dir) { - if (try->data != -1) return DIRTREE_COMEAGAIN; using = AT_REMOVEDIR; - if (try->symlink) goto nodelete; + if (try->symlink) goto skip; if (flags & FLAG_i) { char *s = dirtree_path(try, 0); // This is the section 2(d) prompt. (Yes, posix says to prompt twice.) @@ -63,9 +62,9 @@ static int do_rm(struct dirtree *try) skip: if (unlinkat(fd, try->name, using)) { - perror_msg("%s", try->name); + if (!dir || try->symlink != 2) perror_msg("%s", try->name); nodelete: - if (try->parent) try->parent->symlink = (char *)1; + if (try->parent) try->parent->symlink = (char *)2; } return 0; -- cgit v1.2.3