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 /coreutils | |
| 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>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/touch.c | 12 |
1 files changed, 6 insertions, 6 deletions
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 | } |
