\documentclass[addpoints,12pt]{exam} \usepackage{ngerman} \usepackage{listings,color} \usepackage{graphicx} \firstpageheadrule \runningheadrule \lhead{Manuel Traut\\Sommersemester 2015} \chead{Hochschule Ravensburg-Weingarten\\Linux-Kernelprogrammierung} \rhead{MatrNr:\\Datum:} \firstpagefootrule \runningfootrule \firstpagefooter{Page \thepage\ of \numpages} {} {Punkte: \makebox[.5in]{\hrulefill}\\ von \pointsonpage{\thepage} Punkten} \runningfooter{Page \thepage\ of \numpages} {} {} \pagestyle{headandfoot} \pointsinrightmargin \pointpoints{Punkt}{Punkte} \begin{document} \begin{coverpages} \begin{titlepage} \title{Pr\"ufung Linux-Kernelprogrammierung} \author{Dozent: Manuel Traut} \date{10. Juli 2015 08:00 Uhr} \maketitle \begin{center} Hochschule Ravensburg-Weingarten \vspace{1cm} Dauer: 60 Minuten, erlaubte Hilfsmittel: handschriftliche Mitschriebe/Notizen \end{center} \vspace{2cm} Name:\enspace\hrulefill \vspace{2cm} MatrNr:\enspace\hrulefill \begin{center} \begin{lstlisting} a8888b. d888888b. 8P"YP"Y88 (((((((()))))))))) 8|o||o|88 ||VIEL ERFOLG !!|| 8' .88 ((((((((((((())))) 8`._.' Y8. d/ `8b. .dP . Y8b. d8:' " `::88b. d8" `Y88b :8P ' :888 8a. : _a88P ._/"Yaa_ : .| 88P| \ YP" `| 8P `. / \._____.d| .' `--..__)888888P`._.' \end{lstlisting} \end{center} \end{titlepage} \end{coverpages} \lstset{ % basicstyle=\scriptsize, % the size of the fonts that are used for the code breaklines=true, % sets automatic line breaking frame=single, % adds a frame around the code language=C, % the language of the code numbers=left, % where to put the line-numbers; numbersep=5pt, % how far the line-numbers are from the code numberstyle=\tiny, % the style that is used for the line-numbers tabsize=8, % sets default tabsize to 2 spaces } \begin{questions} \section*{Entwicklungsmodell - Development process} \question[4] Erkl\"aren Sie an einem Beispiel die Aufgaben eines Linux Kernel Maintainers. \question[4] Sie wollen Ihren eigenen Treiber in Mainline Linux integriert haben. Was \"ubermitteln Sie auf welchem Weg wohin? \section*{Tools} \question Der Linux Kernel wird im Versionskontrollsystem git verwaltet. \begin{parts} \part[1] Welches Subkommando verwenden Sie um den Quellcode z.B. des Linux Kernels auf Ihren PC zu \"ubertragen? \part[6] Wie gehen Sie vor um mit Hilfe von git Ihre Änderungen auf eine neuere Version des Kernels zu portieren? \end{parts} \question \begin{parts} \part[1] Welches Kommando f\"uhrt zu den Ausgaben auf folgendem Bild? \part[1] \"Uber welche Dateien wird der Inhalt / Struktur des Tools gesteuert? \end{parts} \includegraphics[height=0.3\textwidth]{./images/kconfig.png} \question In der Vorlesung haben wir etliche Funktionen des Kerneltracers 'ftrace' kennen gelernt. \begin{parts} \part[1] Beschreiben Sie eine M\"oglichkeit den Trace zu starten/stoppen. \part[2] Nennen Sie 2 Events oder Eventtypen welche getraced werden k\"onnen. \part[1] Beschreiben Sie eine M\"oglichkeit wie man den Tracebuffer auslesen kann \part[6] Erkl\"aren und Begr\"unden Sie die Einfl\"u\ss e von ftrace auf die Systemperformance. \end{parts} \section*{Rootfilesysteme - Rootfilesystems} \question \begin{parts} \part[1] Nennen Sie einen Grund der gegen den Einsatz einer Linuxdistribution spricht. \part[4] Nennen Sie 4 Aufgaben die Sie bei einem 'Linux from scratch' (also ohne Distribution) selber tun m\"u\ss en, welche aber klassischerweise von einer Linuxdistribution gel\"ost w\"aren. \end{parts} \newpage \section*{Programmierung - Programming} \question[4] Sie starten ein Linuxsystem. Die letzten Ausgaben lauten: 'freeing memory, loading init' - Nennen Sie 4 m\"ogliche Ursachen. \question[4] Beschreiben Sie mit eigenen Worten, was Sie folgender Kernelausgabe entnehmen k\"onnen: \begin{verbatim} CPU: 0 Not tainted (2.6.37 #9) PC is at prepare_namespace+0x170/0x1d4 LR is at do_unlinkat+0x10c/0x14c pc : [] lr : [] psr: 80000013 sp : c783dfc8 ip : c783df20 fp : c783dfe0 r10: 00000000 r9 : 00000000 r8 : 00000000 r7 : 00000013 r6 : c0054a1c r5 : c0022995 r4 : c03969a4 r3 : 00000000 r2 : 00000000 r1 : c78c7000 r0 : 00000000 Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 00093177 Table: 00004000 DAC: 00000017 Process swapper (pid: 1, stack limit = 0xc783c260) Stack: (0xc783dfc8 to 0xc783e000) dfc0: c783dfd4 c0396940 c00084fc c783dff4 c783dfe4 c0008610 dfe0: c0009214 00000000 00000000 c783dff8 c0054a1c c0008508 00000000 00000000 Backtrace: [] (prepare_namespace+0x0/0x1d4) from [] (kernel_init+0x114/0x154) r5:c00084fc r4:c0396940 [] (kernel_init+0x0/0x154) from [] (do_exit+0x0/0x660) r4:00000000 Code: e3500000 13a03601 15843000 e3a03000 (e5d31000) ---[ end trace 4ed5c061b76895d8 ]--- \end{verbatim} \newpage \question Die folgenden Fragen beziehen sich auf den Quellcode des Kernelmoduls im Anhang. \begin{parts} \part[2] Welche Zeile Quellcode m\"u\ss en Sie l\"oschen damit der Code keine Funktion hat? \part[4] Welche 'virtuellen Dateien' werden von dem Code angelegt? \part[4] Sie wollen vom Userspace aus mittels des Kernelmoduls folgende Datei erstellen. Welche Kommandos oder Pseudo-C Code verwenden Sie? [/tmp/huhu.txt] \begin{lstlisting} 8888 \end{lstlisting} \part[6] Suchen Sie sich drei Funktionen aus, erkl\"aren Sie jeweils wann die Funktion aufgerufen wird und was Sie tut. \part[4] Sie wollen dass der Code keine sysfs device Attribute mehr exportiert. Nennen Sie alle Bereiche, die gel\"oscht werden k\"onnen. \end{parts} \end{questions} \vspace{1cm} Punkte: \_\_\_\_ von \numpoints \hspace{1cm} Note: \newpage \begin{appendix} \begin{lstlisting} /* * Example driver for Linux * Copyright (C) 2015, Manuel Traut * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include #include #include #include #include #include #include #define DEVICE_NAME "hswgt" static int major; static struct class *dummy; static struct device hswgt_dev = { .init_name = DEVICE_NAME, }; static ssize_t hswgt_show_ro(struct device *hswgt_dev, struct device_attribute *hswgt_attr, char *buf) { memset(buf, 8, 4); buf[4] = '\0'; return 5; } static ssize_t hswgt_show_rw(struct device *hswgt_dev, struct device_attribute *hswgt_attr, char *buf) { printk(KERN_ERR "number of the beast?"); memset(buf, 6, 3); buf[3] = '\0'; return 4; } static ssize_t hswgt_store_rw(struct device *hswgt_dev, struct device_attribute *hswgt_attr, const char *buf, size_t count) { printk(KERN_ERR "what's this good for?"); return count; } static DEVICE_ATTR(hswgt_ro, S_IRUGO, hswgt_show_ro, NULL); static DEVICE_ATTR(hswgt_rw, S_IWUSR|S_IRUGO, hswgt_show_rw, hswgt_store_rw); static struct attribute *hswgt_dev_attrs[] = { &dev_attr_hswgt_ro.attr, &dev_attr_hswgt_rw.attr, NULL, }; static struct attribute_group hswgt_dev_attr_group1 = { .attrs = hswgt_dev_attrs, }; static const struct attribute_group *hswgt_dev_attr_groups[] = { &hswgt_dev_attr_group1, NULL, }; static int __init hswgt_init(void) { int ret = 0; pr_notice("%s\n", __func__); dummy = class_create(THIS_MODULE, "dummy"); device_initialize(&hswgt_dev); hswgt_dev.parent = NULL; hswgt_dev.bus = NULL; hswgt_dev.class = dummy; hswgt_dev.groups = hswgt_dev_attr_groups; ret = device_add(&hswgt_dev); if (ret) { pr_err("%s device_add failed: %x\n", __func__, ret); goto failed_dev; } return 0; failed_dev: device_del(&hswgt_dev); class_destroy(dummy); return ret; } static void __exit hswgt_exit(void) { pr_notice("%s\n", __func__); device_del(&hswgt_dev); class_destroy(dummy); } module_init(hswgt_init); module_exit(hswgt_exit); MODULE_AUTHOR("Manuel Traut"); MODULE_DESCRIPTION("dummy test driver"); MODULE_VERSION("3"); MODULE_LICENSE("GPL"); \end{lstlisting} \end{appendix} \end{document}