diff options
| author | Manuel Traut <manut@linutronix.de> | 2014-07-16 23:56:02 +0200 |
|---|---|---|
| committer | Manuel Traut <manut@linutronix.de> | 2014-07-16 23:56:02 +0200 |
| commit | b5cf0f555d887f934a86b93000ac350937ee2b63 (patch) | |
| tree | ee2ada545d790708883cb4e19e556846db788c95 | |
| parent | dcb2d0881bc628f11bc790ec5a34d1fe92ab28b2 (diff) | |
updated pruefung for 2014
Signed-off-by: Manuel Traut <manut@linutronix.de>
| -rw-r--r-- | pruefung.tex | 364 |
1 files changed, 326 insertions, 38 deletions
diff --git a/pruefung.tex b/pruefung.tex index cc0a827..ebb2232 100644 --- a/pruefung.tex +++ b/pruefung.tex @@ -6,7 +6,7 @@ \firstpageheadrule \runningheadrule -\lhead{Manuel Traut\\SoSe 2013} +\lhead{Manuel Traut\\Sommersemester 2014} \chead{Hochschule Ravensburg-Weingarten\\Linux-Kernelprogrammierung} \rhead{MatrNr:\\Datum:} @@ -33,13 +33,13 @@ von \pointsonpage{\thepage} Punkten} \begin{titlepage} \title{Pr\"ufung Linux-Kernelprogrammierung} \author{Dozent: Manuel Traut} -\date{02. Juli 2013 16:30 Uhr\\Raum H143} +\date{21. Juli 2014 08:00 Uhr} \maketitle \begin{center} Hochschule Ravensburg-Weingarten \vspace{1cm} -Dauer: 60 Minuten, erlaubte Hilfsmittel: keine +Dauer: 60 Minuten, erlaubte Hilfsmittel: handschriftliche Mitschriebe/Notizen \end{center} \vspace{2cm} @@ -69,81 +69,212 @@ MatrNr:\enspace\hrulefill \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} - -\question[3] Was versteht man unter dem Begriff 'Kernelpatch'? Wie wird ein - Patch erstellt und angewendet? - -\question[4] F\"ur die Linuxkernelentwicklung wurde das - Versionskontrollsystem git entwickelt. Nennen Sie mind. 4 gravierende - Unterschiede zu Versionskontrollsystemen wie cvs oder svn. -\question[6] Beschreiben Sie den Releasezyklus/Versionierung des Linuxkernels - (seit v3.0). Verwenden Sie in diesem Zusammenhang die Begriffe: - 'Release', 'stable Kernel', 'Release Candidate', 'merge window' +\begin{questions} -\question Im Linuxsourcetree gibt es einen Ordner 'staging'. +\section*{Entwicklungsmodell - Development process} + +\question[7] Beschreiben Sie den Releasezyklus und die Versionierung des + Linuxkernel (seit v3.0). Verwenden Sie in diesem Zusammenhang die Begriffe: + 'stable Kernel', 'Release Candidate', 'merge window' +\begin{verbatim} +Describe the release cycle and version numbering of the Linux kernel +(since linux v3.0). Use the terms 'release candidate', 'merge window', +'stable kernel'. +\end{verbatim} + +\question Im Linux Quellcode gibt es einen Ordner 'staging'. +\begin{verbatim} +There is a folder named 'staging' inside the linux source tree. +\end{verbatim} \begin{parts} \part[1] Was findet man in diesem Ordner? -\part[2] Wann wird der Code aus diesem Ordner gel\"oscht / verschoben? +\begin{verbatim} +What is stored in this folder? +\end{verbatim} +\part[2] Wann werden Dateien aus diesem Ordner gel\"oscht / verschoben? +\begin{verbatim} +What conditions needs to be met that a file from this folder will be +moved or deleted? +\end{verbatim} \end{parts} +\question Der Linux Kernel wird im Versionskontrollsystem git verwaltet. +\begin{verbatim} +The Linux kernel is maintained in the version control system git. +\end{verbatim} +\begin{parts} +\part[1] Welches Subkommando verwenden Sie um den Quellcode z.B. des Linux +Kernels auf Ihren PC zu \"ubertragen? +\begin{verbatim} +Which subcommand to you use to transfer e.g. the source code of the linux +kernel to your pc? +\end{verbatim} +\part[3] Was k\"onnen Sie mit dem Subkommando 'branch' alles machen? +\begin{verbatim} +What can be done with the subcommand 'branch'? +\end{verbatim} +\end{parts} + +\newpage + \section*{Tools} \question \begin{parts} -\part[1] Welches Tool ist auf folgendem Bild zu sehen? -\part[1] \"Uber welche Datei wird der Inhalt / Struktur des Tools gesteuert? -\part[8] Welche Einstellungen k\"onnen mit Hilfe dieses Tools konfiguriert - werden? (beschreiben Sie 4 Kategorien) +\part[1] Welches Kommando f\"uhrt zu den Ausgaben auf folgendem Bild? +\begin{verbatim} +Which command was used to produce the following output? +\end{verbatim} +\part[1] \"Uber welche Dateien wird der Inhalt / Struktur des Tools gesteuert? +\begin{verbatim} +What files are used to alter the content and layout of the tool? +\end{verbatim} \end{parts} \includegraphics[height=0.3\textwidth]{./images/kconfig.png} \question[6] Ein von Ihnen entwickelter Kerneltreiber funktioniert nicht wie -erwartet. Welche Debugingm\"oglichkeiten haben Sie? +erwartet. Welche Debugging M\"oglichkeiten haben Sie? Nennen Sie mindestens zwei und beschreiben Sie Vor- und Nachteile -\question[5] Was mu\ss \space ein Bootloader tun um Linux zu booten? +\begin{verbatim} +You developed a linux driver that doesn't work as expected. +What kind of debugging is available? + +Describe the advantages and disadvantages of two different methods. +\end{verbatim} + + +\section*{Rootfilesysteme - Rootfilesystems} + +\question[2] Sie haben ein statisch gelinktes C Programm und wollen, dass der +Kernel dieses direkt anstartet. Wie erreichen Sie dies? +\begin{verbatim} +You have a staticly linked C application that should be started directly by +the kernel. What needs to be done? +\end{verbatim} -\section*{Programmierung} +\question[2] In welchen F\"allen macht es Sinn keine Linux Distribution +einzusetzen? +\begin{verbatim} +In which cases is it useful to avoid using a linux distribution? +\end{verbatim} -\question[6] Kernel- und Userspace arbeiten in unterschiedlichen - Addressr\"aumen. Nennen Sie 3 M\"oglichkeiten, wie Daten zwischen den - Bereichen ausgetauscht werden k\"onnen. Nennen Sie jeweils typische - Verwendung, gegebenenfalls Einschr\"ankungen. +\newpage + +\section*{Programmierung - Programming} \question Das Kernelsubsystem 'Userspace-IO' (UIO) kann zur Entwicklung eigener Treiber verwendet werden. +\begin{verbatim} +The Userspace-IO (UIO) subsystem of the kernel can be used +to develop an own driver. +\end{verbatim} \begin{parts} \part[3] Welche Einschr\"ankungen gelten? -\part[2] Mu\ss \space der komplette Quellcode des Treibers ver\"offentlicht +\begin{verbatim} +What limitations are given? +\end{verbatim} +\part[2] Mu\ss \space der Quellcode des Treibers ver\"offentlicht werden? +\begin{verbatim} +Do you need to publish the source code of the driver? +\end{verbatim} +\part[1] F\"ur welche Hardware macht ein UIO Treiber keinen Sinn? +\begin{verbatim} +For what kind of hardware is an UIO driver non-sense? +\end{verbatim} \end{parts} \question Sie wollen Ihren eigenen Treiber in Mainline Linux integriert haben. +\begin{verbatim} +You have developed an own driver and you want to get it +integrated into mainline linux. +\end{verbatim} \begin{parts} \part[4] Was \"ubermitteln Sie auf welchem Weg wohin? +\begin{verbatim} +What do you transfer? How do you transfer it? And who is the recipient? +\end{verbatim} \part[2] Wie wird die Qualit\"at Ihres Treibers gepr\"uft, wie reagieren Sie gegebenenfalls auf Beanstandungen? +\begin{verbatim} +What will be done to check the quality of your driver? How do you react on +change requests? +\end{verbatim} \end{parts} -\section*{Rootfilesystem} +\newpage + +\question + +Die folgenden Fragen beziehen sich auf den Quellcode des Kernelmoduls im Anhang. +\begin{verbatim} +The following questions are related to the source code of the kernel module +in the appendix. +\end{verbatim} -\question Sie haben ein ARM embedded System mit 256 MB NAND Flash und sollen ein - GNU/Linux Userspace einrichten. Es soll Netzwerk, Bluetooth und Audio - Unterst\"utzung vorhanden sein. \begin{parts} -\part [3] Aus welchen Komponenten besteht das Rootfilesystem? -\part [2] Wie erstellen Sie ein Rootfilesystem f\"ur dieses System? -\part [1] Was mu\ss \space beim \"Ubertragen der Daten auf das Zielmedium - beachtet werden? +\part[2] Welche Zeile Quellcode m\"u\ss en Sie l\"oschen damit der Code keine + Funktion hat? +\begin{verbatim} +Which source-line needs to be deleted to disable the +functionality of the code? +\end{verbatim} + +\part[4] Welche 'virtuellen Dateien' werden von dem Code angelegt? +\begin{verbatim} +Which 'virtual files' are created by this code? +\end{verbatim} + +\part[2] In der probe Funktion wird eine major id ausgegeben. Was k\"onnen + Sie mit dieser Information anfangen? +\begin{verbatim} +The probe function reports a major id. +What can you do with this information? +\end{verbatim} + +\part[4] Sie wollen vom Userspace aus mittels des Kernelmoduls + folgende Datei erstellen. Welche Kommandos oder Pseudo-C Code verwenden Sie? +\begin{verbatim} +You want to use the kernel module to generate the following file from the +userspace. Which commands or Pseudo-C code do you use? +\end{verbatim} + +[/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. +\begin{verbatim} +Choose 3 functions. Explain for each function what triggers the call +and describe its job. +\end{verbatim} + +\part[4] Sie wollen dass der Code keine sysfs device Attribute mehr exportiert. +Nennen Sie alle Bereiche, die gel\"oscht werden k\"onnen. +\begin{verbatim} +You want the code to avoid exporting sysfs device attributes. +Which lines/areas of the source-code can be removed? +\end{verbatim} \end{parts} + \end{questions} \vspace{1cm} @@ -151,4 +282,161 @@ Punkte: \_\_\_\_ von \numpoints \hspace{1cm} Note: +\newpage + +\begin{appendix} +\begin{lstlisting} +/* + * Example driver for Linux + * Copyright (C) 2014, Manuel Traut <manut@mecka.net> + * + * 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 <linux/init.h> +#include <linux/device.h> +#include <linux/fs.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/types.h> + +#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) +{ + return scnprintf(buf, PAGE_SIZE, "%s\n", "show some cool value"); +} + +static ssize_t hswgt_show_rw(struct device *hswgt_dev, + struct device_attribute *hswgt_attr, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%s\n", "write value, look at dmesg"); +} + +static ssize_t hswgt_store_rw(struct device *hswgt_dev, + struct device_attribute *hswgt_attr, const char *buf, size_t count) +{ + pr_notice("hswgt_store_rw: %s", buf); + 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 hswgt_char_open(struct inode *node, struct file *f) +{ + pr_notice("%s\n", __func__); + return 0; +} + +static ssize_t hswgt_char_read(struct file *f, char __user *buf, + size_t count, loff_t *pos) +{ + pr_notice("%s\n", __func__); + memset(buf, 8, count); + return count; +} + +static ssize_t hswgt_char_write(struct file *f, const char __user *buf, + size_t count, loff_t *pos) +{ + size_t i; + for (i = 0; i < count; i++) + pr_notice("%s[%d]: %x\n", __func__, (int)i, buf[i]); + return count; +} + +static const struct file_operations hswgt_fops = { + .open = hswgt_char_open, + .read = hswgt_char_read, + .write = hswgt_char_write, +}; + +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; + } + + major = register_chrdev(0, "hswgt", &hswgt_fops); + if (major < 0) { + ret = major; + pr_err("%s register chrdev failed; %d\n", __func__, ret); + goto failed_char; + } + pr_notice("%s major device node %d\n", + __func__, major); + + return 0; + +failed_char: + unregister_chrdev(major, "hswgt"); +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); + unregister_chrdev(major, "hswgt"); +} + +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} |
