git: 5fb6ac34479d - stable/12 - sys/file.h: Allow inclusion when compiling for a strict namespace

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 15:55:19 UTC
The branch stable/12 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=5fb6ac34479dc0e23b5ff8f3ae74c6266cf32476

commit 5fb6ac34479dc0e23b5ff8f3ae74c6266cf32476
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-11-24 09:25:47 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-12-06 15:54:10 +0000

    sys/file.h: Allow inclusion when compiling for a strict namespace
    
    Although not part of the standard, this file is sometimes included with
    -D_POSIX_C_SOURCE=<value> or -D_XOPEN_SOURCE=<value>. Limit those
    sturctures that use types hidden by __BSD_VISIBLE to when they are
    visible.
    
    PR:                     259975, 234205
    Sponsored by:           Netflix
    
    (cherry picked from commit a2b53e53a3f38dd89b64500a2d2a1727baffe4f9)
---
 sys/sys/file.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/sys/file.h b/sys/sys/file.h
index d17b9db27561..316ac606cf5a 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -161,6 +161,7 @@ struct fileops {
  * none	not locked
  */
 
+#if __BSD_VISIBLE
 struct fadvise_info {
 	int		fa_advice;	/* (f) FADV_* type. */
 	off_t		fa_start;	/* (f) Region start. */
@@ -205,12 +206,14 @@ struct file {
 #define	FOFFSET_LOCKED       0x1
 #define	FOFFSET_LOCK_WAITING 0x2
 #define	FDEVFS_VNODE	     0x4
+#endif /* __BSD_VISIBLE */
 
 #endif /* _KERNEL || _WANT_FILE */
 
 /*
  * Userland version of struct file, for sysctl
  */
+#if __BSD_VISIBLE
 struct xfile {
 	ksize_t	xf_size;	/* size of struct xfile */
 	pid_t	xf_pid;		/* owning process */
@@ -230,6 +233,7 @@ struct xfile {
 	int	_xf_int_pad3;
 	int64_t	_xf_int64_pad[6];
 };
+#endif /* __BSD_VISIBLE */
 
 #ifdef _KERNEL