Replace futimes with futimens.
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 4 May 2015 17:17:51 +0000 (20:17 +0300)
committerMark Wielaard <mjw@redhat.com>
Tue, 5 May 2015 08:34:13 +0000 (10:34 +0200)
futimes is not standard function, and it's not available in uClibc.
Use futimens which is POSIX.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
src/ChangeLog
src/ar.c
src/strip.c

index 957eeb3..a7cdc3e 100644 (file)
@@ -1,5 +1,13 @@
 2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
 
+       * ar.c (do_oper_extract): Replace struct timeval with struct timespec
+       and futimes with futimens.
+       * strip.c (process_file): Replace struct timeval with struct timespec.
+       (handle_elf, handle_ar): Replace struct timeval with struct timespec
+       in prototype. Replace futimes with futimens.
+
+2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
+
        * addr2line.c (main): Drop mtrace() call and #include <mcheck.h>.
        * ar.c: Likewise.
        * ld.c: Likewise.
index caed7f3..1320d07 100644 (file)
--- a/src/ar.c
+++ b/src/ar.c
@@ -679,13 +679,13 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc,
 
              if (preserve_dates)
                {
-                 struct timeval tv[2];
+                 struct timespec tv[2];
                  tv[0].tv_sec = arhdr->ar_date;
-                 tv[0].tv_usec = 0;
+                 tv[0].tv_nsec = 0;
                  tv[1].tv_sec = arhdr->ar_date;
-                 tv[1].tv_usec = 0;
+                 tv[1].tv_nsec = 0;
 
-                 if (unlikely (futimes (xfd, tv) != 0))
+                 if (unlikely (futimens (xfd, tv) != 0))
                    {
                      error (0, errno,
                             gettext ("cannot change modification time of %s"),
index e81001e..fd3920d 100644 (file)
@@ -109,11 +109,11 @@ static int process_file (const char *fname);
 
 /* Handle one ELF file.  */
 static int handle_elf (int fd, Elf *elf, const char *prefix,
-                      const char *fname, mode_t mode, struct timeval tvp[2]);
+                      const char *fname, mode_t mode, struct timespec tvp[2]);
 
 /* Handle all files contained in the archive.  */
 static int handle_ar (int fd, Elf *elf, const char *prefix, const char *fname,
-                     struct timeval tvp[2]);
+                     struct timespec tvp[2]);
 
 #define INTERNAL_ERROR(fname) \
   error (EXIT_FAILURE, 0, gettext ("%s: INTERNAL ERROR %d (%s): %s"),      \
@@ -302,7 +302,7 @@ process_file (const char *fname)
      now.  We cannot use fstat() after opening the file since the open
      would change the access time.  */
   struct stat64 pre_st;
-  struct timeval tv[2];
+  struct timespec tv[2];
  again:
   if (preserve_dates)
     {
@@ -314,8 +314,8 @@ process_file (const char *fname)
 
       /* If we have to preserve the timestamp, we need it in the
         format utimes() understands.  */
-      TIMESPEC_TO_TIMEVAL (&tv[0], &pre_st.st_atim);
-      TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim);
+      tv[0] = pre_st.st_atim;
+      tv[1] = pre_st.st_mtim;
     }
 
   /* Open the file.  */
@@ -388,7 +388,7 @@ process_file (const char *fname)
 
 static int
 handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
-           mode_t mode, struct timeval tvp[2])
+           mode_t mode, struct timespec tvp[2])
 {
   size_t prefix_len = prefix == NULL ? 0 : strlen (prefix);
   size_t fname_len = strlen (fname) + 1;
@@ -2087,7 +2087,7 @@ while computing checksum for debug information"));
   /* If requested, preserve the timestamp.  */
   if (tvp != NULL)
     {
-      if (futimes (fd, tvp) != 0)
+      if (futimens (fd, tvp) != 0)
        {
          error (0, errno, gettext ("\
 cannot set access and modification date of '%s'"),
@@ -2106,7 +2106,7 @@ cannot set access and modification date of '%s'"),
 
 static int
 handle_ar (int fd, Elf *elf, const char *prefix, const char *fname,
-          struct timeval tvp[2])
+          struct timespec tvp[2])
 {
   size_t prefix_len = prefix == NULL ? 0 : strlen (prefix);
   size_t fname_len = strlen (fname) + 1;
@@ -2144,7 +2144,7 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname,
 
   if (tvp != NULL)
     {
-      if (unlikely (futimes (fd, tvp) != 0))
+      if (unlikely (futimens (fd, tvp) != 0))
        {
          error (0, errno, gettext ("\
 cannot set access and modification date of '%s'"), fname);