Subject: Re: UVM patch: sys_swapctl split
To: Emmanuel Dreyfus <manu@netbsd.org>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: tech-kern
Date: 03/18/2002 10:59:25
manu@netbsd.org (Emmanuel Dreyfus) writes:

> @@ -495,51 +495,13 @@
>  #endif
>             ) {
> -               sep = (struct swapent *)SCARG(uap, arg);
> -               count = 0;
> +               misc = MIN(uvmexp.nswapdev, misc);
> +               len = sizeof(struct swapent) * misc;
> +               sep = (struct swapent *)malloc(len, M_TEMP, M_WAITOK);
>  
> -               LIST_FOREACH(spp, &swap_priority, spi_swappri) {
> -                       for (sdp = CIRCLEQ_FIRST(&spp->spi_swapdev);
> -                            sdp != (void *)&spp->spi_swapdev && misc-- > 0;
> -                            sdp = CIRCLEQ_NEXT(sdp, swd_next)) {
> -                               /*
> -                                * backwards compatibility for system call.
> -                                * note that we use 'struct oswapent' as an
> -                                * overlay into both 'struct swapdev' and
> -                                * the userland 'struct swapent', as we
> -                                * want to retain backwards compatibility
> -                                * with NetBSD 1.3.
> -                                */
> -                               sdp->swd_ose.ose_inuse =
> -                                   btodb((u_int64_t)sdp->swd_npginuse <<
> -                                   PAGE_SHIFT);
> -                               error = copyout(&sdp->swd_ose, sep,
> -                                               sizeof(struct oswapent));
> +               uvm_swap_stats(SCARG(uap, cmd), sep, misc, retval);
> +               error = copyout(sep, (void *)SCARG(uap, arg), len);

Does old 1.3 binary prepare `sizeof(struct swapent) * misc' bytes
space?  I guess you should copyout up to the length just
uvm_swap_stats() copied.

enami.