diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-07-31 21:30:28 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-07-31 21:30:28 +0000 |
commit | 5243b6799bfa44fd8cc78f467375f176b1a54b7f (patch) | |
tree | 0b31c4ecc9977f673344961dc3c29fe215244ad3 /lib/libkvm/kvm_getswapinfo.c | |
parent | 9c76f2b9d6b937fa0a42c4f44ea0f62fdf85caea (diff) | |
download | src-5243b6799bfa44fd8cc78f467375f176b1a54b7f.tar.gz src-5243b6799bfa44fd8cc78f467375f176b1a54b7f.zip |
Notes
Diffstat (limited to 'lib/libkvm/kvm_getswapinfo.c')
-rw-r--r-- | lib/libkvm/kvm_getswapinfo.c | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/lib/libkvm/kvm_getswapinfo.c b/lib/libkvm/kvm_getswapinfo.c index be22e768d85f..35702a896a8d 100644 --- a/lib/libkvm/kvm_getswapinfo.c +++ b/lib/libkvm/kvm_getswapinfo.c @@ -51,8 +51,6 @@ static int nswdev; static int unswdev; /* number of found swap dev's */ static int dmmax; -static void getswapinfo_radix(kvm_t *kd, struct kvm_swap *swap_ary, - int swap_max, int flags); static int kvm_getswapinfo2(kvm_t *kd, struct kvm_swap *swap_ary, int swap_max, int flags); static int kvm_getswapinfo_kvm(kvm_t *, struct kvm_swap *, int, int); @@ -108,23 +106,6 @@ kvm_getswapinfo( return(0); } - rv = kvm_getswapinfo2(kd, swap_ary, swap_max, flags); - - /* This is only called when the tree shall be dumped. It needs kvm. */ - if (flags & SWIF_DUMP_TREE) { - getswapinfo_radix(kd, swap_ary, swap_max, flags); - } - - return rv; -} - -static int -kvm_getswapinfo2( - kvm_t *kd, - struct kvm_swap *swap_ary, - int swap_max, - int flags -) { if (ISALIVE(kd)) { return kvm_getswapinfo_sysctl(kd, swap_ary, swap_max, flags); } else { @@ -199,177 +180,6 @@ kvm_getswapinfo_kvm( return(ti); } -/* - * scanradix() - support routine for radix scanner - */ - -#define TABME tab, tab, "" - -static int -scanradix( - blmeta_t *scan, - daddr_t blk, - daddr_t radix, - daddr_t skip, - daddr_t count, - kvm_t *kd, - int dmmax, - int nswdev, - struct kvm_swap *swap_ary, - int swap_max, - int tab, - int flags -) { - blmeta_t meta; - - KGET2(scan, &meta, sizeof(meta), "blmeta_t"); - - /* - * Terminator - */ - if (meta.bm_bighint == (daddr_t)-1) { - if (flags & SWIF_DUMP_TREE) { - printf("%*.*s(0x%06x,%d) Terminator\n", - TABME, - blk, - radix - ); - } - return(-1); - } - - if (radix == BLIST_BMAP_RADIX) { - /* - * Leaf bitmap - */ - - if (flags & SWIF_DUMP_TREE) { - printf("%*.*s(0x%06x,%d) Bitmap %08x big=%d\n", - TABME, - blk, - radix, - (int)meta.u.bmu_bitmap, - meta.bm_bighint - ); - } - - } else if (meta.u.bmu_avail == radix) { - /* - * Meta node if all free - */ - if (flags & SWIF_DUMP_TREE) { - printf("%*.*s(0x%06x,%d) Submap ALL-FREE {\n", - TABME, - blk, - radix - ); - } - } else if (meta.u.bmu_avail == 0) { - /* - * Meta node if all used - */ - if (flags & SWIF_DUMP_TREE) { - printf("%*.*s(0x%06x,%d) Submap ALL-ALLOCATED\n", - TABME, - blk, - radix - ); - } - } else { - /* - * Meta node if not all free - */ - int i; - int next_skip; - - if (flags & SWIF_DUMP_TREE) { - printf("%*.*s(0x%06x,%d) Submap avail=%d big=%d {\n", - TABME, - blk, - radix, - (int)meta.u.bmu_avail, - meta.bm_bighint - ); - } - - radix /= BLIST_META_RADIX; - next_skip = skip / BLIST_META_RADIX; - - for (i = 1; i <= skip; i += next_skip) { - int r; - daddr_t vcount = (count > radix) ? radix : count; - - r = scanradix( - &scan[i], - blk, - radix, - next_skip - 1, - vcount, - kd, - dmmax, - nswdev, - swap_ary, - swap_max, - tab + 4, - flags - ); - if (r < 0) - break; - blk += radix; - } - if (flags & SWIF_DUMP_TREE) { - printf("%*.*s}\n", TABME); - } - } - return(0); -} - -static void -getswapinfo_radix(kvm_t *kd, struct kvm_swap *swap_ary, int swap_max, int flags) -{ - struct blist *swapblist = NULL; - struct blist blcopy = { 0 }; - - if (!nlist_init(kd)) { - fprintf(stderr, "radix tree: nlist_init failed!\n"); - return; - } - - KGET(NL_SWAPBLIST, swapblist); - - if (swapblist == NULL) { - if (flags & SWIF_DUMP_TREE) - printf("radix tree: NULL - no swap in system\n"); - return; - } - - KGET2(swapblist, &blcopy, sizeof(blcopy), "*swapblist"); - - if (flags & SWIF_DUMP_TREE) { - printf("radix tree: %d/%d/%d blocks, %dK wired\n", - blcopy.bl_free, - blcopy.bl_blocks, - blcopy.bl_radix, - (int)((blcopy.bl_rootblks * sizeof(blmeta_t) + 1023)/ - 1024) - ); - } - scanradix( - blcopy.bl_root, - 0, - blcopy.bl_radix, - blcopy.bl_skip, - blcopy.bl_rootblks, - kd, - dmmax, - nswdev, - swap_ary, - swap_max, - 0, - flags - ); -} - #define GETSYSCTL(kd, name, var) \ getsysctl(kd, name, &(var), sizeof(var)) |