On Sun, 2020-11-29 at 16:15 -0800, Philip Guenther wrote:
> On Sun, Nov 29, 2020 at 12:14 PM Martijn van Duren 
> <[email protected]> wrote:
> > On Sat, 2020-11-28 at 16:23 -0800, Philip Guenther wrote:
> > > On Thu, Nov 26, 2020 at 1:08 PM Martijn van Duren 
> > > <[email protected]> wrote:
> > > > I'm currently playing around a bit with kvm_getfiles and found that I
> > > > couldn't use KERN_FILE_BYFILE with DTYPE_SOCKET.
> > > > According to kvm_getfiles(3):
> > > >      For KERN_FILE_BYFILE the recognized file types are defined in
> > > >      <sys/file.h>:
> > > > 
> > > >            DTYPE_VNODE           files and devices
> > > >            DTYPE_SOCKET          sockets, regardless of domain
> > > >            DTYPE_PIPE            pipes and FIFOs
> > > >            DTYPE_KQUEUE          kqueues
> > > > 
> > > > But these defines are under ifdef _KERNEL.
> > > > 
> > > > So is the manpage lying here, or should the defines be hoisted out
> > > > of the ifdef?
> > > > 
> > > 
> > > 
> > > Let's go ahead and hoist them: FreeBSD and NetBSD already have.  If 
> > > possible, the diff to do that should also simplify the #include bits in 
> > > these files:
> > >     usr.bin/netstat/inet.c
> > >     usr.bin/fstat/fstat.c
> > >     usr.bin/fstat/fuser.c
> > >     usr.bin/systat/netstat.c
> > > 
> > > 
> > > Philip Guenther
> > > 
> > 
> > The others have the #endif/#ifdef break rather low in the file.
> > Personally I reckon it's better reading if the common code is more
> > towards the top.
> > 
> > OK?
> > 
> 
> 
> ok guenther@
> 
> How do the userland clean up bits look?
> 
> 
> Philip Guenther
> 

Something like this?

Index: fstat/fstat.c
===================================================================
RCS file: /cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.101
diff -u -p -r1.101 fstat.c
--- fstat/fstat.c       22 Aug 2020 18:34:29 -0000      1.101
+++ fstat/fstat.c       30 Nov 2020 07:17:51 -0000
@@ -55,9 +55,7 @@
 #include <sys/eventvar.h>
 #include <sys/sysctl.h>
 #include <sys/filedesc.h>
-#define _KERNEL /* for DTYPE_* */
 #include <sys/file.h>
-#undef _KERNEL
 
 #include <net/route.h>
 #include <netinet/in.h>
Index: fstat/fuser.c
===================================================================
RCS file: /cvs/src/usr.bin/fstat/fuser.c,v
retrieving revision 1.8
diff -u -p -r1.8 fuser.c
--- fstat/fuser.c       25 Jan 2019 00:19:26 -0000      1.8
+++ fstat/fuser.c       30 Nov 2020 07:17:51 -0000
@@ -45,9 +45,7 @@
 #include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/ucred.h>
-#define _KERNEL /* for DTYPE_VNODE */
 #include <sys/file.h>
-#undef _KERNEL
 
 #include <err.h>
 #include <fcntl.h>
Index: systat/netstat.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/netstat.c,v
retrieving revision 1.45
diff -u -p -r1.45 netstat.c
--- systat/netstat.c    12 Mar 2015 01:03:00 -0000      1.45
+++ systat/netstat.c    30 Nov 2020 07:17:51 -0000
@@ -38,9 +38,7 @@
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <sys/socket.h>
-#define _KERNEL
 #include <sys/file.h>
-#undef _KERNEL
 
 #include <netinet/in.h>
 #include <netinet/tcp.h>
Index: netstat/inet.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/inet.c,v
retrieving revision 1.168
diff -u -p -r1.168 inet.c
--- netstat/inet.c      15 Jan 2020 14:02:37 -0000      1.168
+++ netstat/inet.c      30 Nov 2020 07:17:51 -0000
@@ -37,9 +37,7 @@
 #include <sys/domain.h>
 #include <sys/protosw.h>
 #include <sys/sysctl.h>
-#define _KERNEL
 #include <sys/file.h>
-#undef _KERNEL
 
 #include <net/route.h>
 #include <netinet/in.h>


Reply via email to