summaryrefslogtreecommitdiff
path: root/2014-pruefung.tex
blob: ebb22326631c5f779dcf2d6ed88ca28080196765 (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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
\documentclass[addpoints,12pt]{exam}

\usepackage{ngerman}
\usepackage{listings,color}
\usepackage{graphicx}

\firstpageheadrule
\runningheadrule
\lhead{Manuel Traut\\Sommersemester 2014}
\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{21. Juli 2014 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[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?
\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 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 Debugging M\"oglichkeiten haben Sie?

Nennen Sie mindestens zwei und beschreiben Sie Vor- und Nachteile

\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}

\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}

\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?
\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}

\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}

\begin{parts}
\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}
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}