diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2011-06-24 21:02:10 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2011-06-24 21:02:10 +0000 |
commit | 14c389b94f49cb069c395e504a4ae612f892bf9c (patch) | |
tree | cb1d727f2db46e6dd2b8d1956ab2819eca6a9fdd /sbin/swapctl/swaplist.c | |
parent | 3da505965757e4e925366c29b363105405fd202d (diff) |
swapctl -s was showing 1k blocks, regardless of -k. so fix this by showing
1k block when we're supposed to.
fix from tyr@poczta.fm in pr 6609
ok otto@
Diffstat (limited to 'sbin/swapctl/swaplist.c')
-rw-r--r-- | sbin/swapctl/swaplist.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/sbin/swapctl/swaplist.c b/sbin/swapctl/swaplist.c index 2cca12df0f7..4aac6cb5011 100644 --- a/sbin/swapctl/swaplist.c +++ b/sbin/swapctl/swaplist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swaplist.c,v 1.7 2007/07/26 17:03:05 deraadt Exp $ */ +/* $OpenBSD: swaplist.c,v 1.8 2011/06/24 21:02:09 jasper Exp $ */ /* $NetBSD: swaplist.c,v 1.8 1998/10/08 10:00:31 mrg Exp $ */ /* @@ -68,13 +68,14 @@ list_swap(int pri, int kflag, int pflag, int dolong) rnswap, nswap); pathmax = 11; + if (kflag) { + header = "1K-blocks"; + blocksize = 1024; + hlen = strlen(header); + } else + header = getbsize(&hlen, &blocksize); + if (dolong) { - if (kflag) { - header = "1K-blocks"; - blocksize = 1024; - hlen = strlen(header); - } else - header = getbsize(&hlen, &blocksize); for (i = rnswap; i-- > 0; sep++) if (pathmax < (l = strlen(sep->se_path))) pathmax = l; @@ -105,11 +106,12 @@ list_swap(int pri, int kflag, int pflag, int dolong) } } if (dolong == 0) - printf("total: %ldk bytes allocated = %ldk used, " - "%ldk available\n", - (long)(dbtoqb(totalsize) / 1024), - (long)(dbtoqb(totalinuse) / 1024), - (long)(dbtoqb(totalsize - totalinuse) / 1024)); + printf("total: %ld %*s allocated, %ld used, " + "%ld available\n", + (long)(dbtoqb(totalsize) / blocksize), + hlen, header, + (long)(dbtoqb(totalinuse) / blocksize), + (long)(dbtoqb(totalsize - totalinuse) / blocksize)); else if (ncounted > 1) (void)printf("%-*s %*ld %8ld %8ld %5.0f%%\n", pathmax, "Total", hlen, |