From 917004b1d424c0f231b329bb42cbad6a1c2740c4 Mon Sep 17 00:00:00 2001 From: franklahm Date: Sat, 3 Apr 2010 07:11:33 +0000 Subject: [PATCH] Patches for OpenBSD --- configure.in | 5 +- distrib/initscripts/rc.atalk.bsd.tmpl | 14 +++-- etc/afpd/quota.c | 3 +- include/atalk/compat.h | 11 ++++ include/atalk/dsi.h | 4 ++ libatalk/compat/Makefile.am | 1 + libatalk/compat/pselect.c | 81 +++++++++++++++++++++++++++ libatalk/vfs/ea_sys.c | 3 +- macros/db3-check.m4 | 4 +- 9 files changed, 115 insertions(+), 11 deletions(-) create mode 100644 libatalk/compat/pselect.c diff --git a/configure.in b/configure.in index db8b6015..9dad52e1 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.240 2010-03-29 15:22:57 franklahm Exp $ +dnl $Id: configure.in,v 1.241 2010-04-03 07:11:33 franklahm Exp $ dnl configure.in for netatalk AC_INIT(etc/afpd/main.c) @@ -135,9 +135,8 @@ AC_TYPE_SIGNAL AC_FUNC_UTIME_NULL AC_FUNC_WAIT3 AC_CHECK_FUNCS(getcwd gethostname gettimeofday getusershell mkdir rmdir select socket strdup strcasestr strstr strtoul strchr memcpy) -AC_CHECK_FUNCS(backtrace_symbols setlocale nl_langinfo) +AC_CHECK_FUNCS(backtrace_symbols setlocale nl_langinfo strlcpy strlcat setlinebuf dirfd pselect) AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64) -AC_CHECK_FUNCS(strlcpy strlcat setlinebuf dirfd) AC_CHECK_FUNC(renameat, AC_DEFINE([_ATFILE_SOURCE], 1, AT file source)) AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include ]) AC_CACHE_SAVE diff --git a/distrib/initscripts/rc.atalk.bsd.tmpl b/distrib/initscripts/rc.atalk.bsd.tmpl index 191055de..05010b7b 100755 --- a/distrib/initscripts/rc.atalk.bsd.tmpl +++ b/distrib/initscripts/rc.atalk.bsd.tmpl @@ -15,7 +15,12 @@ ## /usr/etc/modload -sym :ETCDIR:/netatalk.o; ##fi +netatalk_conf=":ETCDIR:/netatalk.conf" + +[ -f ${netatalk_conf} ] && . ${netatalk_conf} + echo -n 'starting netatalk daemons:' +if [ X"${ATALKD_RUN}" != X"no" ]; then if [ -x :SBINDIR:/atalkd ]; then :SBINDIR:/atalkd; echo -n ' atalkd' fi @@ -25,21 +30,22 @@ if [ -x :BINDIR:/nbprgstr ]; then :BINDIR:/nbprgstr -p 4 `hostname|sed 's/\..*$//'`:netatalk echo -n ' nbprgstr' fi +fi -if [ -x :SBINDIR:/papd ]; then +if [ -x :SBINDIR:/papd -a X"${PAPD_RUN}" != X"no" ]; then :SBINDIR:/papd; echo -n ' papd' fi -if [ -x :SBINDIR:/cnid_metad ]; then +if [ -x :SBINDIR:/cnid_metad -a X"${CNID_METAD_RUN}" != X"no" ]; then :SBINDIR:/cnid_metad $CNID_CONFIG echo -n ' cnid_metad' fi -if [ -x :SBINDIR:/afpd ]; then +if [ -x :SBINDIR:/afpd -a X"${AFPD_RUN}" != X"no" ]; then :SBINDIR:/afpd; echo -n ' afpd' fi -if [ -x :SBINDIR:/timelord ]; then +if [ -x :SBINDIR:/timelord -a X"${TIMELORD_RUN}" != X"no" ]; then :SBINDIR:/timelord; echo -n ' timelord' fi diff --git a/etc/afpd/quota.c b/etc/afpd/quota.c index 26aae15b..9992948c 100644 --- a/etc/afpd/quota.c +++ b/etc/afpd/quota.c @@ -1,5 +1,5 @@ /* - * $Id: quota.c,v 1.34 2010-02-10 14:05:37 franklahm Exp $ + * $Id: quota.c,v 1.35 2010-04-03 07:11:35 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -41,6 +41,7 @@ char *strchr (), *strrchr (); #include #include +#include #include "auth.h" #include "volume.h" diff --git a/include/atalk/compat.h b/include/atalk/compat.h index 6820f7ba..42995534 100644 --- a/include/atalk/compat.h +++ b/include/atalk/compat.h @@ -92,3 +92,14 @@ int snprintf (char *str,size_t count,const char *fmt,...); #ifndef HAVE_VSNPRINTF int vsnprintf(char *str, size_t count, const char *fmt, va_list args); #endif + +/* OpenBSD */ +#if defined(__OpenBSD__) && !defined(ENOTSUP) +#define ENOTSUP EOPNOTSUPP +#endif + +#if !defined(HAVE_PSELECT) || defined(__OpenBSD__) +extern int pselect(int, fd_set * restrict, fd_set * restrict, + fd_set * restrict, const struct timespec * restrict, + const sigset_t * restrict); +#endif diff --git a/include/atalk/dsi.h b/include/atalk/dsi.h index fb45a30e..82da7a15 100644 --- a/include/atalk/dsi.h +++ b/include/atalk/dsi.h @@ -16,6 +16,10 @@ #include #include +#ifdef __OpenBSD__ +#include +#endif + /* What a DSI packet looks like: 0 32 |-------------------------------| diff --git a/libatalk/compat/Makefile.am b/libatalk/compat/Makefile.am index 63ccddd4..ebe54b21 100644 --- a/libatalk/compat/Makefile.am +++ b/libatalk/compat/Makefile.am @@ -10,4 +10,5 @@ libcompat_la_SOURCES = \ strdup.c \ inet_aton.c \ rquota_xdr.c \ + pselect.c \ snprintf.c diff --git a/libatalk/compat/pselect.c b/libatalk/compat/pselect.c new file mode 100644 index 00000000..608996b2 --- /dev/null +++ b/libatalk/compat/pselect.c @@ -0,0 +1,81 @@ +/* + * Copyright 2000 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $FreeBSD: src/lib/libc/gen/pselect.c,v 1.6 2002/10/12 16:13:37 mike Exp $ */ +/* modified for OpenBSD by Masahito Yamaga (2010-02-02) */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#if !defined(HAVE_PSELECT) || defined(__OpenBSD__) + +#include +#include +#include +#include + +/* + * Emulate the POSIX 1003.1g-2000 `pselect' interface. This is the + * same as the traditional BSD `select' function, except that it uses + * a timespec rather than a timeval, doesn't modify the timeout argument, + * and allows the user to specify a signal mask to apply during the select. + */ +int +pselect(int count, fd_set * restrict rfds, fd_set * restrict wfds, + fd_set * restrict efds, const struct timespec * restrict timo, + const sigset_t * restrict mask) +{ + sigset_t omask; + struct timeval tvtimo, *tvp; + int rv, sverrno; + + if (timo) { + TIMESPEC_TO_TIMEVAL(&tvtimo, timo); + tvp = &tvtimo; + } else + tvp = 0; + + if (mask != 0) { + rv = sigprocmask(SIG_SETMASK, mask, &omask); + if (rv != 0) + return rv; + } + + rv = select(count, rfds, wfds, efds, tvp); + if (mask != 0) { + sverrno = errno; + sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0); + errno = sverrno; + } + + return rv; +} + +#endif /* not HAVE_PSELECT || __OpenBSD__ */ diff --git a/libatalk/vfs/ea_sys.c b/libatalk/vfs/ea_sys.c index 07945856..38e61cd4 100644 --- a/libatalk/vfs/ea_sys.c +++ b/libatalk/vfs/ea_sys.c @@ -1,5 +1,5 @@ /* - $Id: ea_sys.c,v 1.6 2010-03-12 15:16:49 franklahm Exp $ + $Id: ea_sys.c,v 1.7 2010-04-03 07:11:36 franklahm Exp $ Copyright (c) 2009 Frank Lahm This program is free software; you can redistribute it and/or modify @@ -49,6 +49,7 @@ #include #include #include +#include #ifndef ENOATTR #define ENOATTR ENODATA diff --git a/macros/db3-check.m4 b/macros/db3-check.m4 index a9c66325..126c496b 100644 --- a/macros/db3-check.m4 +++ b/macros/db3-check.m4 @@ -1,4 +1,4 @@ -dnl $Id: db3-check.m4,v 1.21 2009-12-13 11:59:11 franklahm Exp $ +dnl $Id: db3-check.m4,v 1.22 2010-04-03 07:11:36 franklahm Exp $ dnl Autoconf macros to check for the Berkeley DB library dnl -- check header for minimum version and return version in @@ -28,7 +28,7 @@ AC_DEFUN([NETATALK_BDB_TRY_LINK],[ atalk_cv_bdb_version=no maj=$atalk_cv_bdb_MAJOR min=$atalk_cv_bdb_MINOR - atalk_cv_bdb_try_libs="db$maj$min db$maj.$min db-$maj$min db-$maj.$min" + atalk_cv_bdb_try_libs="db$maj$min db$maj.$min db-$maj$min db-$maj.$min db" for lib in $atalk_cv_bdb_try_libs ; do LIBS="-l$lib $savedlibs" -- 2.39.2