summaryrefslogtreecommitdiff
path: root/pruefung.tex
blob: c2d75d938f9cb20a86a07c12c7f49ec33c89ef16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
\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 : [<c0009378>] lr : [<c00df338>] 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:
[<c0009208>] (prepare_namespace+0x0/0x1d4) from [<c0008610>]
(kernel_init+0x114/0x154)
r5:c00084fc r4:c0396940
[<c00084fc>] (kernel_init+0x0/0x154) from [<c0054a1c>] (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 <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)
{
	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}