HAMMER Utilities: Adjust 'show' defaults.
authorMatthew Dillon <dillon@dragonflybsd.org>
Tue, 30 Sep 2008 23:13:08 +0000 (23:13 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Tue, 30 Sep 2008 23:13:08 +0000 (23:13 +0000)
* 'hammer show' now defaults to full verboseness.

* -q may now be used to reduce verboseness.

sbin/hammer/cmd_show.c
sbin/hammer/hammer.8
sbin/hammer/hammer.c
sbin/hammer/hammer.h

index 4665e3e..b008e83 100644 (file)
@@ -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);
index 1ce42ac..26e5d33 100644 (file)
@@ -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
index 52f5e9d..c8eb09b 100644 (file)
@@ -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);
index 3c83dbc..058d161 100644 (file)
@@ -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 <sys/types.h>
@@ -62,6 +62,7 @@
 
 extern int RecurseOpt;
 extern int VerboseOpt;
+extern int QuietOpt;
 extern int TwoWayPipeOpt;
 extern int TimeoutOpt;
 extern int DelayOpt;