diff options
Diffstat (limited to 'coreutils')
-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 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; } } |