summaryrefslogtreecommitdiff
path: root/coreutils/touch.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2009-11-15 00:12:53 +0100
committerBernhard Reutner-Fischer2009-11-15 00:12:53 +0100
commita307af1af62c51e33e2801d74dbc35560af0fc0e (patch)
tree8d1164763328f7b580afceda831b979de97b7da7 /coreutils/touch.c
parentcc8b6871a71e42a3e0bdb79e534b90cc3eb4c8e6 (diff)
downloadbusybox-a307af1af62c51e33e2801d74dbc35560af0fc0e.zip
busybox-a307af1af62c51e33e2801d74dbc35560af0fc0e.tar.gz
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.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index e79092f..7d1bf0d 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -49,13 +49,13 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
"date\0" Required_argument "d"
;
# endif
- struct utimbuf timebuf;
+ struct timeval timebuf = {.tv_usec = 0};
char *reference_file = NULL;
char *date_str = NULL;
#else
# define reference_file NULL
# define date_str NULL
-# define timebuf (*(struct utimbuf*)NULL)
+# define timebuf (*(struct timeval*)NULL)
#endif
int fd;
int status = EXIT_SUCCESS;
@@ -83,8 +83,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
if (reference_file) {
struct stat stbuf;
xstat(reference_file, &stbuf);
- timebuf.actime = stbuf.st_atime;
- timebuf.modtime = stbuf.st_mtime;
+ timebuf.tv_sec = stbuf.st_mtime;
}
if (date_str) {
@@ -100,12 +99,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
t = validate_tm_time(date_str, &tm_time);
- timebuf.actime = t;
- timebuf.modtime = t;
+ timebuf.tv_sec = t;
}
do {
- if (utime(*argv, reference_file ? &timebuf : NULL)) {
+ if (utimes(*argv, reference_file ? &timebuf : NULL)) {
if (errno == ENOENT) { /* no such file */
if (opts) { /* creation is disabled, so ignore */
continue;
@@ -116,7 +114,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
);
if ((fd >= 0) && !close(fd)) {
if (reference_file)
- utime(*argv, &timebuf);
+ utimes(*argv, &timebuf);
continue;
}
}