]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev/udev-builtin-kmod.c
[PATCH[ udev: ata_id: Fix length of INQUIRY command
[thirdparty/systemd.git] / udev / udev-builtin-kmod.c
CommitLineData
81dadce5 1/*
aa29418a 2 * load kernel modules
81dadce5
KS
3 *
4 * Copyright (C) 2011 Kay Sievers <kay.sievers@vrfy.org>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <stdarg.h>
23#include <unistd.h>
24#include <string.h>
25#include <errno.h>
26#include <fcntl.h>
27#include <sys/stat.h>
28
29#include "udev.h"
30
aa29418a
KS
31static char *kmod;
32
81dadce5
KS
33static int builtin_kmod(struct udev_device *dev, const char *command, bool test)
34{
35 printf("soon we load a module here: '%s'\n", command);
aa29418a 36 printf("test: %s\n", kmod);
81dadce5
KS
37 return EXIT_SUCCESS;
38}
39
aa29418a
KS
40static int builtin_kmod_load(struct udev *udev)
41{
42 printf("load module index\n");
43 asprintf(&kmod, "pid: %u\n", getpid());
44 return 0;
45}
46
47static int builtin_kmod_unload(struct udev *udev)
48{
49 printf("unload module index\n");
50 free(kmod);
51 return 0;
52}
53
81dadce5
KS
54const struct udev_builtin udev_builtin_kmod = {
55 .name = "kmod",
56 .cmd = builtin_kmod,
aa29418a
KS
57 .load = builtin_kmod_load,
58 .unload = builtin_kmod_unload,
81dadce5
KS
59 .help = "kernel module loader",
60 .run_once = false,
61};