# HG changeset patch # User Eric Blake # Date 1251730845 21600 # Node ID 79f4b013feab76a082154cc288e969c962d28cf9 # Parent 6a1268d2cf2abf428094f94d93b11735ffee740a 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 --- 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 --- 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 @@ 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 @@ 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 --- 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 @@ 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 --- 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_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 --- a/modules/chown +++ b/modules/chown @@ -7,6 +7,7 @@ m4/chown.m4 Depends-on: +errno open unistd sys_stat