From 487c50c1e73e3c64ce35ed52e48f6e1c9dc50ae8 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 30 Oct 2012 11:50:42 +0100 Subject: [PATCH] ntdll: Remove futimes implementation from libport, it's only needed in ntdll. --- dlls/ntdll/file.c | 16 ++++++++++-- include/wine/port.h | 6 ----- libs/port/Makefile.in | 1 - libs/port/futimes.c | 58 ------------------------------------------- 4 files changed, 14 insertions(+), 67 deletions(-) delete mode 100644 libs/port/futimes.c diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 5f5e7fe044..61ed576369 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -1560,6 +1560,9 @@ NTSTATUS WINAPI NtSetVolumeInformationFile( static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_INTEGER *atime ) { + NTSTATUS status = STATUS_SUCCESS; + +#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT) struct timeval tv[2]; struct stat st; @@ -1590,8 +1593,17 @@ static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_ tv[1].tv_sec = mtime->QuadPart / 10000000 - SECS_1601_TO_1970; tv[1].tv_usec = (mtime->QuadPart % 10000000) / 10; } - if (!futimes( fd, tv )) return STATUS_SUCCESS; - return FILE_GetNtStatus(); +#ifdef HAVE_FUTIMES + if (futimes( fd, tv ) == -1) status = FILE_GetNtStatus(); +#elif defined(HAVE_FUTIMESAT) + if (futimesat( fd, NULL, tv ) == -1) status = FILE_GetNtStatus(); +#endif + +#else /* HAVE_FUTIMES || HAVE_FUTIMESAT */ + FIXME( "setting file times not supported\n" ); + status = STATUS_NOT_IMPLEMENTED; +#endif + return status; } static inline void get_file_times( const struct stat *st, LARGE_INTEGER *mtime, LARGE_INTEGER *ctime, diff --git a/include/wine/port.h b/include/wine/port.h index 9030aab14b..9a9bb8819c 100644 --- a/include/wine/port.h +++ b/include/wine/port.h @@ -257,11 +257,6 @@ extern int getopt_long_only (int ___argc, char *const *___argv, int ffs( int x ); #endif -#ifndef HAVE_FUTIMES -struct timeval; -int futimes(int fd, const struct timeval *tv); -#endif - #ifndef HAVE_GETPAGESIZE size_t getpagesize(void); #endif /* HAVE_GETPAGESIZE */ @@ -456,7 +451,6 @@ extern unsigned char interlocked_cmpxchg128( __int64 *dest, __int64 xchg_high, #define ffs __WINE_NOT_PORTABLE(ffs) #define fstatvfs __WINE_NOT_PORTABLE(fstatvfs) -#define futimes __WINE_NOT_PORTABLE(futimes) #define getopt_long __WINE_NOT_PORTABLE(getopt_long) #define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only) #define getpagesize __WINE_NOT_PORTABLE(getpagesize) diff --git a/libs/port/Makefile.in b/libs/port/Makefile.in index f2f6db0443..71074b265a 100644 --- a/libs/port/Makefile.in +++ b/libs/port/Makefile.in @@ -5,7 +5,6 @@ MODULE = libwine_port.a C_SRCS = \ ffs.c \ fstatvfs.c \ - futimes.c \ getopt.c \ getopt1.c \ getpagesize.c \ diff --git a/libs/port/futimes.c b/libs/port/futimes.c deleted file mode 100644 index f842d67b55..0000000000 --- a/libs/port/futimes.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * futimes function - * - * Copyright 2004 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "config.h" -#include "wine/port.h" - -#ifndef HAVE_FUTIMES - -#include -#ifdef HAVE_SYS_TIME_H -# include -#endif -#ifdef HAVE_UTIME_H -# include -#endif -#include -#include - -int futimes(int fd, const struct timeval tv[2]) -{ -#ifdef linux - char buffer[sizeof("/proc/self/fd/") + 3*sizeof(int)]; - - sprintf( buffer, "/proc/self/fd/%u", fd ); - if (tv) - { - struct utimbuf ut; - ut.actime = tv[0].tv_sec + (tv[0].tv_usec + 500000) / 1000000; - ut.modtime = tv[1].tv_sec + (tv[1].tv_usec + 500000) / 1000000; - return utime( buffer, &ut ); - } - else return utime( buffer, NULL ); -#elif defined(HAVE_FUTIMESAT) - return futimesat( fd, NULL, tv ); -#else - errno = ENOSYS; - return -1; -#endif -} - -#endif /* HAVE_FUTIMES */