/*-1* Copyright (c) 2014 Vassilis Laganakos2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#include <sys/param.h>27#include <sys/exec.h>28#include <sys/imgact.h>29#include <sys/kernel.h>30#include <sys/malloc.h>31#include <sys/sx.h>3233#include <compat/linux/linux.h>34#include <compat/linux/linux_mib.h>35#include <compat/linux/linux_util.h>3637SET_DECLARE(linux_device_handler_set, struct linux_device_handler);3839TAILQ_HEAD(, linux_ioctl_handler_element) linux_ioctl_handlers =40TAILQ_HEAD_INITIALIZER(linux_ioctl_handlers);41struct sx linux_ioctl_sx;42SX_SYSINIT(linux_ioctl, &linux_ioctl_sx, "Linux ioctl handlers");4344static int45linux_common_modevent(module_t mod, int type, void *data)46{47struct linux_device_handler **ldhp;4849switch(type) {50case MOD_LOAD:51#ifdef INVARIANTS52linux_check_errtbl();53#endif54linux_dev_shm_create();55linux_osd_jail_register();56SET_FOREACH(ldhp, linux_device_handler_set)57linux_device_register_handler(*ldhp);58linux_netlink_register();59break;60case MOD_UNLOAD:61linux_dev_shm_destroy();62linux_osd_jail_deregister();63SET_FOREACH(ldhp, linux_device_handler_set)64linux_device_unregister_handler(*ldhp);65linux_netlink_deregister();66break;67default:68return (EOPNOTSUPP);69}70return (0);71}7273static moduledata_t linux_common_mod = {74"linux_common",75linux_common_modevent,76077};7879DECLARE_MODULE(linux_common, linux_common_mod, SI_SUB_EXEC, SI_ORDER_ANY);80MODULE_VERSION(linux_common, 1);81MODULE_DEPEND(linux_common, netlink, 1, 1, 1);828384