udev-builtin-kmod.c revision 238b53a024a47cda38be5d9c11b54256e316f0ca
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * load kernel modules
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * Copyright (C) 2011-2012 Kay Sievers <kay.sievers@vrfy.org>
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * Copyright (C) 2011 ProFUSION embedded systems
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * This program is free software: you can redistribute it and/or modify
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * it under the terms of the GNU General Public License as published by
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * the Free Software Foundation, either version 2 of the License, or
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * (at your option) any later version.
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * This program is distributed in the hope that it will be useful,
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * but WITHOUT ANY WARRANTY; without even the implied warranty of
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * GNU General Public License for more details.
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * You should have received a copy of the GNU General Public License
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani * along with this program. If not, see <http://www.gnu.org/licenses/>.
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahanistatic int load_module(struct udev *udev, const char *alias)
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani err = kmod_module_new_from_lookup(ctx, alias, &list);
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani struct kmod_module *mod = kmod_module_get_module(l);
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani err = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL);
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani log_debug("module '%s' is blacklisted\n", kmod_module_get_name(mod));
2212d76d08f3bc34c683aed1a6736325b841625cBeniamino Galvani else if (err == 0)
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani log_debug("inserted '%s'\n", kmod_module_get_name(mod));
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani log_debug("failed to insert '%s'\n", kmod_module_get_name(mod));
2212d76d08f3bc34c683aed1a6736325b841625cBeniamino Galvanistatic void udev_kmod_log(void *data, int priority, const char *file, int line,
2212d76d08f3bc34c683aed1a6736325b841625cBeniamino Galvani const char *fn, const char *format, va_list args)
2212d76d08f3bc34c683aed1a6736325b841625cBeniamino Galvani udev_main_log(data, priority, file, line, fn, format, args);
176c355b43e616b61552566303ad59d5fd910333Beniamino Galvanistatic int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test)
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani struct udev *udev = udev_device_get_udev(dev);
2212d76d08f3bc34c683aed1a6736325b841625cBeniamino Galvani if (argc < 3 || strcmp(argv[1], "load")) {
2212d76d08f3bc34c683aed1a6736325b841625cBeniamino Galvani log_error("expect: %s load <module>\n", argv[0]);
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani log_debug("execute '%s' '%s'\n", argv[1], argv[i]);
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani/* called at udev startup and reload */
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahanistatic int builtin_kmod_init(struct udev *udev)
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani/* called on udev shutdown and reload request */
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahanistatic void builtin_kmod_exit(struct udev *udev)
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani/* called every couple of seconds during event activity; 'true' if config has changed */
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahanistatic bool builtin_kmod_validate(struct udev *udev)
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani return false;
ad1ad5c8e36ea795034fcdac660b15d7c141d55bSusant Sahani return (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK);