linux_common.c revision 293527
1240116Smarcel/*- 2240116Smarcel * Copyright (c) 2014 Vassilis Laganakos 3240116Smarcel * All rights reserved. 4240116Smarcel * 5240116Smarcel * Redistribution and use in source and binary forms, with or without 6240116Smarcel * modification, are permitted provided that the following conditions 7240116Smarcel * are met: 8240116Smarcel * 1. Redistributions of source code must retain the above copyright 9240116Smarcel * notice, this list of conditions and the following disclaimer. 10240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11240116Smarcel * notice, this list of conditions and the following disclaimer in the 12240116Smarcel * documentation and/or other materials provided with the distribution. 13240116Smarcel * 14240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15240116Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16240116Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17240116Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18240116Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19240116Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20240116Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21240116Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22240116Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23240116Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24240116Smarcel * SUCH DAMAGE. 25240116Smarcel */ 26240116Smarcel 27240116Smarcel#include <sys/cdefs.h> 28240116Smarcel__FBSDID("$FreeBSD: stable/10/sys/compat/linux/linux_common.c 293527 2016-01-09 16:08:22Z dchagin $"); 29240116Smarcel 30240116Smarcel#include <sys/param.h> 31240116Smarcel#include <sys/module.h> 32240116Smarcel#include <sys/malloc.h> 33240116Smarcel#include <sys/module.h> 34240116Smarcel#include <sys/types.h> 35240116Smarcel#include <sys/kernel.h> 36240116Smarcel#include <sys/proc.h> 37240116Smarcel 38240116Smarcel#include <compat/linux/linux_mib.h> 39240116Smarcel#include <compat/linux/linux_util.h> 40240116Smarcel 41240116SmarcelMODULE_VERSION(linux_common, 1); 42240116Smarcel 43240116SmarcelSET_DECLARE(linux_device_handler_set, struct linux_device_handler); 44240116Smarcel 45240116Smarcel 46240116Smarcelstatic int 47240116Smarcellinux_common_modevent(module_t mod, int type, void *data) 48240116Smarcel{ 49240116Smarcel struct linux_device_handler **ldhp; 50240116Smarcel 51240116Smarcel switch(type) { 52240116Smarcel case MOD_LOAD: 53240116Smarcel linux_osd_jail_register(); 54240116Smarcel SET_FOREACH(ldhp, linux_device_handler_set) 55240116Smarcel linux_device_register_handler(*ldhp); 56240116Smarcel break; 57240116Smarcel case MOD_UNLOAD: 58240116Smarcel linux_osd_jail_deregister(); 59240116Smarcel SET_FOREACH(ldhp, linux_device_handler_set) 60240116Smarcel linux_device_unregister_handler(*ldhp); 61240116Smarcel break; 62240116Smarcel default: 63240116Smarcel return (EOPNOTSUPP); 64240116Smarcel } 65240116Smarcel return (0); 66240116Smarcel} 67240116Smarcel 68240116Smarcelstatic moduledata_t linux_common_mod = { 69240116Smarcel "linuxcommon", 70240116Smarcel linux_common_modevent, 71240116Smarcel 0 72240116Smarcel}; 73240116Smarcel 74240116SmarcelDECLARE_MODULE(linuxcommon, linux_common_mod, SI_SUB_EXEC, SI_ORDER_ANY); 75240116Smarcel