From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 86C67138334 for ; Thu, 20 Dec 2018 18:24:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3E274E0ACA; Thu, 20 Dec 2018 18:24:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 13B5AE0ACA for ; Thu, 20 Dec 2018 18:24:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6C3AB335CC8 for ; Thu, 20 Dec 2018 18:24:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BFECB4E4 for ; Thu, 20 Dec 2018 18:24:45 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1545330156.5d274dbc605c72b43c13f8ac61c988eae40531ce.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/xmkdir.c X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 5d274dbc605c72b43c13f8ac61c988eae40531ce X-VCS-Branch: master Date: Thu, 20 Dec 2018 18:24:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2ac1b6b7-01c1-4eb1-93fc-d361bfffd2e5 X-Archives-Hash: 2cf25f9367af8fe799aeb89796de4c89 commit: 5d274dbc605c72b43c13f8ac61c988eae40531ce Author: Fabian Groffen gentoo org> AuthorDate: Thu Dec 20 11:44:41 2018 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Thu Dec 20 18:22:36 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5d274dbc rm_rf_at: remove the object path points to To better emulate 'rm -Rf' behaviour, if path points to a file, just remove it. If it points to a directory, remove that directory instead of leaving the (now) empty directory behind. Signed-off-by: Fabian Groffen gentoo.org> libq/xmkdir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libq/xmkdir.c b/libq/xmkdir.c index 9a120ae..ed30d6d 100644 --- a/libq/xmkdir.c +++ b/libq/xmkdir.c @@ -58,7 +58,7 @@ rm_rf_at(int dfd, const char *path) dir = fdopendir(subdfd); if (!dir) { close(subdfd); - return -1; + return unlinkat(dfd, path, 0); } while ((de = readdir(dir)) != NULL) { @@ -78,6 +78,8 @@ rm_rf_at(int dfd, const char *path) } } + unlinkat(dfd, path, AT_REMOVEDIR); + /* this also does close(subdfd); */ closedir(dir);