diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-11-15 00:12:53 +0100 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-11-15 00:12:53 +0100 |
commit | a307af1af62c51e33e2801d74dbc35560af0fc0e (patch) | |
tree | 8d1164763328f7b580afceda831b979de97b7da7 /coreutils/touch.c | |
parent | cc8b6871a71e42a3e0bdb79e534b90cc3eb4c8e6 (diff) | |
download | busybox-w32-a307af1af62c51e33e2801d74dbc35560af0fc0e.tar.gz busybox-w32-a307af1af62c51e33e2801d74dbc35560af0fc0e.tar.bz2 busybox-w32-a307af1af62c51e33e2801d74dbc35560af0fc0e.zip |
use utimes() rather than obsolescent utime()
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'coreutils/touch.c')
-rw-r--r-- | coreutils/touch.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c index e79092fc1..7d1bf0d9e 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
@@ -49,13 +49,13 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
49 | "date\0" Required_argument "d" | 49 | "date\0" Required_argument "d" |
50 | ; | 50 | ; |
51 | # endif | 51 | # endif |
52 | struct utimbuf timebuf; | 52 | struct timeval timebuf = {.tv_usec = 0}; |
53 | char *reference_file = NULL; | 53 | char *reference_file = NULL; |
54 | char *date_str = NULL; | 54 | char *date_str = NULL; |
55 | #else | 55 | #else |
56 | # define reference_file NULL | 56 | # define reference_file NULL |
57 | # define date_str NULL | 57 | # define date_str NULL |
58 | # define timebuf (*(struct utimbuf*)NULL) | 58 | # define timebuf (*(struct timeval*)NULL) |
59 | #endif | 59 | #endif |
60 | int fd; | 60 | int fd; |
61 | int status = EXIT_SUCCESS; | 61 | int status = EXIT_SUCCESS; |
@@ -83,8 +83,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
83 | if (reference_file) { | 83 | if (reference_file) { |
84 | struct stat stbuf; | 84 | struct stat stbuf; |
85 | xstat(reference_file, &stbuf); | 85 | xstat(reference_file, &stbuf); |
86 | timebuf.actime = stbuf.st_atime; | 86 | timebuf.tv_sec = stbuf.st_mtime; |
87 | timebuf.modtime = stbuf.st_mtime; | ||
88 | } | 87 | } |
89 | 88 | ||
90 | if (date_str) { | 89 | if (date_str) { |
@@ -100,12 +99,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
100 | tm_time.tm_isdst = -1; /* Be sure to recheck dst */ | 99 | tm_time.tm_isdst = -1; /* Be sure to recheck dst */ |
101 | t = validate_tm_time(date_str, &tm_time); | 100 | t = validate_tm_time(date_str, &tm_time); |
102 | 101 | ||
103 | timebuf.actime = t; | 102 | timebuf.tv_sec = t; |
104 | timebuf.modtime = t; | ||
105 | } | 103 | } |
106 | 104 | ||
107 | do { | 105 | do { |
108 | if (utime(*argv, reference_file ? &timebuf : NULL)) { | 106 | if (utimes(*argv, reference_file ? &timebuf : NULL)) { |
109 | if (errno == ENOENT) { /* no such file */ | 107 | if (errno == ENOENT) { /* no such file */ |
110 | if (opts) { /* creation is disabled, so ignore */ | 108 | if (opts) { /* creation is disabled, so ignore */ |
111 | continue; | 109 | continue; |
@@ -116,7 +114,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
116 | ); | 114 | ); |
117 | if ((fd >= 0) && !close(fd)) { | 115 | if ((fd >= 0) && !close(fd)) { |
118 | if (reference_file) | 116 | if (reference_file) |
119 | utime(*argv, &timebuf); | 117 | utimes(*argv, &timebuf); |
120 | continue; | 118 | continue; |
121 | } | 119 | } |
122 | } | 120 | } |