diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-30 11:36:14 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-30 11:36:14 +0100 |
commit | d0f9d0ed5867d1ca0fbe96d37f68cfab443e949a (patch) | |
tree | 562627c8466015845f7f41fd72ab3091802559cf | |
parent | 1284774d60ebce68dec6fcaf44a33e928c4c1f82 (diff) | |
download | busybox-w32-d0f9d0ed5867d1ca0fbe96d37f68cfab443e949a.tar.gz busybox-w32-d0f9d0ed5867d1ca0fbe96d37f68cfab443e949a.tar.bz2 busybox-w32-d0f9d0ed5867d1ca0fbe96d37f68cfab443e949a.zip |
touch: needs another fix after last utimes() fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/touch.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c index be2d2f925..3f7b265bd 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
@@ -59,7 +59,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
59 | #else | 59 | #else |
60 | # define reference_file NULL | 60 | # define reference_file NULL |
61 | # define date_str NULL | 61 | # define date_str NULL |
62 | # define timebuf (*(struct timeval*)NULL) | 62 | # define timebuf ((struct timeval*)NULL) |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | #if ENABLE_DESKTOP && ENABLE_LONG_OPTS | 65 | #if ENABLE_DESKTOP && ENABLE_LONG_OPTS |
@@ -104,16 +104,15 @@ int touch_main(int argc UNUSED_PARAM, char **argv) | |||
104 | } | 104 | } |
105 | 105 | ||
106 | do { | 106 | do { |
107 | if (utimes(*argv, reference_file ? timebuf : NULL)) { | 107 | if (utimes(*argv, reference_file ? timebuf : NULL) != 0) { |
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; |
111 | } | 111 | } |
112 | /* Try to create the file. */ | 112 | /* Try to create the file */ |
113 | fd = open(*argv, O_RDWR | O_CREAT, | 113 | fd = open(*argv, O_RDWR | O_CREAT, 0666); |
114 | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | 114 | if (fd >= 0) { |
115 | ); | 115 | xclose(fd); |
116 | if ((fd >= 0) && !close(fd)) { | ||
117 | if (reference_file) | 116 | if (reference_file) |
118 | utimes(*argv, timebuf); | 117 | utimes(*argv, timebuf); |
119 | continue; | 118 | continue; |