[PATCH] Try to remove the given path even if it can't be opened

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

 



Consider unreadable empty directories. rmdir(2) will remove
them just fine, assuming the parent directory is modifiable.

Noticed by Linus.
Fix suggested by Michael Gruber and Linus.

Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---
Junio C Hamano, Fri, Apr 01, 2011 20:08:36 +0200:
> 
> Please don't do an attachment that has an inline patch and then attach the
> patch itself again in base64.  It is extremely annoying.

Sorry. Hard to notice on GMail.

The extended error information is a little bit tricky: there is at least four
error cases (opendir, stat, unlink and rmdir) and there is a closedir, which
resets errno to output the error in the caller of remove_dir_recursively.

 dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dir.c b/dir.c
index 325fb56..532bcb6 100644
--- a/dir.c
+++ b/dir.c
@@ -1192,7 +1192,7 @@ int remove_dir_recursively(struct strbuf *path, int flag)
 
 	dir = opendir(path->buf);
 	if (!dir)
-		return -1;
+		return rmdir(path->buf);
 	if (path->buf[original_len - 1] != '/')
 		strbuf_addch(path, '/');
 
-- 
1.7.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]