]> www.infradead.org Git - users/dhowells/kafs-client.git/commitdiff
Improve the debug-mode output of kafs-preload
authorDavid Howells <dhowells@redhat.com>
Tue, 9 Jun 2020 13:41:50 +0000 (14:41 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 18 Jun 2020 15:15:40 +0000 (16:15 +0100)
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 <dhowells@redhat.com>
src/preload-cells.c

index d0db1c60793e29c6c057d03c54b3974bc4ab41b6..bd988068f61c861caeab1cf2e4b8a1e48d2d0c7d 100644 (file)
@@ -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) {