AFS-PAG
view release on metacpan or search on metacpan
kafs/kafs.c view on Meta::CPAN
/*
* kafs replacement, main API.
*
* This is a simple implementation of the k_hasafs, k_setpag, and k_unlog
* functions. It is for use on systems that don't have libkafs or
* libkopenafs, or where a dependency on those libraries is not desirable for
* some reason.
*
* A more robust implementation of the full kafs interface would have a
* separate header file with the various system call constants and would
* support more operations and the k_pioctl interface. Since this is a
* stripped-down implementation with only the few functions to do PAG
* management, various interface constants and system call numbers are
* hard-coded here.
*
* The canonical version of this file is maintained in the rra-c-util package,
* which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
* Copyright 2006, 2007, 2009
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <config.h>
#include <portable/kafs.h>
#include <portable/system.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#ifdef HAVE_SYS_IOCCOM_H
# include <sys/ioccom.h>
#endif
#include <sys/ioctl.h>
#include <sys/stat.h>
/* Used for unused parameters to silence gcc warnings. */
#define UNUSED __attribute__((__unused__))
/* Provided by the relevant sys-*.c file. */
static int k_syscall(long, long, long, long, long, int *);
/*
* Include the syscall implementation for this host, based on the configure
* results. An include of the C source is easier to handle in the build
* machinery than lots of Automake conditionals.
*
* The included file must provide a k_syscall implementation.
*/
#if defined(HAVE_KAFS_DARWIN8)
# include <kafs/sys-darwin8.c>
#elif defined(HAVE_KAFS_DARWIN10)
# include <kafs/sys-darwin10.c>
#elif defined(HAVE_KAFS_LINUX)
# include <kafs/sys-linux.c>
#elif defined(HAVE_KAFS_SOLARIS)
# include <kafs/sys-solaris.c>
#elif defined(HAVE_KAFS_SYSCALL)
# include <kafs/sys-syscall.c>
#else
# error "Unknown AFS system call implementation"
#endif
/*
* On some platforms, k_hasafs needs to try a system call. This attempt may
* fail with SIGSYS. We therefore set a signal handler that changes a static
* variable if SIGSYS is received.
*
* It's really ugly to do this in library or PAM module in so many ways.
* Static variables are evil, changing signal handlers out from under an
* application is evil, and the interaction of signals and threads is probably
* nasty. The only things that make this better is that this case will never
* be triggered in the normal case of AFS being loaded and the only time that
( run in 2.680 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )