goto out;
}
ret = xrename(tmp_name, name);
+ if (ret < 0)
+ goto out;
+ if (OPT_GIVEN(PRESERVE)) {
+ struct timespec times[2]; /* [0]: atime, [1]: mtime */
+ times[0].tv_nsec = UTIME_OMIT;
+ times[1] = sb.st_mtim;
+ /*
+ * We might well have written a file of identical size. If we
+ * keep the mtime as well, we might fool backup applications
+ * like rsync which skip files whose size and mtime haven't
+ * changed. So we change the mtime slightly.
+ */
+ times[1].tv_sec++;
+ if (futimens(output_fd, times) < 0) {
+ ret = -ERRNO_TO_PARA_ERROR(errno);
+ goto out;
+ }
+ }
out:
if (ret < 0 && output_fd >= 0)
unlink(tmp_name); /* ignore errors */
loglevel = OPT_UINT32_VAL(LOGLEVEL);
version_handle_flag("afh", OPT_GIVEN(VERSION));
handle_help_flags();
- afh_init();
for (i = 0; i < lls_num_inputs(lpr); i++) {
int ret2;
const char *path = lls_input(i, lpr);
PARA_ERROR_LOG("%s\n", errctx);
if (ret < 0)
PARA_EMERG_LOG("%s\n", para_strerror(-ret));
+ lls_free_parse_result(lpr, CMD_PTR);
return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
}