From df6a34adbf401032caa8e99bd5f6dd2fdc53ece1 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Fri, 22 Nov 2019 18:38:52 +0100
Subject: [PATCH 6/6] Take away dev_t from the kernel.

---
 sys/kern/makesyscalls.sh | 3 +++
 sys/sys/kinfo.h          | 2 +-
 sys/sys/sysproto.h       | 4 ++++
 sys/sys/types.h          | 6 +++---
 sys/sys/vnioctl.h        | 2 +-
 sys/vfs/tmpfs/tmpfs.h    | 2 +-
 sys/vm/vm_param.h        | 3 +--
 7 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh
index 1885dcf0d9..f87a709516 100644
--- a/sys/kern/makesyscalls.sh
+++ b/sys/kern/makesyscalls.sh
@@ -94,6 +94,9 @@ s/\$//g
 		printf "#include <sys/procctl.h>\n\n" > sysarg
 		printf "#define\tPAD_(t)\t(sizeof(register_t) <= sizeof(t) ? \\\n" > sysarg
 		printf "\t\t0 : sizeof(register_t) - sizeof(t))\n\n" > sysarg
+		printf "#ifdef _KERNEL\n" > sysarg
+		printf "#define\tdev_t\tudev_t\n" > sysarg
+		printf "#endif\n\n" >sysarg
 
 		printf "/*\n * System call names.\n *\n" > sysnames
 		printf " * DO NOT EDIT-- To regenerate this file, edit syscalls.master followed\n" > sysnames
diff --git a/sys/sys/kinfo.h b/sys/sys/kinfo.h
index 104110e66c..8aa189f5f6 100644
--- a/sys/sys/kinfo.h
+++ b/sys/sys/kinfo.h
@@ -188,7 +188,7 @@ struct kinfo_proc {
 	pid_t		kp_sid;		/* session id */
 	char		kp_login[roundup(MAXLOGNAME, sizeof(long))];
 					/* setlogin() name */
-	dev_t		kp_tdev;	/* controlling tty dev */
+	udev_t		kp_tdev;	/* controlling tty dev */
 	pid_t		kp_tpgid;	/* tty process group id */
 	pid_t		kp_tsid;	/* tty session id */
 
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index 077595ce2c..62ad6ba6a6 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -20,6 +20,10 @@
 #define	PAD_(t)	(sizeof(register_t) <= sizeof(t) ? \
 		0 : sizeof(register_t) - sizeof(t))
 
+#ifdef _KERNEL
+#define	dev_t	udev_t
+#endif
+
 struct	nosys_args {
 #ifdef _KERNEL
 	struct sysmsg sysmsg;
diff --git a/sys/sys/types.h b/sys/sys/types.h
index b3f8c13bcd..fc4183e68f 100644
--- a/sys/sys/types.h
+++ b/sys/sys/types.h
@@ -151,9 +151,9 @@ typedef	u_int32_t	udev_t;		/* device number */
 typedef	u_int64_t	uoff_t;		/* uio offset */
 #endif /* _KERNEL || _KERNEL_STRUCTURES */
 
-#ifdef _KERNEL
+#ifdef _KERNEL_VIRTUAL
 typedef	udev_t		dev_t;		/* device number */
-#else /* !_KERNEL */
+#elif !defined(_KERNEL)
 typedef	__uint32_t	dev_t;		/* device number */
 #define	udev_t dev_t
 
@@ -167,7 +167,7 @@ typedef	__uint32_t	dev_t;		/* device number */
 #define	minor(x)	((int)((x)&0xffff00ff))         /* minor number */
 #define	makedev(x,y)	((dev_t)(((x) << 8) | (y)))     /* create dev_t */
 #endif /* __BSD_VISIBLE */
-#endif /* _KERNEL */
+#endif /* _KERNEL_VIRTUAL */
 
 #ifndef _CLOCK_T_DECLARED
 #define	_CLOCK_T_DECLARED
diff --git a/sys/sys/vnioctl.h b/sys/sys/vnioctl.h
index ee23edc16c..d75d00d3bd 100644
--- a/sys/sys/vnioctl.h
+++ b/sys/sys/vnioctl.h
@@ -79,7 +79,7 @@ struct vn_user {
         char    	vnu_file[PATH_MAX];	/* vn description */
 #define _VN_USER_SWAP	"swap"			/* indicates swap-backed vn */
 	union {
-	        dev_t   	dev;		/* vn device */
+	        udev_t   	dev;		/* vn device */
 		u_int64_t	size;		/* size per vnu_secsize */
 	} data1;
 	union {
diff --git a/sys/vfs/tmpfs/tmpfs.h b/sys/vfs/tmpfs/tmpfs.h
index b24e39d1b2..0f29918663 100644
--- a/sys/vfs/tmpfs/tmpfs.h
+++ b/sys/vfs/tmpfs/tmpfs.h
@@ -215,7 +215,7 @@ struct tmpfs_node {
 	/* misc data field for different tn_type node */
 	union {
 		/* Valid when tn_type == VBLK || tn_type == VCHR. */
-		dev_t			tn_rdev; /*int32_t ?*/
+		udev_t			tn_rdev; /*int32_t ?*/
 
 		/* Valid when tn_type == VDIR. */
 		struct tn_dir {
diff --git a/sys/vm/vm_param.h b/sys/vm/vm_param.h
index f93c0d88d3..519d0836f8 100644
--- a/sys/vm/vm_param.h
+++ b/sys/vm/vm_param.h
@@ -58,7 +58,6 @@
  * rights to redistribute these changes.
  *
  * $FreeBSD: src/sys/vm/vm_param.h,v 1.13.2.1 2001/11/03 01:41:10 ps Exp $
- * $DragonFly: src/sys/vm/vm_param.h,v 1.5 2006/09/12 18:41:32 dillon Exp $
  */
 
 /*
@@ -115,7 +114,7 @@ struct xswdev {
 	size_t	xsw_size;
 	int	xsw_version;
 	int	xsw_flags;
-	dev_t	xsw_dev;
+	udev_t	xsw_dev;
 	size_t	xsw_blksize;
 	size_t	xsw_nblks;
 	size_t	xsw_used;
-- 
2.23.0

