aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/swclock/swclock.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/swclock/swclock.c b/src/swclock/swclock.c
index e526bd38..83b15c95 100644
--- a/src/swclock/swclock.c
+++ b/src/swclock/swclock.c
@@ -78,14 +78,12 @@ int main(int argc, char **argv)
eerrorx("swclock: Reference file was not specified");
if (sflag) {
- if (stat(file, &sb) == -1) {
- opt = open(file, O_WRONLY | O_CREAT, 0644);
- if (opt == -1)
- eerrorx("swclock: open: %s", strerror(errno));
- close(opt);
- } else
- if (utime(file, NULL) == -1)
- eerrorx("swclock: utime: %s", strerror(errno));
+ int fd = open(file, O_WRONLY | O_CREAT, 0644);
+ if (fd == -1)
+ eerrorx("swclock: open: %s", strerror(errno));
+ if (futimens(fd, NULL) == -1)
+ eerrorx("swclock: futimens: %s", strerror(errno));
+ close(fd);
return 0;
}