From e95314de42d2b0ea47caba02c4ad5d47d5165c77 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 30 Sep 2008 23:13:08 +0000 Subject: [PATCH] HAMMER Utilities: Adjust 'show' defaults. * 'hammer show' now defaults to full verboseness. * -q may now be used to reduce verboseness. --- sbin/hammer/cmd_show.c | 14 +++++++------- sbin/hammer/hammer.8 | 4 +++- sbin/hammer/hammer.c | 16 +++++++++++++--- sbin/hammer/hammer.h | 3 ++- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/sbin/hammer/cmd_show.c b/sbin/hammer/cmd_show.c index 4665e3ed91..b008e837b1 100644 --- a/sbin/hammer/cmd_show.c +++ b/sbin/hammer/cmd_show.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/hammer/cmd_show.c,v 1.16 2008/07/14 03:21:34 dillon Exp $ + * $DragonFly: src/sbin/hammer/cmd_show.c,v 1.17 2008/09/30 23:13:08 dillon Exp $ */ #include "hammer.h" @@ -62,7 +62,7 @@ hammer_cmd_show(hammer_off_t node_offset, int depth, if (node_offset == (hammer_off_t)-1) { volume = get_volume(RootVolNo); node_offset = volume->ondisk->vol0_btree_root; - if (VerboseOpt) { + if (QuietOpt < 3) { printf("Volume header\trecords=%lld next_tid=%016llx\n", volume->ondisk->vol0_stat_records, volume->ondisk->vol0_next_tid); @@ -100,7 +100,7 @@ print_btree_node(hammer_off_t node_offset, int depth, int spike, node_offset, node->count, node->parent, (node->type ? node->type : '?'), depth); printf(" mirror %016llx", node->mirror_tid); - if (VerboseOpt) { + if (QuietOpt < 3) { printf(" fill="); print_bigblock_fill(node_offset); } @@ -178,7 +178,7 @@ print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type, switch(type) { case HAMMER_BTREE_TYPE_INTERNAL: printf("suboff=%016llx", elm->internal.subtree_offset); - if (VerboseOpt) + if (QuietOpt < 3) printf(" mirror %016llx", elm->internal.mirror_tid); break; case HAMMER_BTREE_TYPE_LEAF: @@ -187,12 +187,12 @@ print_btree_elm(hammer_btree_elm_t elm, int i, u_int8_t type, printf("\n\t "); printf("dataoff=%016llx/%d", elm->leaf.data_offset, elm->leaf.data_len); - if (VerboseOpt) { + if (QuietOpt < 3) { printf(" crc=%04x", elm->leaf.data_crc); printf("\n\t fills="); print_bigblock_fill(elm->leaf.data_offset); } - if (VerboseOpt > 1) + if (QuietOpt < 2) print_record(elm); break; } @@ -310,7 +310,7 @@ print_record(hammer_btree_elm_t elm) printf("\n%17s", ""); printf("size=%lld nlinks=%lld", data->inode.size, data->inode.nlinks); - if (VerboseOpt > 2) { + if (QuietOpt < 1) { printf(" mode=%05o uflags=%08x\n", data->inode.mode, data->inode.uflags); diff --git a/sbin/hammer/hammer.8 b/sbin/hammer/hammer.8 index 1ce42ac730..26e5d3378e 100644 --- a/sbin/hammer/hammer.8 +++ b/sbin/hammer/hammer.8 @@ -30,7 +30,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/sbin/hammer/hammer.8,v 1.50 2008/09/30 08:28:59 swildner Exp $ +.\" $DragonFly: src/sbin/hammer/hammer.8,v 1.51 2008/09/30 23:13:08 dillon Exp $ .Dd September 28, 2008 .Dt HAMMER 8 .Os @@ -109,6 +109,8 @@ When maintaining a streaming mirroring this option specifies the minimum delay after a batch ends before the next batch is allowed to start. The default is five seconds. +.It Fl q +Decrease verbosement. May be specified multiple times. .It Fl t Ar seconds When pruning and reblocking you can tell the utility to stop after a certain period of time. This option is used along with the cycle file diff --git a/sbin/hammer/hammer.c b/sbin/hammer/hammer.c index 52f5e9d05e..c8eb09bfbb 100644 --- a/sbin/hammer/hammer.c +++ b/sbin/hammer/hammer.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/hammer/hammer.c,v 1.40 2008/09/28 21:27:56 thomas Exp $ + * $DragonFly: src/sbin/hammer/hammer.c,v 1.41 2008/09/30 23:13:08 dillon Exp $ */ #include "hammer.h" @@ -44,6 +44,7 @@ static void usage(int exit_code); int RecurseOpt; int VerboseOpt; +int QuietOpt; int NoSyncOpt; int TwoWayPipeOpt; int TimeoutOpt; @@ -60,7 +61,7 @@ main(int ac, char **av) u_int32_t status; int ch; - while ((ch = getopt(ac, av, "b:c:dhf:i:rs:t:v2")) != -1) { + while ((ch = getopt(ac, av, "b:c:dhf:i:qrs:t:v2")) != -1) { switch(ch) { case '2': TwoWayPipeOpt = 1; @@ -109,7 +110,16 @@ main(int ac, char **av) TimeoutOpt = strtol(optarg, NULL, 0); break; case 'v': - ++VerboseOpt; + if (QuietOpt > 0) + --QuietOpt; + else + ++VerboseOpt; + break; + case 'q': + if (VerboseOpt > 0) + --VerboseOpt; + else + ++QuietOpt; break; default: usage(1); diff --git a/sbin/hammer/hammer.h b/sbin/hammer/hammer.h index 3c83dbc562..058d161395 100644 --- a/sbin/hammer/hammer.h +++ b/sbin/hammer/hammer.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sbin/hammer/hammer.h,v 1.25 2008/09/20 04:23:21 dillon Exp $ + * $DragonFly: src/sbin/hammer/hammer.h,v 1.26 2008/09/30 23:13:08 dillon Exp $ */ #include @@ -62,6 +62,7 @@ extern int RecurseOpt; extern int VerboseOpt; +extern int QuietOpt; extern int TwoWayPipeOpt; extern int TimeoutOpt; extern int DelayOpt; -- 2.11.4.GIT