From 59541a305e22334cebf0304859dcaf209edd0154 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 12 Mar 2009 14:38:52 -0700 Subject: [PATCH 1/2] Libspl XDR implementation reorganization Moved xdr_control() function from static inline in xdr.h in to a new xdr.c file which was added to the libspl build. Additionally, I have removed the 'xdr_bytesrec' typedef which shares the same name as the struct. This is what Solaris does, but it's just asking for trouble. It has been replaced with an 'xdr_bytesrec_t' typedef. --- lib/libspl/Makefile.am | 1 + lib/libspl/include/Makefile.am | 13 +++--- lib/libspl/include/rpc/xdr.h | 69 ++++-------------------------- lib/libspl/xdr.c | 78 ++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 67 deletions(-) create mode 100644 lib/libspl/xdr.c diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am index 93d1373f41..5e84930b32 100644 --- a/lib/libspl/Makefile.am +++ b/lib/libspl/Makefile.am @@ -19,6 +19,7 @@ libspl_la_SOURCES = \ ${top_srcdir}/lib/libspl/strlcpy.c \ ${top_srcdir}/lib/libspl/strnlen.c \ ${top_srcdir}/lib/libspl/zone.c \ + ${top_srcdir}/lib/libspl/xdr.c \ ${top_srcdir}/lib/libspl/asm-${target_cpu}/atomic.S \ ${top_srcdir}/lib/libspl/include/sys/list.h \ ${top_srcdir}/lib/libspl/include/sys/list_impl.h diff --git a/lib/libspl/include/Makefile.am b/lib/libspl/include/Makefile.am index 1acc8396d8..40179395f3 100644 --- a/lib/libspl/include/Makefile.am +++ b/lib/libspl/include/Makefile.am @@ -1,6 +1,7 @@ -noinst_HEADERS = *.h -noinst_HEADERS += ia32/sys/*.h -noinst_HEADERS += sys/*.h -noinst_HEADERS += sys/fm/*.h -noinst_HEADERS += sys/sysevent/*.h -noinst_HEADERS += tsol/*.h +pkginclude_HEADERS = *.h +pkginclude_HEADERS += ia32/sys/*.h +pkginclude_HEADERS += rpc/*.h +pkginclude_HEADERS += sys/*.h +pkginclude_HEADERS += sys/fm/*.h +pkginclude_HEADERS += sys/sysevent/*.h +pkginclude_HEADERS += tsol/*.h diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h index dc982ebac9..cd6680f578 100644 --- a/lib/libspl/include/rpc/xdr.h +++ b/lib/libspl/include/rpc/xdr.h @@ -18,16 +18,13 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - */ -/* + * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* + * + * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * * Portions of this source code were derived from Berkeley 4.3 BSD * under license from the Regents of the University of California. */ @@ -37,26 +34,16 @@ #include_next -/* - * Strangely, my glibc version (2.3.6) doesn't have xdr_control(), so - * we have to hack it in here (source taken from OpenSolaris). - * By the way, it is assumed the xdrmem implementation is used. - */ - -#define xdr_control(a,b,c) xdrmem_control(a,b,c) - /* * These are XDR control operators */ #define XDR_GET_BYTES_AVAIL 1 -struct xdr_bytesrec { +typedef struct xdr_bytesrec { bool_t xc_is_last_record; size_t xc_num_avail; -}; - -typedef struct xdr_bytesrec xdr_bytesrec; +} xdr_bytesrec_t; /* * These are the request arguments to XDR_CONTROL. @@ -73,46 +60,6 @@ typedef struct xdr_bytesrec xdr_bytesrec; #define XDR_RDMAGET 4 #define XDR_RDMASET 5 -/* FIXME: probably doesn't work */ -static bool_t -xdrmem_control(XDR *xdrs, int request, void *info) -{ - xdr_bytesrec *xptr; - int32_t *int32p; - int len; - - 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); - - case XDR_PEEK: - /* - * Return the next 4 byte unit in the XDR stream. - */ - if (xdrs->x_handy < sizeof (int32_t)) - return (FALSE); - int32p = (int32_t *)info; - *int32p = (int32_t)ntohl((uint32_t) - (*((int32_t *)(xdrs->x_private)))); - return (TRUE); - - case XDR_SKIPBYTES: - /* - * Skip the next N bytes in the XDR stream. - */ - int32p = (int32_t *)info; - len = RNDUP((int)(*int32p)); - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - xdrs->x_private += len; - return (TRUE); - - } - return (FALSE); -} +extern bool_t xdr_control(XDR *xdrs, int request, void *info); #endif diff --git a/lib/libspl/xdr.c b/lib/libspl/xdr.c new file mode 100644 index 0000000000..288a338a12 --- /dev/null +++ b/lib/libspl/xdr.c @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T + * All Rights Reserved + * + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#include + +/* + * As of glibc-2.5-25 there is not support for xdr_control(). The + * xdrmem implementation from OpenSolaris is used here. + * + * FIXME: Not well tested it may not work as expected. + */ +bool_t +xdr_control(XDR *xdrs, int request, void *info) +{ + xdr_bytesrec_t *xptr; + int32_t *int32p; + int len; + + switch (request) { + case XDR_GET_BYTES_AVAIL: + xptr = (xdr_bytesrec_t *)info; + xptr->xc_is_last_record = TRUE; + xptr->xc_num_avail = xdrs->x_handy; + return (TRUE); + + case XDR_PEEK: + /* + * Return the next 4 byte unit in the XDR stream. + */ + if (xdrs->x_handy < sizeof (int32_t)) + return (FALSE); + int32p = (int32_t *)info; + *int32p = (int32_t)ntohl((uint32_t) + (*((int32_t *)(xdrs->x_private)))); + return (TRUE); + + case XDR_SKIPBYTES: + /* + * Skip the next N bytes in the XDR stream. + */ + int32p = (int32_t *)info; + len = RNDUP((int)(*int32p)); + if ((xdrs->x_handy -= len) < 0) + return (FALSE); + xdrs->x_private += len; + return (TRUE); + + } + return (FALSE); +} From f2e7d57653a65fdc7905e048dc77f446bcd614f6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 12 Mar 2009 15:07:29 -0700 Subject: [PATCH 2/2] Packaging update Make LINUX_VERSION available to Makefile's, add packaging for user space include headers. --- COPYRIGHT | 6 ------ config/zfs-build.m4 | 6 ++++-- lib/libzpool/include/Makefile.am | 2 +- zfs.spec.in | 3 ++- 4 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 COPYRIGHT diff --git a/COPYRIGHT b/COPYRIGHT deleted file mode 100644 index 2ca1599458..0000000000 --- a/COPYRIGHT +++ /dev/null @@ -1,6 +0,0 @@ -The bulk of the library is Copyright 2004 Sun Microsystems, Inc. -Portions are Copyright 2006 OmniTI, Inc. - -The library is distributed under the terms of the CDDL. -See the file OPENSOLARIS.LICENSE for more information. - diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index e9b24edb61..11e45c5004 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -66,11 +66,13 @@ AC_DEFUN([ZFS_AC_KERNEL], [ AC_MSG_RESULT([$kernsrcver]) kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver - LINUX=${kernelsrc} - LINUX_OBJ=${kernelbuild} + LINUX=${kernelsrc} + LINUX_OBJ=${kernelbuild} + LINUX_VERSION=${kernsrcver} AC_SUBST(LINUX) AC_SUBST(LINUX_OBJ) + AC_SUBST(LINUX_VERSION) AC_SUBST(kmoduledir) ]) diff --git a/lib/libzpool/include/Makefile.am b/lib/libzpool/include/Makefile.am index 71f0eaa8e5..d386e052af 100644 --- a/lib/libzpool/include/Makefile.am +++ b/lib/libzpool/include/Makefile.am @@ -1 +1 @@ -noinst_HEADERS = sys/*.h +pkginclude_HEADERS = sys/*.h diff --git a/zfs.spec.in b/zfs.spec.in index db486693fa..3895123e59 100644 --- a/zfs.spec.in +++ b/zfs.spec.in @@ -85,7 +85,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-, root, root) -%doc AUTHORS ChangeLog COPYING COPYRIGHT DISCLAIMER GIT +%doc AUTHORS ChangeLog COPYING DISCLAIMER GIT %doc OPENSOLARIS.LICENSE README TODO ZFS.RELEASE %{_sbindir}/* %{_libdir}/* @@ -94,6 +94,7 @@ rm -rf $RPM_BUILD_ROOT %files devel %defattr(-,root,root) %{kdir}/include/zfs/* +%{_includedir}/* %post if [ -f /boot/System.map-%{kver} ]; then