From d79358f91cc4340b71b7d4e83fa432e8c98a7b22 Mon Sep 17 00:00:00 2001 From: Peter Gerwinski <peter.gerwinski@hs-bochum.de> Date: Sun, 31 May 2015 23:29:44 +0200 Subject: [PATCH] Notizen zu den Lehrveranstaltungen vom 11. und 18. Mai 2015 --- slides/bs-20150511.txt | 58 ++++++++++++++++++++++++++++++++++++++++++ slides/bs-20150518.txt | 13 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 slides/bs-20150511.txt create mode 100644 slides/bs-20150518.txt diff --git a/slides/bs-20150511.txt b/slides/bs-20150511.txt new file mode 100644 index 0000000..33cd162 --- /dev/null +++ b/slides/bs-20150511.txt @@ -0,0 +1,58 @@ +Verzeichnis: Linux-Quelltext +$ find . -name "*syscall*" +$ vi -R ./arch/x86/kernel/syscall_64.c +--> Definition von "sys_call_table" über wiederholte Includes +$ find . -name syscalls_64.h +$ vi -R ./arch/sh/include/asm/syscalls_64.h +$ vi -R ./arch/x86/um/shared/sysdep/syscalls_64.h +--> beides nicht sehr erhellend +$ locate syscalls_64.h +$ vi -R /usr/src/linux-headers-3.16.0-4-amd64/arch/x86/include/generated/asm/syscalls_64.h +$ grep -R syscalls_64\.h * +$ vi -R arch/x86/syscalls/Makefile +$ find . -name syscall_64.tbl +$ vi -R ./arch/x86/syscalls/syscall_64.tbl +--> :-) +$ vi -R ./arch/x86/kernel/syscall_64.c +--> Die 2. Spalte ("sym") bezeichnet den Funktionsnamen. + - Wie findet der "syscall"-Befehl die Tabelle? + - Wo wird die Funktion deklariert? +$ grep -R sys_call_table arch/x86/* +$ vi -R arch/x86/kernel/entry_64.S +--> :-) +$ grep -wr write * +--> :-( +# DuckDuckGo --> http://www.usmanacademy.com/2012/07/linux-system-call-implementation.html +$ find . -name "*write*" +$ vi -R ./fs/read_write.c +--> SYSCALL_DEFINE3(write, ...) + struct fd + vfs_write() +$ vi -R include/linux/file.h +--> struct file *file; +$ grep -r "struct file {" $(find . -name "*.h") +$ vi -R ./include/linux/fs.h +--> const struct file_operations *f_op; +--> ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); +--> :-) +$ vi -R ./fs/read_write.c +--> vfs_write(): + if (file->f_op->write) + ret = file->f_op->write(file, buf, count, pos); + +Beim Öffnen der Datei werden die file_operations in der struct file hinterlegt. + +Skript, 11.05.2015, 13:58:25 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + - \usepackage{hyperref} + - Daemon schreibt in log-Datei: In welche? + +sprintf, 11.05.2015, 14:49:56 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + char buf[42]; + sprintf (buf, "%s", "Hello"); + sprintf (buf + 5, "%s\n", ", world!"); + +oder besser: + + sprintf (buf + strlen (buf), "%s\n", ", world!"); diff --git a/slides/bs-20150518.txt b/slides/bs-20150518.txt new file mode 100644 index 0000000..55f30dd --- /dev/null +++ b/slides/bs-20150518.txt @@ -0,0 +1,13 @@ +Merlin Klaßen, 18.05.2015, 11:38:37 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +device_write() + +cdev_init() +cdev_add() +device_create() + +device_destroy() +class_destroy() +cdev_del() + +--> Der udev-deamon kümmert sich um das Anlegen und Entfernen der char-Device. -- GitLab