]> git.proxmox.com Git - mirror_zfs.git/commitdiff
xdr: header cleanup
authorRob N <robn@despairlabs.com>
Wed, 3 Apr 2024 22:13:27 +0000 (09:13 +1100)
committerGitHub <noreply@github.com>
Wed, 3 Apr 2024 22:13:27 +0000 (15:13 -0700)
#16047 notes that include/os/freebsd/spl/rpc/xdr.h carried an
(apparently) incompatible license. While looking into it, it seems that
this file is actually unnecessary these days - FreeBSD's kernel XDR has
XDR_CONTROL, xdrmem_control and XDR_GET_BYTES_AVAIL, while userspace has
XDR_CONTROL and xdrmem_control, and our implementation of
XDR_GET_BYTES_AVAIL for libspl works nicely with it. So this removes
that file outright.

To keep the includes in nvpair.c tidy, I've made a few small adjustments
to the Linux headers. By definition, rpc/types.h provides bool_t and is
included before rpc/xdr.h, so I've created rpc/types.h for Linux. This
isn't necessary for userspace; both FreeBSD native and tirpc on Linux
already have these headers set up correctly.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Closes #16047
Closes #16051

include/os/freebsd/Makefile.am
include/os/freebsd/spl/rpc/xdr.h [deleted file]
include/os/linux/Makefile.am
include/os/linux/spl/rpc/types.h [new file with mode: 0644]
include/os/linux/spl/rpc/xdr.h
module/nvpair/nvpair.c
module/os/linux/spl/spl-xdr.c

index 551f75f42a20b4ab145dc5c47973eaf4874c99a7..d4103c2f062a629a46635cf480bb81df4b3bdc09 100644 (file)
@@ -4,8 +4,6 @@ noinst_HEADERS = \
        \
        %D%/spl/acl/acl_common.h \
        \
-       %D%/spl/rpc/xdr.h \
-       \
        %D%/spl/sys/ia32/asm_linkage.h \
        \
        %D%/spl/sys/acl.h \
diff --git a/include/os/freebsd/spl/rpc/xdr.h b/include/os/freebsd/spl/rpc/xdr.h
deleted file mode 100644 (file)
index c98466e..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-
-#ifndef        _OPENSOLARIS_RPC_XDR_H_
-#define        _OPENSOLARIS_RPC_XDR_H_
-
-#include <rpc/types.h>
-#include_next <rpc/xdr.h>
-
-#if !defined(_KERNEL) && !defined(_STANDALONE)
-
-#include <assert.h>
-
-/*
- * Taken from sys/xdr/xdr_mem.c.
- *
- * FreeBSD's userland XDR doesn't implement control method (only the kernel),
- * but OpenSolaris nvpair still depend on it, so we have to implement it here.
- */
-static __inline bool_t
-xdrmem_control(XDR *xdrs, int request, void *info)
-{
-       xdr_bytesrec *xptr;
-
-       switch (request) {
-       case XDR_GET_BYTES_AVAIL:
-               xptr = (xdr_bytesrec *)info;
-               xptr->xc_is_last_record = TRUE;
-               xptr->xc_num_avail = xdrs->x_handy;
-               return (TRUE);
-       default:
-               assert(!"unexpected request");
-       }
-       return (FALSE);
-}
-
-#undef XDR_CONTROL
-#define        XDR_CONTROL(xdrs, req, op)                                      \
-       (((xdrs)->x_ops->x_control == NULL) ?                           \
-           xdrmem_control((xdrs), (req), (op)) :                       \
-           (*(xdrs)->x_ops->x_control)(xdrs, req, op))
-
-#endif /* !_KERNEL && !_STANDALONE */
-
-#endif /* !_OPENSOLARIS_RPC_XDR_H_ */
index 51c27132b4efe8e80f4fd87b0ba8ccb13784f5fa..332569efe3618594e21b8f94564f9252a755c9a1 100644 (file)
@@ -47,6 +47,7 @@ kernel_sys_HEADERS = \
 
 kernel_spl_rpcdir = $(kerneldir)/spl/rpc
 kernel_spl_rpc_HEADERS = \
+       %D%/spl/rpc/types.h \
        %D%/spl/rpc/xdr.h
 
 kernel_spl_sysdir = $(kerneldir)/spl/sys
diff --git a/include/os/linux/spl/rpc/types.h b/include/os/linux/spl/rpc/types.h
new file mode 100644 (file)
index 0000000..5bbb4f2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (c) 2008 Sun Microsystems, Inc.
+ *  Written by Ricardo Correia <Ricardo.M.Correia@Sun.COM>
+ *
+ *  This file is part of the SPL, Solaris Porting Layer.
+ *
+ *  The SPL is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ *
+ *  The SPL is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SPL_RPC_TYPES_H
+#define        _SPL_RPC_TYPES_H
+
+#include <sys/types.h>
+
+/* Just enough to support rpc/xdr.h */
+
+typedef int bool_t;
+
+#endif /* SPL_RPC_TYPES_H */
index b00f3542fcdf00fbbbdb13c9b8b05fa9b31b407e..5b621fa9c863048dd40fb208f6a0ac06317c5791 100644 (file)
@@ -23,8 +23,6 @@
 
 #include <sys/types.h>
 
-typedef int bool_t;
-
 /*
  * XDR enums and types.
  */
index d9449e47e87ab97ac00d6c07fc7878df65e704f2..887f7d32df4a4eb508cbc11a95552d905c6f0932 100644 (file)
@@ -41,6 +41,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/string.h>
+#include <rpc/types.h>
 #include <rpc/xdr.h>
 #include <sys/mod.h>
 
index 6b77524181db033163509d92db8cc4a10472272d..e1773da5d173b4ec7bbd9bda296e27682b2f9cbf 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/debug.h>
 #include <sys/types.h>
 #include <sys/sysmacros.h>
+#include <rpc/types.h>
 #include <rpc/xdr.h>
 
 /*