From 83b6575648535ccdc4973ab24240a5b3dfc2f0d4 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 2 Aug 2006 17:47:29 +0000 Subject: [PATCH] kopenafs-20060802 Add a shared libkopenafs that provides k_hasafs, k_setpag, k_unlog, and k_pioctl (in other words, enough for a PAM session module that calls an external aklog). --- Makefile.in | 9 ++- acinclude.m4 | 8 ++- configure.in | 1 + src/kopenafs/.cvsignore | 5 ++ src/kopenafs/Makefile.in | 137 ++++++++++++++++++++++++++++++++++++++++ src/kopenafs/kopenafs.c | 88 ++++++++++++++++++++++++++ src/kopenafs/kopenafs.exp | 4 ++ src/kopenafs/kopenafs.h | 53 ++++++++++++++++ src/kopenafs/mapfile | 13 ++++ src/kopenafs/test-setpag.c | 33 ++++++++++ src/kopenafs/test-unlog.c | 29 +++++++++ src/libafsauthent/Makefile.in | 6 +- src/pam/Makefile.in | 8 +-- src/shlibafsauthent/Makefile.in | 6 +- src/sys/Makefile.in | 5 +- src/sys/afssyscalls.c | 57 ----------------- src/sys/glue.c | 27 ++++++++ src/sys/pioctl.c | 72 +++++++++++++++++++++ 18 files changed, 491 insertions(+), 70 deletions(-) create mode 100644 src/kopenafs/.cvsignore create mode 100644 src/kopenafs/Makefile.in create mode 100644 src/kopenafs/kopenafs.c create mode 100644 src/kopenafs/kopenafs.exp create mode 100644 src/kopenafs/kopenafs.h create mode 100644 src/kopenafs/mapfile create mode 100644 src/kopenafs/test-setpag.c create mode 100644 src/kopenafs/test-unlog.c create mode 100644 src/sys/pioctl.c diff --git a/Makefile.in b/Makefile.in index 6b88e7b..8296a67 100644 --- a/Makefile.in +++ b/Makefile.in @@ -508,6 +508,9 @@ shlibafsauthent: ubik auth kauth shlibafsrpc echo Not building shared libafsauthent for ${SYS_NAME} ;; \ esac +kopenafs: config sys + ${COMPILE_PART1} kopenafs ${COMPILE_PART2} + libadmin_real: ${COMPILE_PART1} libadmin ${COMPILE_PART2} ${COMPILE_PART1} libadmin/adminutil ${COMPILE_PART2} @@ -550,14 +553,14 @@ finale: project cmd comerr afsd butc tbutc @ENABLE_KERNEL_MODULE@ libuafs audit ptserver scout bu_utils ubik uss bozo vfsck volser tvolser tsalvaged \ venus update xstat afsmonitor rxdebug libafsrpc \ libafsauthent shlibafsrpc shlibafsauthent libadmin man-pages \ - platform + platform kopenafs ${COMPILE_PART1} finale ${COMPILE_PART2} finale_nolibafs: project cmd comerr afsd butc tbutc libuafs audit kauth log \ ptserver scout bu_utils ubik uss bozo vfsck volser tvolser tsalvaged \ venus update xstat afsmonitor rxdebug libafsrpc \ libafsauthent shlibafsrpc shlibafsauthent libadmin man-pages \ - platform + platform kopenafs ${COMPILE_PART1} finale ${COMPILE_PART2} # Use washtool to ensure MakefileProto is current and obj/libafs exists. @@ -645,6 +648,7 @@ clean2: -${COMPILE_PART1} libafsauthent ${COMPILE_CLEAN} -${COMPILE_PART1} shlibafsrpc ${COMPILE_CLEAN} -${COMPILE_PART1} shlibafsauthent ${COMPILE_CLEAN} + -${COMPILE_PART1} kopenafs ${COMPILE_CLEAN} -${COMPILE_PART1} libadmin ${COMPILE_CLEAN} -${COMPILE_PART1} libadmin/adminutil ${COMPILE_CLEAN} -${COMPILE_PART1} libadmin/client ${COMPILE_CLEAN} @@ -706,6 +710,7 @@ distclean: clean src/gtx/Makefile \ src/kauth/test/Makefile \ src/kauth/Makefile \ + src/kopenafs/Makefile \ src/libacl/test/Makefile \ src/libacl/Makefile \ src/libadmin/adminutil/Makefile \ diff --git a/acinclude.m4 b/acinclude.m4 index 0d25700..3298140 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1050,8 +1050,14 @@ if test "$ac_cv_header_regex_h" = "yes" && \ else AC_MSG_RESULT(no) fi - + +AC_TYPE_SIGNAL AC_CHECK_TYPE(ssize_t, int) +AC_CHECK_TYPE([sig_atomic_t], , + [AC_DEFINE([sig_atomic_t], [int], + [Define to int if does not define.])], +[#include +#include ]) AC_SIZEOF_TYPE(long) AC_MSG_CHECKING(size of time_t) diff --git a/configure.in b/configure.in index b66f316..f55a83b 100644 --- a/configure.in +++ b/configure.in @@ -49,6 +49,7 @@ src/gtx/Makefile \ src/JAVA/libjafs/Makefile \ src/kauth/Makefile \ src/kauth/test/Makefile \ +src/kopenafs/Makefile \ src/libacl/Makefile \ src/libacl/test/Makefile \ src/libadmin/adminutil/Makefile \ diff --git a/src/kopenafs/.cvsignore b/src/kopenafs/.cvsignore new file mode 100644 index 0000000..88e4cc6 --- /dev/null +++ b/src/kopenafs/.cvsignore @@ -0,0 +1,5 @@ +AFS_component_version_number.c +Makefile +libkopenafs.* +test-setpag +test-unlog diff --git a/src/kopenafs/Makefile.in b/src/kopenafs/Makefile.in new file mode 100644 index 0000000..eb470ed --- /dev/null +++ b/src/kopenafs/Makefile.in @@ -0,0 +1,137 @@ +# 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 +# +# Portions Copyright (c) 2003 Apple Computer, Inc. + +srcdir=@srcdir@ +include @TOP_OBJDIR@/src/config/Makefile.config + +# API version. When something changes, increment as appropriate. +# Ignore at your own risk. +MAJOR = 1 +MINOR = 0 + +CC = ${MT_CC} +INCLUDES = -I. -I${srcdir} -I../sys +CFLAGS = ${COMMON_CFLAGS} ${INCLUDES} ${MT_CFLAGS} ${SHLIB_CFLAGS} + +SYS = ${srcdir}/../sys +SYSOBJS = glue.o pioctl.o setpag.o syscall.o +LIBOBJS = kopenafs.o ${SYSOBJS} AFS_component_version_number.o + +LIBKOPENAFS = libkopenafs.${SHLIB_SUFFIX}.${MAJOR}.${MINOR} + +all: ${TOP_LIBDIR}/${LIBKOPENAFS} ${TOP_LIBDIR}/libkopenafs.a \ + ${TOP_INCDIR}/kopenafs.h + +${TOP_LIBDIR}/${LIBKOPENAFS}: ${LIBKOPENAFS} + ${INSTALL_DATA} ${LIBKOPENAFS} ${TOP_LIBDIR}/${LIBKOPENAFS} + -ln -f -s ${LIBKOPENAFS} \ + ${TOP_LIBDIR}/libkopenafs.${SHLIB_SUFFIX} + -ln -f -s ${LIBKOPENAFS} \ + ${TOP_LIBDIR}/libkopenafs.${SHLIB_SUFFIX}.${MAJOR} + +${TOP_LIBDIR}/libkopenafs.a: libkopenafs.a + ${INSTALL_DATA} libkopenafs.a $@ + +${TOP_INCDIR}/kopenafs.h: kopenafs.h + ${INSTALL_DATA} kopenafs.h $@ + +glue.o: ${SYS}/glue.c ${SYS}/afssyscalls.h + ${CCOBJ} ${CFLAGS} -c ${SYS}/glue.c + +pioctl.o: ${SYS}/pioctl.c ${SYS}/afssyscalls.h + ${CCOBJ} ${CFLAGS} -c ${SYS}/pioctl.c + +setpag.o: ${SYS}/setpag.c ${SYS}/afssyscalls.h + ${CCOBJ} ${CFLAGS} -c ${SYS}/setpag.c + +# This file is only actually used on SGI and AIX, but some systems can't cope +# with an empty .o file being included in a link. +syscall.o: ${SYS}/syscall.s + @set -x; case "$(SYS_NAME)" in \ + sgi_*) \ + ${CC} ${CFLAGS} -c ${SYS}/syscall.s; \ + ;; \ + *fbsd* | *obsd* | *nbsd*) \ + ${CCOBJ} -E ${SFLAGS} syscall.s > syscall.S ; \ + ${AS} syscall.S -o syscall.o ; \ + $(RM) -f syscall.S; \ + ;; \ + rs_aix*) \ + /lib/cpp -P ${SFLAGS} ${srcdir}/syscall.s syscall.ss; \ + as -o syscall.o syscall.ss; \ + $(RM) syscall.ss; \ + ;; \ + *) \ + touch syscall.o; \ + ;; \ + esac + +libkopenafs.a: ${LIBOBJS} + ${RM} -f $@ + ${AR} crv $@ ${LIBOBJS} + ${RANLIB} $@ + +${LIBKOPENAFS}: ${LIBOBJS} + case ${SYS_NAME} in \ + rs_aix*) \ + ${SHLIB_LINKER} -o ${LIBKOPENAFS} ${LIBOBJS} \ + -bE:${srcdir}/kopenafs.exp ${MT_LIBS}; \ + ;; \ + sun*_5*) \ + ${SHLIB_LINKER} -h libafsrpc.${SHLIB_SUFFIX}.${MAJOR} \ + -o ${LIBKOPENAFS} ${LIBOBJS} ${MT_LIBS}; \ + ;; \ + *_linux*) \ + ${SHLIB_LINKER} -Wl,-h,libafsrpc.${SHLIB_SUFFIX}.${MAJOR} \ + -Wl,--version-script=${srcdir}/mapfile \ + -o ${LIBKOPENAFS} ${LIBOBJS} ${MT_LIBS}; \ + ;; \ + *) \ + ${SHLIB_LINKER} -o ${LIBKOPENAFS} ${LIBOBJS} ${MT_LIBS}; \ + ;; \ + esac + +test-unlog: test-unlog.o libkopenafs.a + ${CC} -o test-unlog test-unlog.o libkopenafs.a ${XLIBS} ${CFLAGS} + +test-setpag: test-setpag.o libkopenafs.a + ${CC} -o test-setpag test-setpag.o libkopenafs.a ${XLIBS} ${CFLAGS} + +# +# Installation targets +# +install: ${LIBKOPENAFS} + ${INSTALL} -d ${DESTDIR}${libdir} + ${INSTALL} -d ${DESTDIR}${includedir} + ${INSTALL_DATA} libkopenafs.a ${DESTDIR}${libdir}/libkopenafs.a + ${INSTALL_DATA} ${LIBKOPENAFS} ${DESTDIR}${libdir}/${LIBKOPENAFS} + -ln -f -s ${LIBKOPENAFS} \ + ${DESTDIR}${libdir}/libkopenafs.${SHLIB_SUFFIX} + -ln -f -s ${LIBKOPENAFS} \ + ${DESTDIR}${libdir}/libkopenafs.${SHLIB_SUFFIX}.${MAJOR} + ${INSTALL_DATA} kopenafs.h ${DESTDIR}${includedir}/kopenafs.h + +dest: ${LIBKOPENAFS} + ${INSTALL} -d ${DEST}/lib + ${INSTALL} -d ${DEST}/include + ${INSTALL_DATA} libkopenafs.a ${DEST}/lib/libkopenafs.a + ${INSTALL_DATA} ${LIBKOPENAFS} ${DEST}/lib/${LIBKOPENAFS} + -ln -f -s ${LIBKOPENAFS} \ + ${DEST}/lib/libkopenafs.${SHLIB_SUFFIX} + -ln -f -s ${LIBKOPENAFS} \ + ${DEST}/lib/libkopenafs.${SHLIB_SUFFIX}.${MAJOR} + ${INSTALL_DATA} kopenafs.h ${DEST}/include/kopenafs.h + +# +# Misc targets +# +clean: + $(RM) -f *.o *.a ${LIBKOPENAFS} AFS_component_version_number.c + +include ../config/Makefile.version diff --git a/src/kopenafs/kopenafs.c b/src/kopenafs/kopenafs.c new file mode 100644 index 0000000..84f2b36 --- /dev/null +++ b/src/kopenafs/kopenafs.c @@ -0,0 +1,88 @@ +/* + * 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 + */ + +/* + * Glue code for the kopenafs API. Mostly just wrappers around the functions + * included in the libsys code. + */ + +#include +#include +#include +#include + +#include +#include +#include + +static volatile sig_atomic_t syscall_okay = 1; + +/* Signal handler to catch failed system calls and change the okay flag. */ +#ifdef SIGSYS +static RETSIGTYPE +sigsys_handler(int s) +{ + syscall_okay = 0; + signal(SIGSYS, sigsys_handler); +} +#endif /* SIGSYS */ + +int +k_hasafs(void) +{ + struct ViceIoctl iob; + int okay, saved_errno; + RETSIGTYPE (*saved_func)(int); + + saved_errno = errno; + +#ifdef SIGSYS + saved_func = signal(SIGSYS, sigsys_handler); +#endif + + iob.in = NULL; + iob.in_size = 0; + iob.out = NULL; + iob.out_size = 0; + lpioctl(NULL, VIOCSETTOK, (char *) &iob, 0); + +#ifdef SIGSYS + signal(SIGSYS, saved_func); +#endif + + okay = 1; + if (!syscall_okay || errno != EINVAL) + okay = 0; + errno = saved_errno; + return okay; +} + +int +k_setpag(void) +{ + return lsetpag(); +} + +int +k_pioctl(char *path, int cmd, struct ViceIoctl *cmarg, int follow) +{ + return lpioctl(path, cmd, (char *) cmarg, follow); +} + +int +k_unlog(void) +{ + struct ViceIoctl iob; + + iob.in = NULL; + iob.in_size = 0; + iob.out = NULL; + iob.out_size = 0; + return lpioctl(NULL, VIOCUNLOG, (char *) &iob, 0); +} diff --git a/src/kopenafs/kopenafs.exp b/src/kopenafs/kopenafs.exp new file mode 100644 index 0000000..5cfc102 --- /dev/null +++ b/src/kopenafs/kopenafs.exp @@ -0,0 +1,4 @@ +k_hasafs +k_setpag +k_unlog +k_pioctl diff --git a/src/kopenafs/kopenafs.h b/src/kopenafs/kopenafs.h new file mode 100644 index 0000000..cfa2aa4 --- /dev/null +++ b/src/kopenafs/kopenafs.h @@ -0,0 +1,53 @@ +/* + * 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 + */ + +/* + * This file defines the interface to the libkopenafs library, which provides + * a reduced set of functions for compatibility with the Heimdal/KTH libkafs + * library. This interface and the corresponding library are the best way to + * get a completely standalone setpag() function from OpenAFS (in the form of + * the k_setpag() interface defined here). + * + * The calls here only work on systems with native AFS clients and *will not* + * work through the NFS translator. + */ + +#ifndef KOPENAFS_H +#define KOPENAFS_H 1 + +/* Get the VIOC* constants and struct ViceIoctl. */ +#include + +/* + * Initialization function. Returns true if AFS is available on the system + * and false otherwise. Should be called before any of the other functions, + * and if it returns false, the other functions should not be called. + */ +int k_hasafs(void); + +/* + * Create a new PAG and put the current process in it. Returns 0 on success, + * non-zero on system call failure. Equivalent to lsetpag(). + */ +int k_setpag(void); + +/* + * Remove the tokens in the current PAG. Returns 0 on success, non-zero on + * system call failure. + */ +int k_unlog(void); + +/* + * Perform an arbitrary pioctl system call with the specified arguments. + * Returns 0 on success, non-zero on system call failure. Equivalent to + * lpioctl(). + */ +int k_pioctl(char *path, int cmd, struct ViceIoctl *cmarg, int follow); + +#endif /* KOPENAFS_H */ diff --git a/src/kopenafs/mapfile b/src/kopenafs/mapfile new file mode 100644 index 0000000..2220a04 --- /dev/null +++ b/src/kopenafs/mapfile @@ -0,0 +1,13 @@ +# Export map for libkopenafs, used on Linux and Solaris to restrict +# exports from the shared libraries to just the public ABI. Add symbol +# versioning while we're at it, just in case. + +KOPENAFS_1.0 { + global: + k_hasafs; + k_setpag; + k_unlog; + k_pioctl; + local: + *; +}; diff --git a/src/kopenafs/test-setpag.c b/src/kopenafs/test-setpag.c new file mode 100644 index 0000000..dc11673 --- /dev/null +++ b/src/kopenafs/test-setpag.c @@ -0,0 +1,33 @@ +/* + * 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 + */ + +/* + * Test the kopenafs setpag support. + */ + +#include +#include + +int +main(int argc, char *argv[]) +{ + int status; + + if (k_hasafs()) { + printf("Running k_setpag\n"); + status = k_setpag(); + printf("Status: %d, errno: %d\n", status, errno); + if (argc > 1) { + argv++; + execvp(argv[0], argv); + } + } else { + printf("AFS apparently not running\n"); + } +} diff --git a/src/kopenafs/test-unlog.c b/src/kopenafs/test-unlog.c new file mode 100644 index 0000000..790cc53 --- /dev/null +++ b/src/kopenafs/test-unlog.c @@ -0,0 +1,29 @@ +/* + * 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 + */ + +/* + * Test the kopenafs unlog support. + */ + +#include +#include + +int +main(void) +{ + int status; + + if (k_hasafs()) { + printf("Running k_unlog\n"); + status = k_unlog(); + printf("Status: %d, errno: %d\n", status, errno); + } else { + printf("AFS apparently not running\n"); + } +} diff --git a/src/libafsauthent/Makefile.in b/src/libafsauthent/Makefile.in index 180e95c..3794aca 100644 --- a/src/libafsauthent/Makefile.in +++ b/src/libafsauthent/Makefile.in @@ -72,7 +72,8 @@ SYSOBJS = \ afssyscalls.o \ rmtsysnet.o \ glue.o \ - setpag.o + setpag.o \ + pioctl.o PTSERVEROBJS = \ ptclient.o \ @@ -250,6 +251,9 @@ glue.o: ${SYS}/glue.c setpag.o: ${SYS}/setpag.c ${CCRULE} +pioctl.o: ${SYS}/pioctl.c + ${CCRULE} + clean: $(RM) -f *.o *.a libafsauthent* diff --git a/src/pam/Makefile.in b/src/pam/Makefile.in index 5934724..024f384 100644 --- a/src/pam/Makefile.in +++ b/src/pam/Makefile.in @@ -27,13 +27,7 @@ LDFLAGS = ${SHLIB_LDFLAGS} INCLUDES=-I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} CFLAGS = ${PAM_DBG} ${PAM_OPTMZ} ${INCLUDES} ${PAM_CFLAGS} -all: test_pam ${TOP_LIBDIR}/pam_afs.so.1 ${TOP_LIBDIR}/pam_afs.krb.so.1 - -${TOP_LIBDIR}/pam_afs.so.1: pam_afs.so.1 - ${INSTALL_DATA} $? $@ - -${TOP_LIBDIR}/pam_afs.krb.so.1: pam_afs.krb.so.1 - ${INSTALL_DATA} $? $@ +all: test_pam pam_afs.so.1 pam_afs.krb.so.1 afs_setcred.o: afs_setcred.c afs_pam_msg.h afs_message.h afs_util.h ${CC} ${CFLAGS} -c ${srcdir}/afs_setcred.c -o afs_setcred.o diff --git a/src/shlibafsauthent/Makefile.in b/src/shlibafsauthent/Makefile.in index 1784291..302cc4e 100644 --- a/src/shlibafsauthent/Makefile.in +++ b/src/shlibafsauthent/Makefile.in @@ -77,7 +77,8 @@ SYSOBJS = \ afssyscalls.o \ rmtsysnet.o \ glue.o \ - setpag.o + setpag.o \ + pioctl.o PTSERVEROBJS = \ ptclient.o \ @@ -276,5 +277,8 @@ glue.o: ${SYS}/glue.c setpag.o: ${SYS}/setpag.c ${CCRULE} +pioctl.o: ${SYS}/pioctl.c + ${CCRULE} + clean: $(RM) -f *.o *.a libafsauthent* diff --git a/src/sys/Makefile.in b/src/sys/Makefile.in index 78f81f8..09e366d 100644 --- a/src/sys/Makefile.in +++ b/src/sys/Makefile.in @@ -19,7 +19,7 @@ CFLAGS=-I. -I${srcdir} ${DBUG} -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} ${XCF SFLAGS=-I${TOP_INCDIR} LIBS=libsys.a ${TOP_LIBDIR}/librx.a libsys.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/util.a ${XLIBS} -OBJECTS= afssyscalls.o setpag.o glue.o syscall.o +OBJECTS= afssyscalls.o setpag.o pioctl.o glue.o syscall.o SHLIBOBJS = picobj/setpag.o picobj/glue.o syscall.o RMTOBJS=rmtsysnet.o rmtsysc.o rmtsys.cs.o rmtsys.xdr.o rmtsys.ss.o rmtsyss.o @@ -124,6 +124,9 @@ glue.o: glue.c afssyscalls.h setpag.o: setpag.c afssyscalls.h ${CCOBJ} ${CFLAGS} -c ${srcdir}/setpag.c +pioctl.o: pioctl.c afssyscalls.h + ${CCOBJ} ${CFLAGS} -c ${srcdir}/pioctl.c + rmtsysnet.o rmtsysc.o rmtsyss.o rmtsysd.o: rmtsys.h rmtsysd: AFS_component_version_number.o afs.exp afsl.exp diff --git a/src/sys/afssyscalls.c b/src/sys/afssyscalls.c index e2335d4..8266adf 100644 --- a/src/sys/afssyscalls.c +++ b/src/sys/afssyscalls.c @@ -59,7 +59,6 @@ static void check_iops(int index, char *fun, char *file, int line); #pragma weak xiinc = iinc #pragma weak xidec = idec #pragma weak xiopen = iopen -#pragma weak xlpioctl = lpioctl #ifdef notdef #pragma weak xiread = iread #pragma weak xiwrite = iwrite @@ -204,11 +203,6 @@ iwrite(int dev, int inode, int inode_p1, unsigned int offset, char *cbuf, } #endif /* notdef */ -int -lpioctl(char *path, int cmd, char *cmarg, int follow) -{ - return (syscall(AFS_PIOCTL, path, cmd, cmarg, follow)); -} #else /* AFS_SGI_ENV */ #ifndef AFS_NAMEI_ENV @@ -307,57 +301,6 @@ iwrite(int dev, int inode, int inode_p1, unsigned int offset, char *cbuf, #endif /* AFS_NAMEI_ENV */ -#if defined(AFS_DARWIN80_ENV) -int ioctl_afs_syscall(long syscall, long param1, long param2, long param3, - long param4, long param5, long param6, int *rval) { - struct afssysargs syscall_data; - int code; - int fd = open(SYSCALL_DEV_FNAME, O_RDWR); - if(fd < 0) - return -1; - - syscall_data.syscall = syscall; - syscall_data.param1 = param1; - syscall_data.param2 = param2; - syscall_data.param3 = param3; - syscall_data.param4 = param4; - syscall_data.param5 = param5; - syscall_data.param6 = param6; - - code = ioctl(fd, VIOC_SYSCALL, &syscall_data); - - close(fd); - if (code) - return code; - *rval=syscall_data.retval; - return 0; -} -#endif - -int -lpioctl(char *path, int cmd, char *cmarg, int follow) -{ - int errcode, rval; - -#if defined(AFS_LINUX20_ENV) - rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, - follow, &errcode); - - if(rval) - errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, - follow); -#elif defined(AFS_DARWIN80_ENV) - rval = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, - follow, 0, 0, &errcode); - if (rval) - errcode = rval; -#else - errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow); -#endif - - return (errcode); -} - #endif /* !AFS_SGI_ENV */ #endif /* !AFS_AIX32_ENV */ diff --git a/src/sys/glue.c b/src/sys/glue.c index fd6cec6..cf92c61 100644 --- a/src/sys/glue.c +++ b/src/sys/glue.c @@ -53,3 +53,30 @@ int proc_afs_syscall(long syscall, long param1, long param2, long param3, return 0; } #endif + +#if defined(AFS_DARWIN80_ENV) +int ioctl_afs_syscall(long syscall, long param1, long param2, long param3, + long param4, long param5, long param6, int *rval) { + struct afssysargs syscall_data; + int code; + int fd = open(SYSCALL_DEV_FNAME, O_RDWR); + if(fd < 0) + return -1; + + syscall_data.syscall = syscall; + syscall_data.param1 = param1; + syscall_data.param2 = param2; + syscall_data.param3 = param3; + syscall_data.param4 = param4; + syscall_data.param5 = param5; + syscall_data.param6 = param6; + + code = ioctl(fd, VIOC_SYSCALL, &syscall_data); + + close(fd); + if (code) + return code; + *rval=syscall_data.retval; + return 0; +} +#endif diff --git a/src/sys/pioctl.c b/src/sys/pioctl.c new file mode 100644 index 0000000..9260c06 --- /dev/null +++ b/src/sys/pioctl.c @@ -0,0 +1,72 @@ +/* + * 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 + */ + +/* + * The lpioctl system call. (pioctl is handled by the rmtsys layer and turned + * into either lpioctl or a remote call as appropriate.) It is kept separate + * to allow for the creation of the libkopenafs shared library without + * including the other system calls. + */ + +#include +#include + +#include +#if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV) +#include +#else +#include +#endif +#include "afssyscalls.h" + +#ifdef AFS_AIX32_ENV +/* + * in VRMIX, system calls look just like function calls, so we don't + * need to do anything! + */ + +#else +#if defined(AFS_SGI_ENV) + +#pragma weak xlpioctl = lpioctl + +int +lpioctl(char *path, int cmd, char *cmarg, int follow) +{ + return (syscall(AFS_PIOCTL, path, cmd, cmarg, follow)); +} + +#else /* AFS_SGI_ENV */ + +int +lpioctl(char *path, int cmd, char *cmarg, int follow) +{ + int errcode, rval; + +#if defined(AFS_LINUX20_ENV) + rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, + follow, &errcode); + + if(rval) + errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, + follow); +#elif defined(AFS_DARWIN80_ENV) + rval = ioctl_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg, + follow, 0, 0, &errcode); + if (rval) + errcode = rval; +#else + errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg, follow); +#endif + + return (errcode); +} + +#endif /* !AFS_SGI_ENV */ +#endif /* !AFS_AIX32_ENV */ -- 1.9.4