OSDN Git Service

In rm, init using to AT_REMOVEDIR in the dir case earlier.
authorRob Landley <rob@landley.net>
Fri, 6 Feb 2015 23:31:52 +0000 (17:31 -0600)
committerRob Landley <rob@landley.net>
Fri, 6 Feb 2015 23:31:52 +0000 (17:31 -0600)
(If you had a chmod 000 directory and did rm -r on it without -f, after the prompt it would complain it was a directory.)

toys/posix/rm.c

index 7b7916c..5523a98 100644 (file)
@@ -47,13 +47,13 @@ static int do_rm(struct dirtree *try)
 
   // handle directory recursion
   if (dir) {
+    using = AT_REMOVEDIR;
     // Handle chmod 000 directories when -f
     if (faccessat(fd, try->name, R_OK, 0)) {
       if (toys.optflags & FLAG_f) wfchmodat(fd, try->name, 0700);
       else goto skip;
     }
     if (!try->again) return DIRTREE_COMEAGAIN;
-    using = AT_REMOVEDIR;
     if (try->symlink) goto skip;
     if (flags & FLAG_i) {
       char *s = dirtree_path(try, 0);