From 6a71e509c5674becede0c1472bb61b9208263f38 Mon Sep 17 00:00:00 2001 From: David Howells Date: Tue, 9 Jun 2020 14:41:50 +0100 Subject: [PATCH] Improve the debug-mode output of kafs-preload Make "kafs-preload -D" indicate which proc file it would writing cell addition lines to so that it prints: WRITE 'add example.org' TO /proc/fs/afs/cells instead of: add example.org Signed-off-by: David Howells --- src/preload-cells.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/preload-cells.c b/src/preload-cells.c index d0db1c6..bd98806 100644 --- a/src/preload-cells.c +++ b/src/preload-cells.c @@ -110,13 +110,17 @@ int do_preload(const struct kafs_cell_db *db, bool redirect_to_stdout) exit(1); } } else { - fd = 1; + fd = -1; } for (i = 0; i < db->nr_cells; i++) { const struct kafs_cell *cell = db->cells[i]; n = snprintf(buf, sizeof(buf) - 1, "add %s", cell->name); + if (redirect_to_stdout) { + printf("WRITE '%s' TO /proc/fs/afs/cells\n", buf); + continue; + } if (write(fd, buf, n) != n) { if (errno != EEXIST) { _error("Can't add cell '%s': %m", cell->name); @@ -125,9 +129,6 @@ int do_preload(const struct kafs_cell_db *db, bool redirect_to_stdout) verbose("%s: Already exists", cell->name); } - if (redirect_to_stdout) - if (write(1, "\n", 1) == -1) - perror("stdout"); } if (!redirect_to_stdout) { -- 2.49.0