#include "log.h"
#include "util.h"
+#include "macro.h"
#include "mkdir.h"
#include "path-util.h"
#include "strv.h"
i->type != IGNORE_PATH)
return 0;
- if (!i->age_set || i->age <= 0)
+ if (!i->age_set)
return 0;
n = now(CLOCK_REALTIME);
if (i->argument) {
ssize_t n;
size_t l;
- struct iovec iovec[2];
- static const char new_line = '\n';
+ _cleanup_free_ char *unescaped;
- l = strlen(i->argument);
+ unescaped = cunescape(i->argument);
+ if (unescaped == NULL)
+ return log_oom();
- zero(iovec);
- iovec[0].iov_base = i->argument;
- iovec[0].iov_len = l;
+ l = strlen(unescaped);
+ n = write(fd, unescaped, l);
- iovec[1].iov_base = (void*) &new_line;
- iovec[1].iov_len = 1;
-
- n = writev(fd, iovec, 2);
-
- /* It's OK if we don't write the trailing
- * newline, hence we check for l, instead of
- * l+1 here. Files in /sys often refuse
- * writing of the trailing newline. */
if (n < 0 || (size_t) n < l) {
log_error("Failed to write file %s: %s", path, n < 0 ? strerror(-n) : "Short write");
close_nointr_nofail(fd);
return errno == ENOENT ? 0 : -errno;
for (;;) {
- struct dirent buf, *de;
+ struct dirent *de;
+ union dirent_storage buf;
bool is_dir;
int r;
char *entry_path;
- r = readdir_r(d, &buf, &de);
+ r = readdir_r(d, &buf.de, &de);
if (r != 0) {
if (ret == 0)
ret = -r;
case CREATE_FILE:
case TRUNCATE_FILE:
+ r = write_one_file(i, i->path);
+ if (r < 0)
+ return r;
+ break;
case WRITE_FILE:
r = glob_item(i, write_one_file);
if (r < 0)
for (j = optind; j < argc; j++) {
char *fragment;
- fragment = resolve_fragment(argv[j], (const char**) conf_file_dirs);
+ fragment = resolve_fragment(argv[j], (const char **)conf_file_dirs);
if (!fragment) {
log_error("Failed to find a %s file: %m", argv[j]);
r = EXIT_FAILURE;
} else {
char **files, **f;
- r = conf_files_list_strv(&files, ".conf",
- (const char **) conf_file_dirs);
+ r = conf_files_list_strv(&files, ".conf", (const char **)conf_file_dirs);
if (r < 0) {
log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
r = EXIT_FAILURE;