From 8d6a960a9d958c7f474b13802d4e9c7a0efa32c8 Mon Sep 17 00:00:00 2001 From: martijn Date: Thu, 8 Feb 2018 07:00:33 +0000 Subject: [PATCH] Add the order keyword to systat global command interpreter. This command shows the available orderings for the current view, which ordering is active, their shortcuts, and if they're in reverse order. manpage nits jmc@ OK tedu@ --- usr.bin/systat/engine.c | 17 ++++++++++++++++- usr.bin/systat/engine.h | 3 ++- usr.bin/systat/main.c | 32 +++++++++++++++++++++++++++++++- usr.bin/systat/pftop.c | 4 ++-- usr.bin/systat/systat.1 | 11 +++++++++-- 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/usr.bin/systat/engine.c b/usr.bin/systat/engine.c index 64cfc86d334..adaccfe5eb4 100644 --- a/usr.bin/systat/engine.c +++ b/usr.bin/systat/engine.c @@ -1,4 +1,4 @@ -/* $Id: engine.c,v 1.21 2017/04/05 15:57:11 deraadt Exp $ */ +/* $Id: engine.c,v 1.22 2018/02/08 07:00:33 martijn Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * @@ -890,6 +890,21 @@ print_fld_float(field_def *fld, double f, int prec) /* ordering */ +int +foreach_order(void (*callback)(order_type *)) +{ + order_type *o; + + if (curr_view == NULL || curr_view->mgr == NULL || + curr_view->mgr->order_list == NULL) + return -1; + o = curr_view->mgr->order_list; + do { + callback(o++); + } while (o->name != NULL); + return 0; +} + void set_order(const char *opt) { diff --git a/usr.bin/systat/engine.h b/usr.bin/systat/engine.h index 18c9edcb324..b3fabc0cd9c 100644 --- a/usr.bin/systat/engine.h +++ b/usr.bin/systat/engine.h @@ -1,4 +1,4 @@ -/* $Id: engine.h,v 1.8 2013/09/07 11:43:49 reyk Exp $ */ +/* $Id: engine.h,v 1.9 2018/02/08 07:00:33 martijn Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * @@ -130,6 +130,7 @@ int set_view(const char *opt); void next_view(void); void prev_view(void); +int foreach_order(void (*callback)(order_type *)); void set_order(const char *opt); void next_order(void); diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c index 8c850d3329a..3b4bb36195f 100644 --- a/usr.bin/systat/main.c +++ b/usr.bin/systat/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.66 2016/10/13 11:22:46 otto Exp $ */ +/* $Id: main.c,v 1.67 2018/02/08 07:00:33 martijn Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * Copyright (c) 2001 Daniel Hartmeier @@ -250,6 +250,31 @@ show_help(void) message_set(tmp_buf); } +void +add_order_tb(order_type *o) +{ + if (curr_view->mgr->order_curr == o) + tbprintf("[%s%s(%c)] ", o->name, + o->func != NULL && sortdir == -1 ? "^" : "", + (char) o->hotkey); + else + tbprintf("%s(%c) ", o->name, (char) o->hotkey); +} + +void +show_order(void) +{ + if (rawmode) + return; + + tb_start(); + if (foreach_order(add_order_tb) == -1) { + tbprintf("No orders available"); + } + tb_end(); + message_set(tmp_buf); +} + void cmd_compat(const char *buf) { @@ -275,6 +300,11 @@ cmd_compat(const char *buf) cmd_delay(buf + 5); return; } + if (strncasecmp(buf, "order", 5) == 0) { + show_order(); + need_update = 1; + return; + } for (s = buf; *s && strchr("0123456789+-.eE", *s) != NULL; s++) ; diff --git a/usr.bin/systat/pftop.c b/usr.bin/systat/pftop.c index aed29d80659..1420184c58e 100644 --- a/usr.bin/systat/pftop.c +++ b/usr.bin/systat/pftop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pftop.c,v 1.40 2017/07/19 12:58:31 mikeb Exp $ */ +/* $OpenBSD: pftop.c,v 1.41 2018/02/08 07:00:33 martijn Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * Copyright (c) 2001 Daniel Hartmeier @@ -269,7 +269,7 @@ order_type order_list[] = { /* Define view managers */ struct view_manager state_mgr = { "States", select_states, read_states, sort_states, print_header, - print_states, keyboard_callback, order_list, NULL + print_states, keyboard_callback, order_list, order_list }; struct view_manager rule_mgr = { diff --git a/usr.bin/systat/systat.1 b/usr.bin/systat/systat.1 index fd223d3b4de..f3a33ee9b26 100644 --- a/usr.bin/systat/systat.1 +++ b/usr.bin/systat/systat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: systat.1,v 1.102 2017/06/15 03:47:07 dlg Exp $ +.\" $OpenBSD: systat.1,v 1.103 2018/02/08 07:00:33 martijn Exp $ .\" $NetBSD: systat.1,v 1.6 1996/05/10 23:16:39 thorpej Exp $ .\" .\" Copyright (c) 1985, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)systat.1 8.2 (Berkeley) 12/30/93 .\" -.Dd $Mdocdate: June 15 2017 $ +.Dd $Mdocdate: February 8 2018 $ .Dt SYSTAT 1 .Os .Sh NAME @@ -219,6 +219,8 @@ command interpreter. .Bl -tag -width Fl .It Ic help Print the names of the available views on the command line. +.It Ic order +Print the names of the available orderings on the command line. .It Ic quit Quit .Nm . @@ -384,6 +386,11 @@ changes the view to show all of them. Display kernel .Xr pool 9 per CPU cache statistics. +Available orderings are: +.Ic name , +.Ic request , +and +.Ic releases . .It Ic queues Display statistics about the active queues, similar to the output of -- 2.20.1