summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2023-05-07 14:36:49 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2023-05-07 14:36:49 +0200
commitf2c131bc5294d0531edb3486874f37019b0b1413 (patch)
tree6923a9d65ecc21b53a16f73abdabf1a21d58d819
parentd017ac75f05c65e2e736f6dea271b69d7c9524bb (diff)
downloadabase-f2c131bc5294d0531edb3486874f37019b0b1413.tar.gz
abase-f2c131bc5294d0531edb3486874f37019b0b1413.tar.bz2
added a simple rmmod
-rw-r--r--Makefile3
-rw-r--r--README5
-rw-r--r--rmmod.115
-rw-r--r--rmmod.c34
4 files changed, 53 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 83f8a68..8d6fe49 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,8 @@ BIN =\
more\
hexdump\
ifconfig\
- ping
+ ping\
+ rmmod
LIBUTILOBJ = $(LIBUTILSRC:.c=.o)
OBJ = $(BIN:=.o) $(LIBUTFOBJ) $(LIBUTILOBJ)
diff --git a/README b/README
index 5745cd1..e53ed1c 100644
--- a/README
+++ b/README
@@ -11,11 +11,10 @@ Currently it contains the following:
- a 'ifconfig': show and configure simple interfaces
- a 'ping': test a network connection
- a 'netstat': see list of active connections of a machine
-- a 'mkswap': swapon/swapoff exist, so we should also be able to create
- a swap
+- a 'mkswap': swapon/swapoff/swaplabel exist, so we should also be able
+ to create a swap
- 'fsck.ext4', 'mkfs.ext4': if ext4 is the only file system we support
- 'nbd-client': for NBD root mounts
-- 'rmmod': 'insmod/lsmod' exists in ubase, removing is important to
play with hardware. dependencies can also be done from the text
modules.dep file and a samurai or simplistic make, 'modprobe' as
shell wrapper on dependencies and insmod calls
diff --git a/rmmod.1 b/rmmod.1
new file mode 100644
index 0000000..3c526da
--- /dev/null
+++ b/rmmod.1
@@ -0,0 +1,15 @@
+.Dd 2023-05-07
+.Dt RMMID 1
+.Os abase
+.Sh NAME
+.Nm rmmid
+.Nd remove module for the Linux kernl
+.Sh SYNOPSIS
+.Nm
+{module}
+.Sh DESCRIPTION
+.Nm
+Removes a loaded Linux kernel module named
+.Ar module
+.RE
+
diff --git a/rmmod.c b/rmmod.c
new file mode 100644
index 0000000..e0545d3
--- /dev/null
+++ b/rmmod.c
@@ -0,0 +1,34 @@
+/* See LICENSE file for copyright and license details. */
+#include <fcntl.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#include "util.h"
+
+static void
+usage(void)
+{
+ eprintf("usage: %s <module>\n", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char *module;
+
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND
+
+ if (argc != 1) {
+ weprintf("Expecting exactly one 'module' to remove\n");
+ usage();
+ }
+ module = argv[0];
+
+ if (syscall(__NR_delete_module, module, O_NONBLOCK) < 0)
+ eprintf("delete_module:");
+
+ return 0;
+}