From d800b5b1bc746ddff351fbad075ed43dc1f4de0c Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Tue, 20 Aug 2019 20:20:46 +0200
Subject: [PATCH] kernel/chflags: Make the flags u_long all the way until
 va_flags (which is u_long too).

---
 sys/kern/syscalls.master |  8 ++++----
 sys/kern/vfs_syscalls.c  |  4 ++--
 sys/sys/sysproto.h       | 12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 1652d8e66c..f29b4dd569 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -83,8 +83,8 @@
 31	STD	{ int getpeername(int fdes, caddr_t asa, int *alen); }
 32	STD	{ int getsockname(int fdes, caddr_t asa, int *alen); }
 33	STD	{ int access(char *path, int flags); }
-34	STD	{ int chflags(char *path, int flags); }
-35	STD	{ int fchflags(int fd, int flags); }
+34	STD	{ int chflags(const char *path, u_long flags); }
+35	STD	{ int fchflags(int fd, u_long flags); }
 36	STD	{ int sync(void); }
 37	STD	{ int kill(int pid, int signum); }
 38	OBSOL	old stat
@@ -531,7 +531,7 @@
 388	UNIMPL	nosys
 389	UNIMPL	nosys
 390	STD	{ int kenv(int what, const char *name, char *value, int len); }
-391	STD	{ int lchflags(char *path, int flags); }
+391	STD	{ int lchflags(const char *path, u_long flags); }
 392	STD	{ int uuidgen(struct uuid *store, int count); }
 393	STD	{ int sendfile(int fd, int s, off_t offset, size_t nbytes, \
 				struct sf_hdtr *hdtr, off_t *sbytes, int flags); }
@@ -720,7 +720,7 @@
 534	STD	{ int vmm_guest_ctl(int op, struct vmm_guest_options *options); }
 535	STD	{ int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); }
 536	STD	{ int procctl(idtype_t idtype, id_t id, int cmd, void *data); }
-537	STD	{ int chflagsat(int fd, const char *path, int flags, int atflags);}
+537	STD	{ int chflagsat(int fd, const char *path, u_long flags, int atflags);}
 538	STD	{ int pipe2(int *fildes, int flags); }
 539	STD	{ int utimensat(int fd, const char *path, const struct timespec *ts, int flags); }
 540	STD	{ int futimens(int fd, const struct timespec *ts); }
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index f409d10be8..7ee2aa704a 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -86,7 +86,7 @@ static int getutimes (struct timeval *, struct timespec *);
 static int getutimens (const struct timespec *, struct timespec *, int *);
 static int setfown (struct mount *, struct vnode *, uid_t, gid_t);
 static int setfmode (struct vnode *, int);
-static int setfflags (struct vnode *, int);
+static int setfflags (struct vnode *, u_long);
 static int setutimes (struct vnode *, struct vattr *,
 			const struct timespec *, int);
 
@@ -3154,7 +3154,7 @@ sys_readlinkat(struct readlinkat_args *uap)
 }
 
 static int
-setfflags(struct vnode *vp, int flags)
+setfflags(struct vnode *vp, u_long flags)
 {
 	struct thread *td = curthread;
 	int error;
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index f8f7289ef5..419c4e2ae3 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -248,15 +248,15 @@ struct	chflags_args {
 #ifdef _KERNEL
 	struct sysmsg sysmsg;
 #endif
-	char *	path;	char path_[PAD_(char *)];
-	int	flags;	char flags_[PAD_(int)];
+	const char *	path;	char path_[PAD_(const char *)];
+	u_long	flags;	char flags_[PAD_(u_long)];
 };
 struct	fchflags_args {
 #ifdef _KERNEL
 	struct sysmsg sysmsg;
 #endif
 	int	fd;	char fd_[PAD_(int)];
-	int	flags;	char flags_[PAD_(int)];
+	u_long	flags;	char flags_[PAD_(u_long)];
 };
 struct	sync_args {
 #ifdef _KERNEL
@@ -1622,8 +1622,8 @@ struct	lchflags_args {
 #ifdef _KERNEL
 	struct sysmsg sysmsg;
 #endif
-	char *	path;	char path_[PAD_(char *)];
-	int	flags;	char flags_[PAD_(int)];
+	const char *	path;	char path_[PAD_(const char *)];
+	u_long	flags;	char flags_[PAD_(u_long)];
 };
 struct	uuidgen_args {
 #ifdef _KERNEL
@@ -2251,7 +2251,7 @@ struct	chflagsat_args {
 #endif
 	int	fd;	char fd_[PAD_(int)];
 	const char *	path;	char path_[PAD_(const char *)];
-	int	flags;	char flags_[PAD_(int)];
+	u_long	flags;	char flags_[PAD_(u_long)];
 	int	atflags;	char atflags_[PAD_(int)];
 };
 struct	pipe2_args {
-- 
2.22.0

