Imported Upstream version 1.7.4
[debian/sudo] / utimes.c
index 17b87b9569db7b58903e21e761335542123639b7..84f4c433cb6d8c7c52dd26b818f9a26b814609b0 100644 (file)
--- a/utimes.c
+++ b/utimes.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2004-2005, 2007 Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <config.h>
+
 #include <sys/types.h>
 #include <sys/time.h>
-#include <time.h>
 #include <stdio.h>
-
-#include "config.h"
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+#endif
 
 #ifdef HAVE_UTIME_H
 # include <utime.h>
@@ -27,9 +29,7 @@
 # include <emul/utime.h>
 #endif
 
-#ifndef lint
-static const char rcsid[] = "$Sudo: utimes.c,v 1.3 2004/09/11 16:24:28 millert Exp $";
-#endif /* lint */
+#include <compat.h>
 
 #ifndef HAVE_UTIMES
 /*
@@ -43,8 +43,8 @@ utimes(file, times)
     if (times != NULL) {
        struct utimbuf utb;
 
-       utb.actime = (time_t)times[0].tv_sec;
-       utb.modtime = (time_t)times[1].tv_sec;
+       utb.actime = (time_t)(times[0].tv_sec + times[0].tv_usec / 1000000);
+       utb.modtime = (time_t)(times[1].tv_sec + times[1].tv_usec / 1000000);
        return(utime(file, &utb));
     } else
        return(utime(file, NULL));
@@ -63,8 +63,8 @@ futimes(fd, times)
     if (times != NULL) {
        struct utimbuf utb;
 
-       utb.actime = (time_t)times[0].tv_sec;
-       utb.modtime = (time_t)times[1].tv_sec;
+       utb.actime = (time_t)(times[0].tv_sec + times[0].tv_usec / 1000000);
+       utb.modtime = (time_t)(times[1].tv_sec + times[1].tv_usec / 1000000);
        return(futime(fd, &utb));
     } else
        return(futime(fd, NULL));