From 5af2d10f62c901c3d0b0e02b8ceaf31a655dbb2e Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Sun, 13 Apr 2003 19:06:18 +0000 Subject: [PATCH] Initial revision --- src/cf/solaris-fs-rolled.m4 | 16 ++++ src/config/Makefile.alpha_dux51.in | 32 ++++++++ src/config/Makefile.sunx86_58.in | 50 ++++++++++++ src/config/Makefile.sunx86_59.in | 49 ++++++++++++ src/config/param.alpha_dux51.h | 119 ++++++++++++++++++++++++++++ src/config/param.alpha_dux51_usr.h | 67 ++++++++++++++++ src/config/param.sunx86_59.h | 123 +++++++++++++++++++++++++++++ src/config/param.sunx86_59_usr.h | 69 ++++++++++++++++ src/util/softsig.c | 95 ++++++++++++++++++++++ src/util/softsig.h | 16 ++++ 10 files changed, 636 insertions(+) create mode 100644 src/cf/solaris-fs-rolled.m4 create mode 100644 src/config/Makefile.alpha_dux51.in create mode 100644 src/config/Makefile.sunx86_58.in create mode 100644 src/config/Makefile.sunx86_59.in create mode 100644 src/config/param.alpha_dux51.h create mode 100644 src/config/param.alpha_dux51_usr.h create mode 100644 src/config/param.sunx86_59.h create mode 100644 src/config/param.sunx86_59_usr.h create mode 100644 src/util/softsig.c create mode 100644 src/util/softsig.h diff --git a/src/cf/solaris-fs-rolled.m4 b/src/cf/solaris-fs-rolled.m4 new file mode 100644 index 000000000..01d78d0f5 --- /dev/null +++ b/src/cf/solaris-fs-rolled.m4 @@ -0,0 +1,16 @@ +AC_DEFUN(SOLARIS_FS_HAS_FS_ROLLED, [ +AC_MSG_CHECKING(for fs_rolled in struct proc) +AC_CACHE_VAL(ac_cv_solaris_fs_has_fs_rolled, +[ +AC_TRY_COMPILE( +[#include ], +[struct fs _fs; +(void) _fs.fs_rolled;], +ac_cv_solaris_fs_has_fs_rolled=yes, +ac_cv_solaris_fs_has_fs_rolled=no)]) +AC_MSG_RESULT($ac_cv_solaris_fs_has_fs_rolled) +if test "$ac_cv_solaris_fs_has_fs_rolled" = "yes"; then + AC_DEFINE(STRUCT_FS_HAS_FS_ROLLED, 1, [define if struct fs has fs_rolled]) +fi +]) + diff --git a/src/config/Makefile.alpha_dux51.in b/src/config/Makefile.alpha_dux51.in new file mode 100644 index 000000000..f4f1d76b7 --- /dev/null +++ b/src/config/Makefile.alpha_dux51.in @@ -0,0 +1,32 @@ +# Copyright 2000, International Business Machines Corporation and others. +# All Rights Reserved. +# +# This software has been released under the terms of the IBM Public +# License. For details, see the LICENSE file in the top-level source +# directory or online at http://www.openafs.org/dl/license10.html + +AFS_OSTYPE = DUX + +MT_CC=cc +XCFLAGS= -D_NO_PROTO -DOSF +MT_CFLAGS=-D_REENTRANT=1 -pthread -DAFS_PTHREAD_ENV ${XCFLAGS} +SHLIB_SUFFIX=so +SHLIB_CFLAGS= +SHLIB_LINKER=${CC} -all -shared -expect_unresolved "*" +XLIBS=@LIB_AFSDB@ +MTLIBS=-pthread -lpthread -lmach -lexc -lc +NON_SHARED=-non_shared +TXLIBS= -lcurses +LWP_OPTMZ=-O2 +OPTMZ=-O2 +DBG=-g3 +CP=cp +RM=rm +CSTATIC=-non_shared +RANLIB=/bin/true +INSTALL=${TOP_SRCDIR}/pinstall/pinstall + +#this is for the vol package +FS_CONV_OSF40D = fs_conv_dux40D +install_FS_CONV_OSF40D = $(DESTDIR)${afssrvsbindir}/fs_conv_dux40D +dest_FS_CONV_OSF40D = $(DEST)/root.server/usr/afs/bin/fs_conv_dux40D diff --git a/src/config/Makefile.sunx86_58.in b/src/config/Makefile.sunx86_58.in new file mode 100644 index 000000000..7b082e24c --- /dev/null +++ b/src/config/Makefile.sunx86_58.in @@ -0,0 +1,50 @@ +# Keep macros within each section in sorted order for clean diff displays. +# +# AFS_OSTYPE used to indicate suffixes and os specific subdirectories. +AFS_OSTYPE = SOLARIS +# +# compilation and link editor flags +XCFLAGS=-dy -Bdynamic +MT_CFLAGS=-mt -DAFS_PTHREAD_ENV ${XCFLAGS} +PAM_CFLAGS = -KPIC +PAMLIBS= -lc -lpam -lsocket -lnsl -lm +SHLIB_LDFLAGS = -G -Bsymbolic +LWP_OPTMZ=-g +OPTMZ=-O +DBG=-g + +## Compilation flags for 64 bit Solaris +XCFLAGS64 = ${XCFLAGS} -xarch=v9 + +SHLIB_SUFFIX=so +SHLIB_LINKER=${CC} -G -dy -Wl,-Mmapfile -Bsymbolic -z text +# +# libraries +XLIBS=@LIB_AFSDB@ -lsocket -lnsl -lintl -ldl +TXLIBS=-lcurses +MTLIBS=-lpthread -lsocket +XLIBELFA=-lelf +XLIBKVM=-lkvm +# +SHLIB_SUFFIX=so +SHLIB_CFLAGS=-KPIC +# +# programs +AR=/usr/ccs/bin/ar +AS=as +CC=/opt/SUNWspro/bin/cc +MT_CC=/opt/SUNWspro/bin/cc +CP=/bin/cp +LEX=lex +LD= /usr/ccs/bin/ld +LORDER = /usr/ccs/bin/lorder +MV=mv +RANLIB=/bin/true +RM=rm +STRIP= /usr/ccs/bin/strip +INSTALL=${TOP_SRCDIR}/pinstall/pinstall +# +# this is for the vol package +FS_CONV_SOL26 = fs_conv_sol26 +install_FS_CONV_SOL26 = $(DESTDIR)${afssrvsbindir}/fs_conv_sol26 +dest_FS_CONV_SOL26 = $(DEST)/root.server/usr/afs/bin/fs_conv_sol26 diff --git a/src/config/Makefile.sunx86_59.in b/src/config/Makefile.sunx86_59.in new file mode 100644 index 000000000..cf69f345d --- /dev/null +++ b/src/config/Makefile.sunx86_59.in @@ -0,0 +1,49 @@ +# Keep macros within each section in sorted order for clean diff displays. +# +# AFS_OSTYPE used to indicate suffixes and os specific subdirectories. +AFS_OSTYPE = SOLARIS +# +# compilation and link editor flags +XCFLAGS=-dy -Bdynamic +MT_CFLAGS=-mt -DAFS_PTHREAD_ENV ${XCFLAGS} +PAM_CFLAGS = -KPIC +PAMLIBS= -lc -lpam -lsocket -lnsl -lm +LWP_OPTMZ=-g +OPTMZ=-O +DBG=-g + +## Compilation flags for 64 bit Solaris +XCFLAGS64 = ${XCFLAGS} -xarch=v9 + +# +# libraries +XLIBS=@LIB_AFSDB@ -lsocket -lnsl -lintl -ldl +TXLIBS=-lcurses +MTLIBS=-lpthread -lsocket +XLIBELFA=-lelf +XLIBKVM=-lkvm +# +SHLIB_LINKER=${CC} -G -dy -Wl,-Mmapfile -Bsymbolic -z text +SHLIB_SUFFIX=so +SHLIB_CFLAGS=-KPIC +SHLIB_LDFLAGS = -G -Bsymbolic +# +# programs +AR=/usr/ccs/bin/ar +AS=as +CC=/opt/SUNWspro/bin/cc +MT_CC=/opt/SUNWspro/bin/cc +CP=/bin/cp +LEX=lex +LD= /usr/ccs/bin/ld +LORDER = /usr/ccs/bin/lorder +MV=mv +RANLIB=/bin/true +RM=rm +STRIP= /usr/ccs/bin/strip +INSTALL=${TOP_SRCDIR}/pinstall/pinstall +# +# this is for the vol package +FS_CONV_SOL26 = fs_conv_sol26 +install_FS_CONV_SOL26 = $(DESTDIR)${afssrvsbindir}/fs_conv_sol26 +dest_FS_CONV_SOL26 = $(DEST)/root.server/usr/afs/bin/fs_conv_sol26 diff --git a/src/config/param.alpha_dux51.h b/src/config/param.alpha_dux51.h new file mode 100644 index 000000000..f94dff57e --- /dev/null +++ b/src/config/param.alpha_dux51.h @@ -0,0 +1,119 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef AFS_PARAM_H +#define AFS_PARAM_H + +#define AFS_OSF_ENV 1 +#define AFS_OSF20_ENV 1 +#define AFS_OSF30_ENV 1 +#define AFS_OSF32_ENV 1 +#define AFS_OSF32C_ENV 1 +#define AFS_DUX40_ENV 1 +#define AFS_DUX50_ENV 1 +#define AFS_DUX51_ENV 1 +#define __alpha 1 +#define AFS_ALPHA_ENV 1 +#define AFS_DECOSF_ENV 1 +#define AFS_64BIT_ENV 1 + +#include + +#define AFS_VM_RDWR_ENV 1 +#define AFS_VFS_ENV 1 +#define AFS_GREEDY43_ENV 1 +#define AFS_ENV 1 +#define AFS_MINPHYS_ENV 1 +#define CMUSTD_ENV 1 + +#define AFS_SYSCALL 232 +#define AFS_MOUNT_AFS 13 + +#ifndef MOUNT_AFS +#define MOUNT_AFS AFS_MOUNT_AFS +#endif +#define SYS_NAME "alpha_dux51" +#define SYS_NAME_ID SYS_NAME_ID_alpha_dux51 + +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 1 /* System supports statvfs */ + +#define AFS_GCPAGS 1 /* if nonzero, garbage collect PAGs */ + +#ifdef AFS_NAMEI_ENV +#define AFS_64BIT_IOPS_ENV 1 /* needed for NAMEI... */ +#else +#define AFS_3DISPARES 1 /* Utilize the 3 available disk inode spares */ +#endif + +#define AFS_USE_GETTIMEOFDAY 1 /* use gettimeofday to implement rx clock */ + +#if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) +#include +#if BYTE_ORDER == BIG_ENDIAN +#define AFSBIG_ENDIAN 1 +#else +#if BYTE_ORDER == LITTLE_ENDIAN +#define AFSLITTLE_ENDIAN 1 +#else +#error machine/endian.h must define BYTE_ORDER! +#endif +#endif +#endif /* ! ASSEMBLER && ! __LANGUAGE_ASSEMBLY__ */ + +#define NEARINODE_HINT 1 /* hint to ufs module to scatter inodes on disk*/ +#define nearInodeHash(volid, hval) { \ + unsigned char* ts = (unsigned char*)&(volid);\ + for ((hval)=0; ts<(unsigned char*)&(volid)+sizeof(volid);ts++){\ + (hval) *= 173; \ + (hval) += *ts; \ + } \ + } + +/* Extra kernel definitions (from kdefs file) */ +#ifdef _KERNEL +#define AFS_GLOBAL_SUNLOCK 1 +#define AFS_VFS34 1 /* What is VFS34??? */ +#define AFS_SHORTGID 1 /* are group id's short? */ +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_resid uio_resid +#define AFS_UIOSYS UIO_SYSSPACE +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES CLBYTES +#define osi_GetTime(x) microtime(x) +#define AFS_KALLOC(x) kalloc(x) +#define AFS_KFREE(x,y) kfree(x,y) +#define v_count v_usecount +#define v_vfsp v_mount +#define vfs_bsize m_stat.f_bsize +#define vfs_fsid m_stat.f_fsid +#define va_nodeid va_fileid +#define vfs_vnodecovered m_vnodecovered +#define direct dirent +#define vnode_t struct vnode + +#define VN_RELE(vp) vrele(((struct vnode *)(vp))) +#define VN_HOLD(vp) VREF(((struct vnode *)(vp))) + +#if !defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) +enum vcexcl {NONEXCL, EXCL}; + +#include + +#endif /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ */ + +#define memset(A, B, S) bzero(A, S) +#define memcpy(B, A, S) bcopy(A, B, S) +#define memcmp(A, B, S) bcmp(A, B, S) +#endif /* _KERNEL */ + +#endif /* AFS_PARAM_H */ diff --git a/src/config/param.alpha_dux51_usr.h b/src/config/param.alpha_dux51_usr.h new file mode 100644 index 000000000..7aa8d0aaa --- /dev/null +++ b/src/config/param.alpha_dux51_usr.h @@ -0,0 +1,67 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef AFS_PARAM_H +#define AFS_PARAM_H + +#define AFS_VFS_ENV 1 +/* Used only in vfsck code; is it needed any more???? */ +#define RXK_LISTENER_ENV 1 +#define AFS_USERSPACE_IP_ADDR 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + +#define UKERNEL 1 /* user space kernel */ +#define AFS_GREEDY43_ENV 1 /* Used only in rx/rx_user.c */ +#define AFS_64BIT_ENV 1 +#define AFS_ENV 1 +#define AFS_USR_OSF_ENV 1 +#define AFS_USR_DUX40_ENV 1 + +#include + +/*#define AFS_GLOBAL_SUNLOCK 1*/ /* For global locking */ + +#define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */ +#define AFS_SYSCALL 232 + +/* File system entry (used if mount.h doesn't define MOUNT_AFS */ +#define AFS_MOUNT_AFS 1 + +/* Machine / Operating system information */ +#define sys_alpha_dux40 1 +#define SYS_NAME "alpha_dux51" +#define SYS_NAME_ID SYS_NAME_ID_alpha_dux51 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ +#define AFSLITTLE_ENDIAN 1 + +/* Extra kernel definitions (from kdefs file) */ +#ifdef KERNEL +#define AFS_UIOFMODE 1 /* Only in afs/afs_vnodeops.c (afs_ustrategy) */ +#define AFS_SYSVLOCK 1 /* sys v locking supported */ +/*#define AFS_USEBUFFERS 1*/ +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_fmode uio_fmode +#define afsio_resid uio_resid +#define AFS_UIOSYS 1 +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES MCLBYTES +#define AFS_MINCHANGE 2 +#define VATTR_NULL usr_vattr_null +#endif /* KERNEL */ +#define AFS_DIRENT +#ifndef CMSERVERPREF +#define CMSERVERPREF +#endif +#define ROOTINO UFSROOTINO + +#endif /* AFS_PARAM_H */ diff --git a/src/config/param.sunx86_59.h b/src/config/param.sunx86_59.h new file mode 100644 index 000000000..2a95530ff --- /dev/null +++ b/src/config/param.sunx86_59.h @@ -0,0 +1,123 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef AFS_PARAM_H +#define AFS_PARAM_H + +#define AFS_VFS_ENV 1 +/* Used only in vfsck code; is it needed any more???? */ + +#define AFS_VFSINCL_ENV 1 /* NOBODY uses this.... */ +#define AFS_GREEDY43_ENV 1 /* Used only in rx/rx_user.c */ +#define AFS_ENV 1 +#define AFS_SUN_ENV 1 +#define AFS_SUN5_ENV 1 +#define AFS_SUN52_ENV 1 +#define AFS_SUN53_ENV 1 +#define AFS_SUN54_ENV 1 +#define AFS_SUN55_ENV 1 +#define AFS_SUN56_ENV 1 +#define AFS_SUN57_ENV 1 +#define AFS_SUN58_ENV 1 +#define AFS_SUN59_ENV 1 +#define AFS_X86_ENV 1 + +#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */ + +#include + +#define AFS_GLOBAL_SUNLOCK 1 /* For global locking */ +#define RXK_LISTENER_ENV 1 +#define AFS_GCPAGS 1 /* if nonzero, garbage collect PAGs */ + +#ifdef AFS_NAMEI_ENV +#define AFS_64BIT_IOPS_ENV 1 /* needed for NAMEI... */ +#else /* AFS_NAMEI_ENV */ +#define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */ +#endif /* AFS_NAMEI_ENV */ + +#define AFS_SYSCALL 65 + +/* File system entry (used if mount.h doesn't define MOUNT_AFS */ +#define AFS_MOUNT_AFS "afs" + +/* Machine / Operating system information */ +#define sys_sunx86_59 1 +#define SYS_NAME "sunx86_59" +#define SYS_NAME_ID SYS_NAME_ID_sunx86_59 +#define AFSLITTLE_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_VXFS 1 /* Support cache on Veritas vxfs file system */ +#define AFS_HAVE_STATVFS 1 /* System supports statvfs */ +#define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ +#define AFS_USE_GETTIMEOFDAY 1 /* use gettimeofday to implement rx clock */ + +#define NEARINODE_HINT 1 /* hint to ufs module to scatter inodes on disk*/ +#define nearInodeHash(volid, hval) { \ + unsigned char* ts = (unsigned char*)&(volid)+sizeof(volid)-1;\ + for ( (hval)=0; ts >= (unsigned char*)&(volid); ts--){\ + (hval) *= 173; \ + (hval) += *ts; \ + } \ + } + +/* Extra kernel definitions (from kdefs file) */ +#ifdef KERNEL +/* sun definitions here */ +#define AFS_UIOFMODE 1 /* Only in afs/afs_vnodeops.c (afs_ustrategy) */ +#define AFS_SYSVLOCK 1 /* sys v locking supported */ +/*#define AFS_USEBUFFERS 1*/ +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_fmode uio_fmode +#define afsio_resid uio_resid +#define AFS_UIOSYS UIO_SYSSPACE +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES MCLBYTES +#define AFS_MINCHANGE 2 +#define osi_GetTime(x) uniqtime(x) + +/** + * These defines are for the 64 bit Solaris 7 port + * AFS_SYSCALL32 is used to protect the ILP32 syscall interface + * AFS_64BIT_ENV is for use of 64 bit inode numbers + */ +#if defined(__sparcv9) +#define AFS_SUN57_64BIT_ENV 1 +#define AFS_64BIT_INO 1 +#endif + +/** + * Solaris 7 64 bit has two versions of uniqtime. Since we consistently + * use 32 bit quantities for time in afs, we now use uniqtime32 + */ +#if defined(AFS_SUN57_64BIT_ENV) +#undef osi_GetTime +#define osi_GetTime(x) uniqtime32(x) +#endif + + + +#define AFS_KALLOC(n) kmem_alloc(n, KM_SLEEP) +#define AFS_KALLOC_NOSLEEP(n) kmem_alloc(n, KM_NOSLEEP) +#define AFS_KFREE kmem_free +#define VATTR_NULL vattr_null +#define memset(A, B, S) bzero(A, S) +#define memcpy(B, A, S) bcopy(A, B, S) +#define memcmp(A, B, S) bcmp(A, B, S) +#endif /* KERNEL */ +#define AFS_DIRENT +#ifndef CMSERVERPREF +#define CMSERVERPREF +#endif +#define ROOTINO UFSROOTINO + +#endif /* AFS_PARAM_H */ diff --git a/src/config/param.sunx86_59_usr.h b/src/config/param.sunx86_59_usr.h new file mode 100644 index 000000000..76b0f5cfd --- /dev/null +++ b/src/config/param.sunx86_59_usr.h @@ -0,0 +1,69 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef AFS_PARAM_H +#define AFS_PARAM_H + +#define AFS_VFS_ENV 1 +/* Used only in vfsck code; is it needed any more???? */ +#define RXK_LISTENER_ENV 1 +#define AFS_USERSPACE_IP_ADDR 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + +#define UKERNEL 1 /* user space kernel */ +#define AFS_GREEDY43_ENV 1 /* Used only in rx/rx_user.c */ +#define AFS_ENV 1 +#define AFS_USR_SUN5_ENV 1 +#define AFS_USR_SUN6_ENV 1 +#define AFS_USR_SUN7_ENV 1 +#define AFS_USR_SUN8_ENV 1 +#define AFS_USR_SUN9_ENV 1 + +#include + +/*#define AFS_GLOBAL_SUNLOCK 1 /* For global locking */ + +#define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */ +#define AFS_SYSCALL 65 + +/* File system entry (used if mount.h doesn't define MOUNT_AFS */ +#define AFS_MOUNT_AFS 1 + +/* Machine / Operating system information */ +#define sys_sunx86_59 1 +#define SYS_NAME "sunx86_59" +#define SYS_NAME_ID SYS_NAME_ID_sunx86_59 +#define AFSLITTLE_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ + +/* Extra kernel definitions (from kdefs file) */ +#ifdef KERNEL +#define AFS_UIOFMODE 1 /* Only in afs/afs_vnodeops.c (afs_ustrategy) */ +#define AFS_SYSVLOCK 1 /* sys v locking supported */ +/*#define AFS_USEBUFFERS 1*/ +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_fmode uio_fmode +#define afsio_resid uio_resid +#define AFS_UIOSYS 1 +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES MCLBYTES +#define AFS_MINCHANGE 2 +#define VATTR_NULL usr_vattr_null +#endif /* KERNEL */ +#define AFS_DIRENT +#ifndef CMSERVERPREF +#define CMSERVERPREF +#endif +#define ROOTINO UFSROOTINO + +#endif /* AFS_PARAM_H */ diff --git a/src/util/softsig.c b/src/util/softsig.c new file mode 100644 index 000000000..886a61f76 --- /dev/null +++ b/src/util/softsig.c @@ -0,0 +1,95 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#define _POSIX_PTHREAD_SEMANTICS +#include +#include +#include +#include +#include + +static pthread_t softsig_tid; +static struct { + void (*handler) (int); + int pending; +} softsig_sigs[NSIG]; + +static void * +softsig_thread (void *arg) +{ + sigset_t ss; + + sigemptyset (&ss); + sigaddset (&ss, SIGUSR1); + + while (1) { + void (*h) (int) = NULL; + int i, sigw; + + for (i = 0; i < NSIG; i++) + if (softsig_sigs[i].pending) { + softsig_sigs[i].pending = 0; + h = softsig_sigs[i].handler; + break; + } + + if (i == NSIG) + assert (0 == sigwait (&ss, &sigw)); + else if (h) + h (i); + } +} + +void +softsig_init () +{ + sigset_t ss, os; + + sigemptyset (&ss); + sigaddset (&ss, SIGUSR1); + + /* Set mask right away, so we don't accidentally SIGUSR1 the + * softsig thread and cause an exit (default action). + */ + assert (0 == pthread_sigmask (SIG_BLOCK, &ss, &os)); + assert (0 == pthread_create (&softsig_tid, NULL, &softsig_thread, NULL)); + assert (0 == pthread_sigmask (SIG_SETMASK, &os, NULL)); +} + +static void +softsig_handler (int signo) +{ + softsig_sigs[signo].pending = 1; + pthread_kill (softsig_tid, SIGUSR1); +} + +void +softsig_signal (int signo, void (*handler) (int)) +{ + softsig_sigs[signo].handler = handler; + signal (signo, softsig_handler); +} + +#if defined(TEST) +static void +print_foo (int signo) +{ + printf ("foo, signo = %d, tid = %d\n", signo, pthread_self ()); +} + +int +main () +{ + softsig_init (); + softsig_signal (SIGINT, print_foo); + printf ("main is tid %d\n", pthread_self ()); + while (1) + sleep (60); +} +#endif diff --git a/src/util/softsig.h b/src/util/softsig.h new file mode 100644 index 000000000..53af0d318 --- /dev/null +++ b/src/util/softsig.h @@ -0,0 +1,16 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef _SOFTSIG_H +#define _SOFTSIG_H + +void softsig_init (); +void softsig_signal (int signo, void (*handler) (int)); + +#endif -- 2.39.5