mpsutil.c (286180) | mpsutil.c (289364) |
---|---|
1/*- 2 * Copyright (c) 2008 Yahoo!, Inc. 3 * All rights reserved. 4 * Written by: John Baldwin <jhb@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 15 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Yahoo!, Inc. 3 * All rights reserved. 4 * Written by: John Baldwin <jhb@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 15 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__RCSID("$FreeBSD: projects/mpsutil/usr.sbin/mpsutil/mpsutil.c 286180 2015-08-02 03:52:51Z scottl $"); | 32__RCSID("$FreeBSD: projects/mpsutil/usr.sbin/mpsutil/mpsutil.c 289364 2015-10-15 15:19:38Z bapt $"); |
33 34#include <sys/param.h> 35#include <sys/errno.h> 36#include <err.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <string.h> 40#include <unistd.h> 41#include "mpsutil.h" 42 43SET_DECLARE(MPS_DATASET(top), struct mpsutil_command); 44SET_DECLARE(MPS_DATASET(usage), struct mpsutil_usage); 45 46int mps_unit; | 33 34#include <sys/param.h> 35#include <sys/errno.h> 36#include <err.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <string.h> 40#include <unistd.h> 41#include "mpsutil.h" 42 43SET_DECLARE(MPS_DATASET(top), struct mpsutil_command); 44SET_DECLARE(MPS_DATASET(usage), struct mpsutil_usage); 45 46int mps_unit; |
47int is_mps; |
|
47 48static void 49usage(void) 50{ 51 struct mpsutil_usage **cmd; 52 const char *args, *desc; 53 | 48 49static void 50usage(void) 51{ 52 struct mpsutil_usage **cmd; 53 const char *args, *desc; 54 |
54 fprintf(stderr, "usage: mpsutil [-u unit] <command> ...\n\n"); | 55 fprintf(stderr, "usage: %s [-u unit] <command> ...\n\n", getprogname()); |
55 fprintf(stderr, "Commands include:\n"); 56 SET_FOREACH(cmd, MPS_DATASET(usage)) { 57 if (*cmd == NULL) 58 fprintf(stderr, "\n"); 59 else 60 (*cmd)->handler(&args, &desc); 61 if (strncmp((*cmd)->set, "top", 3) == 0) 62 fprintf(stderr, "%s %-30s\t%s\n", --- 4 unchanged lines hidden (view full) --- 67 } 68 exit(1); 69} 70 71static int 72version(int ac, char **av) 73{ 74 | 56 fprintf(stderr, "Commands include:\n"); 57 SET_FOREACH(cmd, MPS_DATASET(usage)) { 58 if (*cmd == NULL) 59 fprintf(stderr, "\n"); 60 else 61 (*cmd)->handler(&args, &desc); 62 if (strncmp((*cmd)->set, "top", 3) == 0) 63 fprintf(stderr, "%s %-30s\t%s\n", --- 4 unchanged lines hidden (view full) --- 68 } 69 exit(1); 70} 71 72static int 73version(int ac, char **av) 74{ 75 |
75 printf("mpsutil: version %s", MPSUTIL_VERSION); | 76 printf("%s: version %s", MPSUTIL_VERSION, getprogname()); |
76#ifdef DEBUG 77 printf(" (DEBUG)"); 78#endif 79 printf("\n"); 80 return (0); 81} 82 83MPS_COMMAND(top, version, version, "", "version") 84 85int 86main(int ac, char **av) 87{ 88 struct mpsutil_command **cmd; 89 int ch; 90 | 77#ifdef DEBUG 78 printf(" (DEBUG)"); 79#endif 80 printf("\n"); 81 return (0); 82} 83 84MPS_COMMAND(top, version, version, "", "version") 85 86int 87main(int ac, char **av) 88{ 89 struct mpsutil_command **cmd; 90 int ch; 91 |
92 is_mps = !strcmp(getprogname(), "mpsutil"); 93 |
|
91 while ((ch = getopt(ac, av, "u:h?")) != -1) { 92 switch (ch) { 93 case 'u': 94 mps_unit = atoi(optarg); 95 break; 96 case 'h': 97 case '?': 98 usage(); --- 102 unchanged lines hidden --- | 94 while ((ch = getopt(ac, av, "u:h?")) != -1) { 95 switch (ch) { 96 case 'u': 97 mps_unit = atoi(optarg); 98 break; 99 case 'h': 100 case '?': 101 usage(); --- 102 unchanged lines hidden --- |