From: Eric Blake Date: Mon, 31 Aug 2009 15:00:45 +0000 (-0600) Subject: chown: avoid compilation warning on mingw X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6127191016725b6be0cd65bb10124fd3f69d752;p=pspp chown: avoid compilation warning on mingw * m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown. * lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on mingw. * lib/lchown.c (lchown) [!HAVE_CHOWN]: Likewise. * modules/chown (Depends-on): Add errno. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index fc9a3d2684..2998bb7c71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-08-31 Eric Blake + + chown: avoid compilation warning on mingw + * m4/chown.m4 (gl_FUNC_CHOWN): Recognize missing chown. + * lib/chown.c (rpl_chown) [!HAVE_CHOWN]: Always return failure on + mingw. + * lib/lchown.c (lchown) [!HAVE_CHOWN]: Likewise. + * modules/chown (Depends-on): Add errno. + 2009-08-31 Stefano Lattarini (tiny change) * gnulib-tool: Fix test whether $CONFIG_SHELL has a working 'echo' diff --git a/lib/chown.c b/lib/chown.c index 3582b04d67..cca1d7f3c6 100644 --- a/lib/chown.c +++ b/lib/chown.c @@ -1,7 +1,7 @@ /* provide consistent interface to chown for systems that don't interpret an ID of -1 as meaning `don't change the corresponding ID'. - Copyright (C) 1997, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2004-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +46,8 @@ int rpl_chown (const char *file, uid_t uid, gid_t gid) { -#if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE +#if HAVE_CHOWN +# if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE if (gid == (gid_t) -1 || uid == (uid_t) -1) { struct stat file_stats; @@ -61,9 +62,9 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) if (uid == (uid_t) -1) uid = file_stats.st_uid; } -#endif +# endif -#if CHOWN_MODIFIES_SYMLINK +# if CHOWN_MODIFIES_SYMLINK { /* Handle the case in which the system-supplied chown function does *not* follow symlinks. Instead, it changes permissions @@ -97,7 +98,12 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) else if (errno != EACCES) return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = EOPNOTSUPP; + return -1; +#endif } diff --git a/lib/lchown.c b/lib/lchown.c index 07aef87394..5bc7074f81 100644 --- a/lib/lchown.c +++ b/lib/lchown.c @@ -1,7 +1,7 @@ /* Provide a stub lchown function for systems that lack it. - Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software - Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007, 2009 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,7 +48,8 @@ int lchown (const char *file, uid_t uid, gid_t gid) { -#if ! CHOWN_MODIFIES_SYMLINK +#if HAVE_CHOWN +# if ! CHOWN_MODIFIES_SYMLINK struct stat stats; if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) @@ -56,7 +57,12 @@ lchown (const char *file, uid_t uid, gid_t gid) errno = EOPNOTSUPP; return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = EOPNOTSUPP; + return -1; +#endif } diff --git a/m4/chown.m4 b/m4/chown.m4 index 5d30ae3426..ac76d3fe2b 100644 --- a/m4/chown.m4 +++ b/m4/chown.m4 @@ -1,4 +1,4 @@ -# serial 18 +# serial 19 # Determine whether we need the chown wrapper. dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009 @@ -20,6 +20,7 @@ AC_DEFUN([gl_FUNC_CHOWN], AC_REQUIRE([AC_TYPE_UID_T]) AC_REQUIRE([AC_FUNC_CHOWN]) AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK]) + AC_CHECK_FUNCS_ONCE([chown]) if test $ac_cv_func_chown_works = no; then AC_DEFINE([CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE], [1], diff --git a/modules/chown b/modules/chown index cf9921089b..7cd07f590b 100644 --- a/modules/chown +++ b/modules/chown @@ -7,6 +7,7 @@ lib/fchown-stub.c m4/chown.m4 Depends-on: +errno open unistd sys_stat