X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Futimens.c;h=f06918cc23e859f02d0c54ba47b4e4ccaf24fcf1;hb=4430dd023d6c2b7b63a87fa62dcc2360c5a34a12;hp=c19041140754714a6ddaa17dbad971d14f90d7d8;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/utimens.c b/lib/utimens.c index c19041140..f06918cc2 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -1,6 +1,6 @@ /* Set file access and modification times. - Copyright (C) 2003-2011 Free Software Foundation, Inc. + Copyright (C) 2003-2012 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 @@ -21,6 +21,7 @@ #include +#define _GL_UTIMENS_INLINE _GL_EXTERN_INLINE #include "utimens.h" #include @@ -180,18 +181,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