[snip]
+ int count = SCARG(uap, misc);
+ int i, error = 0;
+
+ /* Make sure userland cannot exhaust kernel memory */
+ if ((size_t)count > (size_t)uvmexp.nswapdev)
+ count = uvmexp.nswapdev;
+
+ sep = kmem_alloc(sizeof(*sep) * count, KM_SLEEP);
+ sep32 = kmem_alloc(sizeof(*sep32) * count, KM_SLEEP);
+
+ uvm_swap_stats(SWAP_STATS, sep, count, retval);
+ count = *retval;
+
+ if (count < 1)
+ goto out;
+
+ for (i = 0; i < count; i++) {
+ sep32[i].se_dev = sep[i].se_dev;
+ sep32[i].se_flags = sep[i].se_flags;
+ sep32[i].se_nblks = sep[i].se_nblks;
+ sep32[i].se_inuse = sep[i].se_inuse;
+ sep32[i].se_priority = sep[i].se_priority;
+ memcpy(sep32[i].se_path, sep[i].se_path,
+ sizeof(sep32[i].se_path));
+ }