Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 2014ss
  • 2015ss
  • 2016ss
  • 2017ss
  • 2018ss
  • 2019ss
  • 2020ss
  • 2021ss
  • 2022ss
  • 2023ss
  • 2024ss
  • 2025ss
12 results

Target

Select target project
  • pgerwinski/bs
  • cloepke/bs
  • khaleeliyeh/bs
3 results
Select Git revision
  • 2014ss
  • 2015ss
  • 2016ss
  • 2017ss
  • 2018ss
  • 2019ss
  • 2020ss
  • 2021ss
  • 2022ss
  • 2023ss
10 results
Show changes
Showing
with 0 additions and 236 deletions
20170512/photo-20170512-142424.jpg

137 KiB

20170512/photo-20170512-142529.jpg

146 KiB

20170512/photo-20170512-142614.jpg

126 KiB

#include <unistd.h>
#include <string.h>
int puts (char *s)
{
int len = strlen (s);
write (0, s, len);
char eol = '\n';
write (0, &eol, 1);
return len + 1;
}
20170519/photo-20170519-150202.jpg

141 KiB

20170519/photo-20170519-150342.jpg

114 KiB

20170519/photo-20170519-150416.jpg

131 KiB

20170519/photo-20170519-150444.jpg

111 KiB

Hello, world! 25.05.2017, 13:31:13
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hello.c:5: printf()
ioputs.c:32: _IO_puts()
ioputs.c:41: _IO_putc_unlocked()
genops.c:227: __overflow()
fileops.c:814: _IO_new_file_overflow()
fileops.c:867: _IO_do_write()
fileops.c:499: _IO_new_do_write()
fileops.c:502: new_do_write()
fileops.c:509: new_do_write()
fileops.c:526: _IO_SYSWRITE()
fileops.c:1263: _IO_new_file_write()
fileops.c:1271: write()
../sysdeps/unix/syscall-template.S:84: write() -- Systemaufruf (System Call), Assembler
0x7ffff7b16590 <write> cmpl $0x0,0x2c21a9(%rip) # 0x7ffff7dd8740 <__libc_multiple_threads>
0x7ffff7b16597 <write+7> jne 0x7ffff7b165a9 <write+25>
0x7ffff7b16599 <__write_nocancel> mov $0x1,%eax
0x7ffff7b1659e <__write_nocancel+5> syscall
0x7ffff7b165a0 <__write_nocancel+7> cmp $0xfffffffffffff001,%rax
0x7ffff7b165a6 <__write_nocancel+13> jae 0x7ffff7b165d9 <write+73>
0x7ffff7b165a8 <__write_nocancel+15> retq
0x7ffff7b165a9 <write+25> sub $0x8,%rsp
0x7ffff7b165ad <write+29> callq 0x7ffff7b30130 <__libc_enable_asynccancel>
0x7ffff7b165b2 <write+34> mov %rax,(%rsp)
0x7ffff7b165b6 <write+38> mov $0x1,%eax
0x7ffff7b165bb <write+43> syscall
0x7ffff7b165bd <write+45> mov (%rsp),%rdi
0x7ffff7b165c1 <write+49> mov %rax,%rdx
0x7ffff7b165c4 <write+52> callq 0x7ffff7b30190 <__libc_disable_asynccancel>
0x7ffff7b165c9 <write+57> mov %rdx,%rax
0x7ffff7b165cc <write+60> add $0x8,%rsp
0x7ffff7b165d0 <write+64> cmp $0xfffffffffffff001,%rax
0x7ffff7b165d6 <write+70> jae 0x7ffff7b165d9 <write+73>
0x7ffff7b165d8 <write+72> retq
0x7ffff7b165d9 <write+73> mov 0x2bc898(%rip),%rcx # 0x7ffff7dd2e78
0x7ffff7b165e0 <write+80> neg %eax
0x7ffff7b165e2 <write+82> mov %eax,%fs:(%rcx)
0x7ffff7b165e5 <write+85> or $0xffffffffffffffff,%rax
0x7ffff7b165e9 <write+89> retq
GDB-Unterbrechungspunkte:
in _IO_puts at ioputs.c:41
in new_do_write at fileops.c:526
in _IO_new_file_write at fileops.c:1271
in main at hello-1.c:5
in __GI___overflow at genops.c:232
GDB Source Directories:
/home/peter/bo/2017ss/bs/20170519/glibc-2.24/libio
/home/peter/bo/2017ss/bs/20170519/glibc-2.24/io
/home/peter/bo/2017ss/bs/20170519/glibc-2.24
Kernel, 25.05.2017, 17:53:23
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suchbegriff: sys_call_table
/usr/src/linux-headers-4.9.0-2-amd64/arch/x86/include/generated/asm/syscalls_64.h
arch/x86/entry/syscall_64.c: Defnition sys_call_table
arch/x86/entry/entry_64.S: Verwendung sys_call_table
arch/x86/kernel/cpu/common.c: wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64);
https://sites.google.com/site/masumzh/articles/hypervisor-based-virtualization/compute-virtualization
"As shown below, the content of the IA32_LSTAR MSR (Model Specific Register)
is copied to the instruction pointer register (RIP) [...]"
--> Weiter geht's mit dem Eintrag in sys_call_table,
also mit der Implementation von sys_write().
Wenn man lange genug sucht, findet man: fs/read_write.c
SYSCALL_DEFINE3(write, unsigned int, fd, const char __user *, buf, size_t, count)
ret = vfs_write(f.file, buf, count, &pos);
ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
ret = __vfs_write(file, buf, count, pos);
ssize_t __vfs_write(struct file *file, const char __user *p, size_t count, loff_t *pos)
if (file->f_op->write) return file->f_op->write(file, p, count, pos);
:-)
Jetzt fehlt nur noch: Wie bekommt f_op->write den Wert, den das Modul hinterlegt hat?
#include <stdio.h>
int main (void)
{
printf ("Hello, world!\n");
return 0;
}
20170602/photo-20170602-142235.jpg

119 KiB

20170602/photo-20170602-142314.jpg

144 KiB

Grafik
~~~~~~
- Beispiel für User-Space-Treiber
- Grafik-Hardware teilt sich Hauptspeicher mit dem Rechner
- Textmodus
- Grafikmodus
- Interpretation der Bits/Bytes
- Umschalten zwischen verschiedenen Modi
- Programm im ROM der Grafikkarte, Software-Interrupt
- Zeichnen: Low Level - am Betriebssystem vorbei
- Programm im ROM der Grafikkarte, Software-Interrupt
- direkter Zugriff auf den Speicher
- Zeichnen: High Level - wozu?
- Portabilität
- Zeichen über das Netzwerk
- Trennung der Anwendungen: mehrere Fenster
- Zeichnen: High Level - Betriebssystem
- Bibliothek
- Integration der Bibliothek in das Betriebssystem
- kontrollierter Low-Level-Zugriff
Aufgabe: Zeichne ein hübsches Bild auf den Computerbildschirm
unter Verwendung der tiefstmöglichen Low-Level-Bibliothek des Betriebssystems:
- Unix/X11: Xlib
- MS-Windows: GDI (oder ggf. GDI+ oder Direct2d)
http://tronche.com/gui/x/
http://tronche.com/gui/x/xlib-tutorial/
http://www.unix-manuals.com/tutorials/xlib/xlib.html
http://en.wikibooks.org/wiki/X_Window_Programming/XLib
http://bobobobo.wordpress.com/
X-Bibliothekten unter Debian-basierten GNU/Linux-Distributionen nachinstallieren:
sudo apt-get update
sudo apt-get install libx11-dev
20170609/photo-20170609-142346.jpg

142 KiB

20170609/photo-20170609-142509.jpg

119 KiB

20170609/photo-20170609-142524.jpg

134 KiB

../20170421/bs-20170421.pdf
\ No newline at end of file
20170623/photo-20170623-145922.jpg

125 KiB

30.06.2017
- Quelltexte RP6 und Linux-Scheduler
- Signale
- Netzwerk-Interfaces
Signale, 23.05.2016, 09:29:58
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Prozeßkontrolle von bash aus: ^C, ^Z, jobs, kill -INT %3, fg, bg
Prozeßkontrolle: ps, ps aux, pstree, kill
Signal-Handler schreiben: signals-*.c
Aufgabe: "Timer-Interrupt" programmieren
Netzwerk-Interfaces, 30.05.2016, 10:36:28
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Loopback-Treiber:
Datei: ~/bo/2016ss/bs/20160509/linux-source-3.16/drivers/net/loopback.c
Suchbegriff: struct net_device_ops
drivers/net: Netzwerkkarten.
net: Protokolle.
Datei: ~/bo/2016ss/bs/20160509/linux-source-3.16/net/
Suchbegriff: ether_setup
Netzwerk-Treiber: früher auch unter /dev, jetzt nicht mehr
- "keine klassischen Datei-Operationen" --> serielle Schnittstellen
- historisch: Hot-Plug-Fähigkeit --> udev [--> systemd]
Netzwerke in der Praxis:
Datei: ~/bo/2013ss/net/script/net-2013ss.pdf
SMTP-Sitzung: E-Mail versenden
$ nc 88.198.170.60 25
220 mx1.gerwinski.de ESMTP Exim 4.84_2 Mon, 30 May 2016 12:39:01 +0200
HELO microsoft.com
250 mx1.gerwinski.de Hello office.g-n-u.de [82.207.128.254]
MAIL FROM: <korbinian.moeller@hs-bochum.de>
250 OK
RCPT TO: <peter@gerwinski.de>
250 Accepted
DATA
354 Enter message, ending with "." on a line by itself
Subject: Test
From: Bill Gates <gates@microsoft.com>
To: Steve Jobs <jobs@apple.com>
Hi! B-)
.
250 OK id=1b7Kbi-0003Ut-CZ
QUIT
221 mx1.gerwinski.de closing connection
$
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#define TARGET_HOST "localhost"
#define PORT 1234
#define MESSAGE "Hello, world!\n"
void error (char *msg)
{
fprintf (stderr, "%s\n", msg);
exit (1);
}
int main (void)
{
int s;
struct sockaddr_in name;
if ((s = socket (PF_INET, SOCK_STREAM, 0)) < 0)
error ("cannot create socket");
memset (&name, 0, sizeof (name));
name.sin_family = AF_INET;
name.sin_port = htons (PORT);
name.sin_addr.s_addr = htonl (INADDR_ANY);
struct hostent *ho = gethostbyname (TARGET_HOST);
if (!ho)
{
close (s);
error ("name server lookup error");
}
if (ho->h_length > (int) sizeof (name.sin_addr))
ho->h_length = sizeof (name.sin_addr);
memcpy (&name.sin_addr, ho->h_addr, ho->h_length);
if (connect (s, (struct sockaddr *) &name, sizeof (name)) < 0)
{
close (s);
error ("cannot connect to socket");
}
send (s, MESSAGE, strlen (MESSAGE), 0);
shutdown (s, SHUT_RDWR);
close (s);
return 0;
}