diff --git a/20220321/Operating_system_placement-de.pdf b/20220321/Operating_system_placement-de.pdf new file mode 120000 index 0000000000000000000000000000000000000000..0ac467095a599f2fdacc118bc84feb070a03d2d5 --- /dev/null +++ b/20220321/Operating_system_placement-de.pdf @@ -0,0 +1 @@ +../common/Operating_system_placement-de.pdf \ No newline at end of file diff --git a/20220404/Makefile b/20220404/Makefile new file mode 120000 index 0000000000000000000000000000000000000000..f6b6055dee93f47bde83b09e1618e38152ac699f --- /dev/null +++ b/20220404/Makefile @@ -0,0 +1 @@ +Makefile-modules-1 \ No newline at end of file diff --git a/20220404/Makefile-1 b/20220404/Makefile-1 new file mode 100644 index 0000000000000000000000000000000000000000..bfc1b10a929f22a8c2f4f0cf0368c78db14ad0b0 --- /dev/null +++ b/20220404/Makefile-1 @@ -0,0 +1,8 @@ +philosophy: philosophy.o answer.o + gcc philosophy.o answer.o -o philosophy + +answer.o: answer.c answer.h + gcc -Wall -O answer.c -c + +philosophy.o: philosophy.c answer.h + gcc -Wall -O philosophy.c -c diff --git a/20220404/Makefile-2 b/20220404/Makefile-2 new file mode 100644 index 0000000000000000000000000000000000000000..60aab7c7d51b28879c41e8590ab422e9edfadee5 --- /dev/null +++ b/20220404/Makefile-2 @@ -0,0 +1,16 @@ +TARGET = philosophy +OBJECTS = philosophy.o answer.o +HEADERS = answer.h +CFLAGS = -Wall -O + +$(TARGET): $(OBJECTS) + gcc $(OBJECTS) -o $(TARGET) + +answer.o: answer.c $(HEADERS) + gcc $(CFLAGS) answer.c -c + +philosophy.o: philosophy.c $(HEADERS) + gcc $(CFLAGS) philosophy.c -c + +clean: + rm -f $(OBJECTS) $(TARGET) diff --git a/20220404/Makefile-3 b/20220404/Makefile-3 new file mode 100644 index 0000000000000000000000000000000000000000..0ac355bfddfd237fe0f1b5062c5a242ab0d3e97e --- /dev/null +++ b/20220404/Makefile-3 @@ -0,0 +1,13 @@ +TARGET = philosophy +OBJECTS = philosophy.o answer.o +HEADERS = answer.h +CFLAGS = -Wall -O + +$(TARGET): $(OBJECTS) + gcc $(OBJECTS) -o $(TARGET) + +%.o: %.c $(HEADERS) + gcc $(CFLAGS) $< -c + +clean: + rm -f $(OBJECTS) $(TARGET) diff --git a/20220404/Makefile-modules-1 b/20220404/Makefile-modules-1 new file mode 100644 index 0000000000000000000000000000000000000000..817bd62fcb708a904341be771524c0fa2878c5da --- /dev/null +++ b/20220404/Makefile-modules-1 @@ -0,0 +1,9 @@ +obj-m += hellomod-1.o +obj-m += hellomod-2.o +obj-m += chardev-1.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules + +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean diff --git a/20220404/answer.c b/20220404/answer.c new file mode 100644 index 0000000000000000000000000000000000000000..e11399f0b3f482162893cbadf5db11129fdb2ef2 --- /dev/null +++ b/20220404/answer.c @@ -0,0 +1,6 @@ +#include "answer.h" + +int answer (void) +{ + return ANSWER; +} diff --git a/20220404/answer.h b/20220404/answer.h new file mode 100644 index 0000000000000000000000000000000000000000..6632ffe85a1f2222765dc071a229b15b897339df --- /dev/null +++ b/20220404/answer.h @@ -0,0 +1,3 @@ +extern int answer (void); + +#define ANSWER 42 diff --git a/20220404/chardev-1.c b/20220404/chardev-1.c new file mode 100644 index 0000000000000000000000000000000000000000..17a6651a33313322de202fbcb6bbf82333c0b766 --- /dev/null +++ b/20220404/chardev-1.c @@ -0,0 +1,166 @@ +/* + * chardev.c: Creates a read-only char device that says how many times + * you've read from the dev file + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/fs.h> +#include <asm/uaccess.h> /* for put_user */ + +/* + * Prototypes - this would normally go in a .h file + */ +int init_module(void); +void cleanup_module(void); +static int device_open(struct inode *, struct file *); +static int device_release(struct inode *, struct file *); +static ssize_t device_read(struct file *, char *, size_t, loff_t *); +static ssize_t device_write(struct file *, const char *, size_t, loff_t *); + +#define SUCCESS 0 +#define DEVICE_NAME "chardev" /* Dev name as it appears in /proc/devices */ +#define BUF_LEN 80 /* Max length of the message from the device */ + +/* + * Global variables are declared as static, so are global within the file. + */ + +static int Major; /* Major number assigned to our device driver */ +static int Device_Open = 0; /* Is device open? + * Used to prevent multiple access to device */ +static char msg[BUF_LEN]; /* The msg the device will give when asked */ +static char *msg_Ptr; + +static struct file_operations fops = { + .read = device_read, + .write = device_write, + .open = device_open, + .release = device_release +}; + +/* + * This function is called when the module is loaded + */ +int init_module(void) +{ + Major = register_chrdev(0, DEVICE_NAME, &fops); + + if (Major < 0) { + printk(KERN_ALERT "Registering char device failed with %d\n", Major); + return Major; + } + + printk(KERN_INFO "I was assigned major number %d. To talk to\n", Major); + printk(KERN_INFO "the driver, create a dev file with\n"); + printk(KERN_INFO "'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major); + printk(KERN_INFO "Try various minor numbers. Try to cat and echo to\n"); + printk(KERN_INFO "the device file.\n"); + printk(KERN_INFO "Remove the device file and module when done.\n"); + + return SUCCESS; +} + +/* + * This function is called when the module is unloaded + */ +void cleanup_module(void) +{ + /* + * Unregister the device + */ + unregister_chrdev(Major, DEVICE_NAME); +} + +/* + * Methods + */ + +/* + * Called when a process tries to open the device file, like + * "cat /dev/mycharfile" + */ +static int device_open(struct inode *inode, struct file *file) +{ + static int counter = 0; + + if (Device_Open) + return -EBUSY; + + Device_Open++; + sprintf(msg, "I already told you %d times Hello world!\n", counter++); + msg_Ptr = msg; + try_module_get(THIS_MODULE); + + return SUCCESS; +} + +/* + * Called when a process closes the device file. + */ +static int device_release(struct inode *inode, struct file *file) +{ + Device_Open--; /* We're now ready for our next caller */ + + /* + * Decrement the usage count, or else once you opened the file, you'll + * never get get rid of the module. + */ + module_put(THIS_MODULE); + + return 0; +} + +/* + * Called when a process, which already opened the dev file, attempts to + * read from it. + */ +static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */ + char *buffer, /* buffer to fill with data */ + size_t length, /* length of the buffer */ + loff_t * offset) +{ + /* + * Number of bytes actually written to the buffer + */ + int bytes_read = 0; + + /* + * If we're at the end of the message, + * return 0 signifying end of file + */ + if (*msg_Ptr == 0) + return 0; + + /* + * Actually put the data into the buffer + */ + while (length && *msg_Ptr) { + + /* + * The buffer is in the user data segment, not the kernel + * segment so "*" assignment won't work. We have to use + * put_user which copies data from the kernel data segment to + * the user data segment. + */ + put_user(*(msg_Ptr++), buffer++); + + length--; + bytes_read++; + } + + /* + * Most read functions return the number of bytes put into the buffer + */ + return bytes_read; +} + +/* + * Called when a process writes to dev file: echo "hi" > /dev/hello + */ +static ssize_t +device_write(struct file *filp, const char *buff, size_t len, loff_t * off) +{ + printk(KERN_ALERT "Sorry, this operation isn't supported.\n"); + return -EINVAL; +} diff --git a/20220404/freedos.hd b/20220404/freedos.hd new file mode 100644 index 0000000000000000000000000000000000000000..bf24ea7697c79c81cbb1ff01ddb015a63faff730 Binary files /dev/null and b/20220404/freedos.hd differ diff --git a/20220404/hellomod-1.c b/20220404/hellomod-1.c new file mode 100644 index 0000000000000000000000000000000000000000..a9fef793369a4e24da98b91e1bb7c651190ceea2 --- /dev/null +++ b/20220404/hellomod-1.c @@ -0,0 +1,20 @@ +/* + * hello-1.c - The simplest kernel module. + */ +#include <linux/module.h> /* Needed by all modules */ +#include <linux/kernel.h> /* Needed for KERN_INFO */ + +int init_module(void) +{ + printk(KERN_INFO "Hello world 1.\n"); + + /* + * A non 0 return means init_module failed; module can't be loaded. + */ + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "Goodbye world 1.\n"); +} diff --git a/20220404/hellomod-2.c b/20220404/hellomod-2.c new file mode 100644 index 0000000000000000000000000000000000000000..a2bb30b1329f9a2997a2d6164631618635f41f4c --- /dev/null +++ b/20220404/hellomod-2.c @@ -0,0 +1,22 @@ +/* + * hello-2.c - The simplest kernel module. + */ +#include <linux/module.h> /* Needed by all modules */ +#include <linux/kernel.h> /* Needed for KERN_INFO */ + +MODULE_LICENSE("GPL"); + +int init_module(void) +{ + printk(KERN_INFO "Hello world 2.\n"); + + /* + * A non 0 return means init_module failed; module can't be loaded. + */ + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "Goodbye world 2.\n"); +} diff --git a/20220404/make-1.txt b/20220404/make-1.txt new file mode 100644 index 0000000000000000000000000000000000000000..bae6639927d6ea0b9faa07e2884b1e2b10edba15 --- /dev/null +++ b/20220404/make-1.txt @@ -0,0 +1,60 @@ +cassini/home/peter/bo/2022ss/bs/20220404> cat philosophy.c +#include <stdio.h> +#include "answer.h" + +int main (void) +{ + printf ("The answer is %d.\n", answer ()); + return 0; +} +cassini/home/peter/bo/2022ss/bs/20220404> cat answer.h +extern int answer (void); + +#define ANSWER 42 +cassini/home/peter/bo/2022ss/bs/20220404> cat answer.c +#include "answer.h" + +int answer (void) +{ + return ANSWER; +} +cassini/home/peter/bo/2022ss/bs/20220404> gcc -Wall -O philosophy.c -o philosophy +/usr/bin/ld: /tmp/ccjJ8ZhE.o: in function `main': +philosophy.c:(.text+0x5): undefined reference to `answer' +collect2: error: ld returned 1 exit status +cassini/home/peter/bo/2022ss/bs/20220404> gcc -Wall -O philosophy.c answer.c -o philosophy +Sie haben neue Post in /var/mail/peter. +cassini/home/peter/bo/2022ss/bs/20220404> ./philosophy +The answer is 42. +cassini/home/peter/bo/2022ss/bs/20220404> gcc -Wall -O philosophy.c -c +cassini/home/peter/bo/2022ss/bs/20220404> gcc -Wall -O answer.c -c +cassini/home/peter/bo/2022ss/bs/20220404> ls -l philosophy.[co] answer.[co] +-rw-r--r-- 1 peter peter 60 Dez 13 13:46 answer.c +-rw-r--r-- 1 peter peter 1208 Apr 4 13:57 answer.o +-rw-r--r-- 1 peter peter 117 Jan 4 2021 philosophy.c +-rw-r--r-- 1 peter peter 1632 Apr 4 13:57 philosophy.o +cassini/home/peter/bo/2022ss/bs/20220404> gcc philosophy.o answer.o -o philosophy +cassini/home/peter/bo/2022ss/bs/20220404> ./philosophy +The answer is 42. +cassini/home/peter/bo/2022ss/bs/20220404> gcc philosophy.o -o philosophy +/usr/bin/ld: philosophy.o: in function `main': +philosophy.c:(.text+0x5): undefined reference to `answer' +collect2: error: ld returned 1 exit status +cassini/home/peter/bo/2022ss/bs/20220404> cat Makefile-1 +philosophy: philosophy.o answer.o + gcc philosophy.o answer.o -o philosophy + +answer.o: answer.c answer.h + gcc -Wall -O answer.c -c + +philosophy.o: philosophy.c answer.h + gcc -Wall -O philosophy.c -c +cassini/home/peter/bo/2022ss/bs/20220404> make +make: *** Es wurden keine Ziele angegeben und keine „make“-Steuerdatei gefunden. Schluss. +cassini/home/peter/bo/2022ss/bs/20220404> make -f Makefile-1 +gcc philosophy.o answer.o -o philosophy +cassini/home/peter/bo/2022ss/bs/20220404> rm *.o +cassini/home/peter/bo/2022ss/bs/20220404> make -f Makefile-1 +gcc -Wall -O philosophy.c -c +gcc -Wall -O answer.c -c +gcc philosophy.o answer.o -o philosophy diff --git a/20220404/make-2.txt b/20220404/make-2.txt new file mode 100644 index 0000000000000000000000000000000000000000..ab38c8dd947a3c1b4c8ab3541176519d9634e261 --- /dev/null +++ b/20220404/make-2.txt @@ -0,0 +1,45 @@ +/* + * hello-1.c - The simplest kernel module. + */ +#include <linux/module.h> /* Needed by all modules */ +#include <linux/kernel.h> /* Needed for KERN_INFO */ + +int init_module(void) +{ + printk(KERN_INFO "Hello world 1.\n"); + + /* + * A non 0 return means init_module failed; module can't be loaded. + */ + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "Goodbye world 1.\n"); +} +cassini/home/peter/bo/2022ss/bs/20220404> cat Makefile-modules-1 +obj-m += hellomod-1.o + +# obj-m += hellomod-2.o +# obj-m += chardev-1.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules + +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean +cassini/home/peter/bo/2022ss/bs/20220404> ln -sf Makefile-modules-1 Makefile +cassini/home/peter/bo/2022ss/bs/20220404> echo /lib/modules/$(shell uname -r)/build +bash: shell: Kommando nicht gefunden. +/lib/modules//build +cassini/home/peter/bo/2022ss/bs/20220404> echo /lib/modules/$(uname -r)/build +/lib/modules/4.19.0-12-amd64/build +cassini/home/peter/bo/2022ss/bs/20220404> ls /lib/modules/4.19.0-12-amd64/build +arch include Makefile Module.symvers scripts tools +cassini/home/peter/bo/2022ss/bs/20220404> uname +Linux +cassini/home/peter/bo/2022ss/bs/20220404> uname -r +4.19.0-12-amd64 +cassini/home/peter/bo/2022ss/bs/20220404> pwd +/home/peter/bo/2022ss/bs/20220404 diff --git a/20220404/modules-1.txt b/20220404/modules-1.txt new file mode 100644 index 0000000000000000000000000000000000000000..d0b19f27400f8df15bcb3f7054f98ac8a2407d08 --- /dev/null +++ b/20220404/modules-1.txt @@ -0,0 +1,33 @@ +-rw-r--r-- 1 peter peter 270648 Apr 4 14:19 hellomod-1.ko +cassini/home/peter/bo/2022ss/bs/20220404> ./hellomod-1.ko +bash: ./hellomod-1.ko: Keine Berechtigung +cassini/home/peter/bo/2022ss/bs/20220404> chmod +x hellomod-1.ko +cassini/home/peter/bo/2022ss/bs/20220404> ./hellomod-1.ko +bash: ./hellomod-1.ko: Kann die Binärdatei nicht ausführen: Fehler im Format der Programmdatei +cassini/home/peter/bo/2022ss/bs/20220404> chmod -x hellomod-1.ko +cassini/home/peter/bo/2022ss/bs/20220404> insmod hellomod-1.ko +bash: insmod: Kommando nicht gefunden. +cassini/home/peter/bo/2022ss/bs/20220404> sudo insmod hellomod-1.ko +[sudo] Passwort für peter: +cassini/home/peter/bo/2022ss/bs/20220404> sudo rmmod hellomod-1.ko +cassini/home/peter/bo/2022ss/bs/20220404> cat hellomod-1.c +/* + * hello-1.c - The simplest kernel module. + */ +#include <linux/module.h> /* Needed by all modules */ +#include <linux/kernel.h> /* Needed for KERN_INFO */ + +int init_module(void) +{ + printk(KERN_INFO "Hello world 1.\n"); + + /* + * A non 0 return means init_module failed; module can't be loaded. + */ + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "Goodbye world 1.\n"); +} diff --git a/20220404/modules-2.txt b/20220404/modules-2.txt new file mode 100644 index 0000000000000000000000000000000000000000..be8dd1125da58e01eb6ab1b40f9045dccd1400cb --- /dev/null +++ b/20220404/modules-2.txt @@ -0,0 +1,8 @@ +cassini/home/peter/bo/2022ss/bs/20220404> sudo dmesg +[...] +[1583119.050593] hellomod_1: loading out-of-tree module taints kernel. +[1583119.050600] hellomod_1: module license 'unspecified' taints kernel. +[1583119.050601] Disabling lock debugging due to kernel taint +[1583119.050666] hellomod_1: module verification failed: signature and/or required key missing - tainting kernel +[1583119.051455] Hello world 1. +[1583136.476867] Goodbye world 1. diff --git a/20220404/modules-3.txt b/20220404/modules-3.txt new file mode 100644 index 0000000000000000000000000000000000000000..2e92a6ca2c886b3b7b920d67ff636c2df6060563 --- /dev/null +++ b/20220404/modules-3.txt @@ -0,0 +1,4 @@ +cassini/home/peter/bo/2022ss/bs/20220404> sudo dmesg +[...] +[1583551.529893] Hello world 2. +[1583557.018894] Goodbye world 2. diff --git a/20220404/modules-4.txt b/20220404/modules-4.txt new file mode 100644 index 0000000000000000000000000000000000000000..00b0a49562cef65640b80b7eecb3ecb21ce6f01e --- /dev/null +++ b/20220404/modules-4.txt @@ -0,0 +1,6 @@ +[1584035.731938] I was assigned major number 241. To talk to +[1584035.731939] the driver, create a dev file with +[1584035.731940] 'mknod /dev/chardev c 241 0'. +[1584035.731940] Try various minor numbers. Try to cat and echo to +[1584035.731941] the device file. +[1584035.731941] Remove the device file and module when done. diff --git a/20220404/modules-5.txt b/20220404/modules-5.txt new file mode 100644 index 0000000000000000000000000000000000000000..a82d2ec284069fb1fe7448ca66847a5ddba9ee23 --- /dev/null +++ b/20220404/modules-5.txt @@ -0,0 +1,15 @@ +cassini/home/peter/bo/2022ss/bs/20220404> mkdir dev +cassini/home/peter/bo/2022ss/bs/20220404> mknod dev/chardev c 241 0 +mknod: dev/chardev: Die Operation ist nicht erlaubt +cassini/home/peter/bo/2022ss/bs/20220404> sudo mknod dev/chardev c 241 0 +cassini/home/peter/bo/2022ss/bs/20220404> ls -l dev/ +insgesamt 0 +crw-r--r-- 1 root root 241, 0 Apr 4 14:39 chardev +cassini/home/peter/bo/2022ss/bs/20220404> ls -l /dev/tty +crw-rw-rw- 1 root tty 5, 0 Apr 4 14:22 /dev/tty +cassini/home/peter/bo/2022ss/bs/20220404> cat dev/chardev +I already told you 0 times Hello world! +cassini/home/peter/bo/2022ss/bs/20220404> cat dev/chardev +I already told you 1 times Hello world! +cassini/home/peter/bo/2022ss/bs/20220404> cat dev/chardev +I already told you 2 times Hello world! diff --git a/20220404/nix-hello.c b/20220404/nix-hello.c new file mode 100644 index 0000000000000000000000000000000000000000..cc2018703757a875b70c2aa3fd1a104d7e870301 --- /dev/null +++ b/20220404/nix-hello.c @@ -0,0 +1,15 @@ +int main (void) +{ + char *p = (char *) 0xb8000000; + *p++ = 'H'; + *p++ = 0x04; + *p++ = 'e'; + *p++ = 0x02; + *p++ = 'l'; + *p++ = 0x01; + *p++ = 'l'; + *p++ = 0x06; + *p++ = 'o'; + *p++ = 0x03; + return 0; +} diff --git a/20220404/os-layers-1.jpg b/20220404/os-layers-1.jpg new file mode 120000 index 0000000000000000000000000000000000000000..6dc99e9e12dbc84e908c37974c7d528be014d587 --- /dev/null +++ b/20220404/os-layers-1.jpg @@ -0,0 +1 @@ +../common/os-layers-1.jpg \ No newline at end of file diff --git a/20220404/os-layers-2.jpg b/20220404/os-layers-2.jpg new file mode 120000 index 0000000000000000000000000000000000000000..4da385ea396af0f9c7ed79b23a183a3b5618b445 --- /dev/null +++ b/20220404/os-layers-2.jpg @@ -0,0 +1 @@ +../common/os-layers-2.jpg \ No newline at end of file diff --git a/20220404/os-layers-3.jpg b/20220404/os-layers-3.jpg new file mode 120000 index 0000000000000000000000000000000000000000..eaf5b599709e39d1c51dfdac28843c31b3fa971c --- /dev/null +++ b/20220404/os-layers-3.jpg @@ -0,0 +1 @@ +../common/os-layers-3.jpg \ No newline at end of file diff --git a/20220404/os-layers-4.jpg b/20220404/os-layers-4.jpg new file mode 120000 index 0000000000000000000000000000000000000000..efcbbd1827ff55f225fee0b77b8bfb5c6cff980c --- /dev/null +++ b/20220404/os-layers-4.jpg @@ -0,0 +1 @@ +../common/os-layers-4.jpg \ No newline at end of file diff --git a/20220404/os-layers-5.jpg b/20220404/os-layers-5.jpg new file mode 120000 index 0000000000000000000000000000000000000000..91cabe9241f19ece833cb22e8f16587153f246a2 --- /dev/null +++ b/20220404/os-layers-5.jpg @@ -0,0 +1 @@ +../common/os-layers-5.jpg \ No newline at end of file diff --git a/20220404/philosophy.c b/20220404/philosophy.c new file mode 100644 index 0000000000000000000000000000000000000000..e9f508a501d9ec66d02e0636a9f6c71f2c7a8594 --- /dev/null +++ b/20220404/philosophy.c @@ -0,0 +1,8 @@ +#include <stdio.h> +#include "answer.h" + +int main (void) +{ + printf ("The answer is %d.\n", answer ()); + return 0; +} diff --git a/20220404/screenshot-20220404-122759.png b/20220404/screenshot-20220404-122759.png new file mode 100644 index 0000000000000000000000000000000000000000..3ab65322c56c233daa8a2c08e39974c2e6e2992b Binary files /dev/null and b/20220404/screenshot-20220404-122759.png differ diff --git a/20220404/screenshot-20220404-123432.png b/20220404/screenshot-20220404-123432.png new file mode 100644 index 0000000000000000000000000000000000000000..7b61806b48dbf6eed3757bd061fca6e4658300ef Binary files /dev/null and b/20220404/screenshot-20220404-123432.png differ diff --git a/20220404/screenshot-20220404-132001.png b/20220404/screenshot-20220404-132001.png new file mode 100644 index 0000000000000000000000000000000000000000..6e509ea1c93b3d50476d6ed1cefb8290ee1e8c7c Binary files /dev/null and b/20220404/screenshot-20220404-132001.png differ diff --git a/20220404/screenshot-20220404-132021.png b/20220404/screenshot-20220404-132021.png new file mode 100644 index 0000000000000000000000000000000000000000..5c585e5d896403f4fc05923cfda2f593c5a57787 Binary files /dev/null and b/20220404/screenshot-20220404-132021.png differ