diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-29 19:40:36 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-29 19:40:36 +0100 |
| commit | dcbfaba264df2f9f07e53f77e8178f5bfc7ae88e (patch) | |
| tree | b5dfaa3715ded4f3c9a676b6cf636ad50bf04c9d | |
| parent | bf22475e9552b08feb31d40250ab293d2fd98234 (diff) | |
| download | busybox-w32-dcbfaba264df2f9f07e53f77e8178f5bfc7ae88e.tar.gz busybox-w32-dcbfaba264df2f9f07e53f77e8178f5bfc7ae88e.tar.bz2 busybox-w32-dcbfaba264df2f9f07e53f77e8178f5bfc7ae88e.zip | |
fix improper utimes usage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | archival/bbunzip.c | 8 | ||||
| -rw-r--r-- | archival/libunarchive/data_extract_all.c | 8 | ||||
| -rw-r--r-- | coreutils/touch.c | 12 | ||||
| -rw-r--r-- | libbb/copy_file.c | 8 |
4 files changed, 18 insertions, 18 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 22a0fd189..df674bc6c 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
| @@ -105,15 +105,15 @@ int FAST_FUNC bbunpack(char **argv, | |||
| 105 | if (status >= 0) { | 105 | if (status >= 0) { |
| 106 | /* TODO: restore other things? */ | 106 | /* TODO: restore other things? */ |
| 107 | if (info.mtime) { | 107 | if (info.mtime) { |
| 108 | struct timeval times; | 108 | struct timeval times[2]; |
| 109 | 109 | ||
| 110 | times.tv_sec = info.mtime; | 110 | times[1].tv_sec = times[0].tv_sec = info.mtime; |
| 111 | times.tv_usec = 0; | 111 | times[1].tv_usec = times[0].tv_usec = 0; |
| 112 | /* Note: we closed it first. | 112 | /* Note: we closed it first. |
| 113 | * On some systems calling utimes | 113 | * On some systems calling utimes |
| 114 | * then closing resets the mtime | 114 | * then closing resets the mtime |
| 115 | * back to current time. */ | 115 | * back to current time. */ |
| 116 | utimes(new_name, ×); /* ignoring errors */ | 116 | utimes(new_name, times); /* ignoring errors */ |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | /* Delete _compressed_ file */ | 119 | /* Delete _compressed_ file */ |
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 1100410e6..ae242df64 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
| @@ -148,11 +148,11 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
| 148 | } | 148 | } |
| 149 | /* same for utime */ | 149 | /* same for utime */ |
| 150 | if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { | 150 | if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { |
| 151 | struct timeval t; | 151 | struct timeval t[2]; |
| 152 | 152 | ||
| 153 | t.tv_sec = file_header->mtime; | 153 | t[1].tv_sec = t[0].tv_sec = file_header->mtime; |
| 154 | t.tv_usec = 0; | 154 | t[1].tv_usec = t[0].tv_usec = 0; |
| 155 | utimes(file_header->name, &t); | 155 | utimes(file_header->name, t); |
| 156 | } | 156 | } |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
diff --git a/coreutils/touch.c b/coreutils/touch.c index f670b7f6e..be2d2f925 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
| @@ -54,8 +54,8 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
| 54 | # endif | 54 | # endif |
| 55 | char *reference_file = NULL; | 55 | char *reference_file = NULL; |
| 56 | char *date_str = NULL; | 56 | char *date_str = NULL; |
| 57 | struct timeval timebuf; | 57 | struct timeval timebuf[2]; |
| 58 | timebuf.tv_usec = 0; | 58 | timebuf[1].tv_usec = timebuf[0].tv_usec = 0; |
| 59 | #else | 59 | #else |
| 60 | # define reference_file NULL | 60 | # define reference_file NULL |
| 61 | # define date_str NULL | 61 | # define date_str NULL |
| @@ -84,7 +84,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
| 84 | if (reference_file) { | 84 | if (reference_file) { |
| 85 | struct stat stbuf; | 85 | struct stat stbuf; |
| 86 | xstat(reference_file, &stbuf); | 86 | xstat(reference_file, &stbuf); |
| 87 | timebuf.tv_sec = stbuf.st_mtime; | 87 | timebuf[1].tv_sec = timebuf[0].tv_sec = stbuf.st_mtime; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | if (date_str) { | 90 | if (date_str) { |
| @@ -100,11 +100,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
| 100 | tm_time.tm_isdst = -1; /* Be sure to recheck dst */ | 100 | tm_time.tm_isdst = -1; /* Be sure to recheck dst */ |
| 101 | t = validate_tm_time(date_str, &tm_time); | 101 | t = validate_tm_time(date_str, &tm_time); |
| 102 | 102 | ||
| 103 | timebuf.tv_sec = t; | 103 | timebuf[1].tv_sec = timebuf[0].tv_sec = t; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | do { | 106 | do { |
| 107 | if (utimes(*argv, reference_file ? &timebuf : NULL)) { | 107 | if (utimes(*argv, reference_file ? timebuf : NULL)) { |
| 108 | if (errno == ENOENT) { /* no such file */ | 108 | if (errno == ENOENT) { /* no such file */ |
| 109 | if (opts) { /* creation is disabled, so ignore */ | 109 | if (opts) { /* creation is disabled, so ignore */ |
| 110 | continue; | 110 | continue; |
| @@ -115,7 +115,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
| 115 | ); | 115 | ); |
| 116 | if ((fd >= 0) && !close(fd)) { | 116 | if ((fd >= 0) && !close(fd)) { |
| 117 | if (reference_file) | 117 | if (reference_file) |
| 118 | utimes(*argv, &timebuf); | 118 | utimes(*argv, timebuf); |
| 119 | continue; | 119 | continue; |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index adcfe2111..893b52ed5 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
| @@ -374,12 +374,12 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags) | |||
| 374 | /* Cannot happen: */ | 374 | /* Cannot happen: */ |
| 375 | /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */ | 375 | /* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */ |
| 376 | ) { | 376 | ) { |
| 377 | struct timeval times; | 377 | struct timeval times[2]; |
| 378 | 378 | ||
| 379 | times.tv_sec = source_stat.st_mtime; | 379 | times[1].tv_sec = times[0].tv_sec = source_stat.st_mtime; |
| 380 | times.tv_usec = 0; | 380 | times[1].tv_usec = times[0].tv_usec = 0; |
| 381 | /* BTW, utimes sets usec-precision time - just FYI */ | 381 | /* BTW, utimes sets usec-precision time - just FYI */ |
| 382 | if (utimes(dest, ×) < 0) | 382 | if (utimes(dest, times) < 0) |
| 383 | bb_perror_msg("can't preserve %s of '%s'", "times", dest); | 383 | bb_perror_msg("can't preserve %s of '%s'", "times", dest); |
| 384 | if (chown(dest, source_stat.st_uid, source_stat.st_gid) < 0) { | 384 | if (chown(dest, source_stat.st_uid, source_stat.st_gid) < 0) { |
| 385 | source_stat.st_mode &= ~(S_ISUID | S_ISGID); | 385 | source_stat.st_mode &= ~(S_ISUID | S_ISGID); |
