From: Paul Eggert Date: Fri, 1 Sep 2023 16:11:32 +0000 (-0700) Subject: chown: port to mingw and MSVC 14 X-Git-Tag: v9.5~175 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74439d15d7f8eae1d942cd96632f4c1c4c9e9e3a;p=thirdparty%2Fcoreutils.git chown: port to mingw and MSVC 14 * src/chown-core.c (restricted_chown): Don’t assume fchown exists. The Gnulib doc says that nowadays this is needed only for ports to mingw and MSVC 14, but it’s an easy port so let’s do it. --- diff --git a/src/chown-core.c b/src/chown-core.c index be86072da3..fd718214f5 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -260,16 +260,11 @@ restricted_chown (int cwd_fd, char const *file, else if ((required_uid == (uid_t) -1 || required_uid == st.st_uid) && (required_gid == (gid_t) -1 || required_gid == st.st_gid)) { +#if HAVE_FCHOWN if (fchown (fd, uid, gid) == 0) - { - status = (close (fd) == 0 - ? RC_ok : RC_error); - return status; - } - else - { - status = RC_error; - } + return close (fd) < 0 ? RC_error : RC_ok; +#endif + status = RC_error; } int saved_errno = errno;