Date: Sat, 30 Jul 2011 01:06:48 +0200 From: Robert Millan <rmh@debian.org> To: Kostik Belousov <kostikbel@gmail.com> Cc: freebsd-hackers@freebsd.org, freebsd-emulation@freebsd.org, Ed Maste <emaste@freebsd.org> Subject: Re: kern/159281: [PATCH] Linux-like /proc/swaps for linprocfs Message-ID: <CAOfDtXOJjOoQA8yNFPVdQRqCqr-Vc5nscMbgOLGLMuvTP9mp1w@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--90e6ba613be8131d7804a93d56e9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Kostik, 2011/7/29 Kostik Belousov <kostikbel@gmail.com>: > The patch is too hackish, IMHO. > I would prefer to have an exported kernel function that fills xswdev > by index, used both by vm_swap_info and linprocfs. > > For the device name, you would use sw_vp->v_rdev->si_name, see, for > instance, the following fragment in the swapoff_all(): > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (vn_isdisk(sp->= sw_vp, NULL)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0devname =3D sp->sw_vp->v_rdev->si_name; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0else > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0devname =3D "[file]"; > This could be another function that returns swap information by index. Here's a patch with the changes you requested. --=20 Robert Millan --90e6ba613be8131d7804a93d56e9 Content-Type: text/x-patch; charset=US-ASCII; name="006_proc_swaps.diff" Content-Disposition: attachment; filename="006_proc_swaps.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gqprh89i1 LS0tIGEvc3lzL2NvbXBhdC9saW5wcm9jZnMvbGlucHJvY2ZzLmMKKysrIGIvc3lzL2NvbXBhdC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WxsKHZv aWQpOworaW50IHN3YXBfaW5mbyhpbnQgbmFtZSwgc3RydWN0IHhzd2RldiAqeHMpOworaW50IHN3 YXBfZGV2bmFtZShpbnQgbmFtZSwgY2hhciAqZGV2bmFtZSwgc2l6ZV90IGxlbik7CiAKICNlbmRp ZgkJCQkvKiBfS0VSTkVMICovCiAjZW5kaWYJCQkJLyogX1ZNX1NXQVBfUEFHRVJfSF8gKi8K --90e6ba613be8131d7804a93d56e9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOfDtXOJjOoQA8yNFPVdQRqCqr-Vc5nscMbgOLGLMuvTP9mp1w>