X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Futimens.c;h=f7cb8def315cbe306d2c7db5ae0e1a040fae2af9;hb=b65bfcd7ba0be84de3d96f22103103f21679a721;hp=99b22900ddb17e12aa768bb6ede78d994882696a;hpb=1114cbc4eda4c4d13fa48169be60ff2a165507cc;p=gnulib.git diff --git a/lib/utimens.c b/lib/utimens.c index 99b22900d..f7cb8def3 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -1,6 +1,6 @@ /* Set file access and modification times. - Copyright (C) 2003-2010 Free Software Foundation, Inc. + Copyright (C) 2003-2011 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 the @@ -180,18 +180,13 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) if (adjustment_needed < 0) return -1; - /* Require that at least one of FD or FILE are valid. Works around + /* Require that at least one of FD or FILE are potentially valid, to avoid a Linux bug where futimens (AT_FDCWD, NULL) changes "." rather than failing. */ - if (!file) + if (fd < 0 && !file) { - if (fd < 0) - { - errno = EBADF; - return -1; - } - if (dup2 (fd, fd) != fd) - return -1; + errno = EBADF; + return -1; } /* Some Linux-based NFS clients are buggy, and mishandle time stamps @@ -338,7 +333,7 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) # endif if (futimes (fd, t) == 0) { -# if __linux__ && __GLIBC__ && ! HAVE_WORKING_UTIMES +# if __linux__ && __GLIBC__ /* Work around a longstanding glibc bug, still present as of 2010-12-27. On older Linux kernels that lack both utimensat and utimes, glibc's futimes rounds instead of