From bdb0e5fd6e031f9b3fae95d8180cf6bba32384c8 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 8 Feb 2021 01:50:28 -0600 Subject: Yi-Yo Chiang pointed out install -D was broken when the target file exists. Add a test, with comment that "make install_test" doesn't currently exist... --- lib/lib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index de67efa2..06e39169 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -177,9 +177,11 @@ int mkpathat(int atfd, char *dir, mode_t lastmode, int flags) // not-a-directory along the way, but the last one we must explicitly // test for. Might as well do it up front. - if (!fstatat(atfd, dir, &buf, 0) && !S_ISDIR(buf.st_mode)) { - errno = EEXIST; - return 1; + if (!fstatat(atfd, dir, &buf, 0)) { + if ((flags&MKPATHAT_MKLAST) && !S_ISDIR(buf.st_mode)) { + errno = EEXIST; + return 1; + } else return 0; } for (s = dir; ;s++) { -- cgit v1.2.3