From: David Howells Date: Tue, 9 Jun 2020 13:41:50 +0000 (+0100) Subject: Improve the debug-mode output of kafs-preload X-Git-Tag: v0.5~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=6a71e509c5674becede0c1472bb61b9208263f38;p=users%2Fdhowells%2Fkafs-client.git 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 --- 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) {