Debian Codegraph @

doc/navigating

raw
1 Some ideas on navigating and understanding the Hurd source code.
2
3 First you must understand Mach IPC and MiG. Pay special attention to
4 the way that various kinds of MiG calls manage memory; this is crucial
5 to avoid leaks. The "Mach server writers' guide" explains all this.
6
7 Most programs that make up the Hurd are built out of libraries; a
8 solid understanding of the libraries that make up the source is
9 essential. First start by reading the libports library specification
10 (in libports/ports.h). This library manages the Mach ports that
11 servers handle.
12
13 Then start looking at some Hurd interfaces. A good place to start is
14 to look at the proc server. There is only one proc server in a
15 running system, but examine the way the interface (hurd/process.defs)
16 is written and the way the proc server implements it.
17
18 Then look at the auth server; make sure you understand how an auth
19 transaction works. Again, by looking at the implementation, you can
20 see a simple example.
21
22 Filesystems are more complex; the interface specification is in
23 hurd/io.defs and hurd/fs.defs. These interfaces are implemented by
24 three different libraries: trivfs, diskfs, and netfs. trivfs
25 implements single-node filesystems (that thus have no directories).
26 Most trivfs filesystems don't even do any filesystem stuff at all.
27 See, for example, the null translator (trans/null.c) for a simple
28 example of using trivfs.
29
30 diskfs is used for disk-based filesystems, with one in existence now:
31 ext2fs. If you write another diskfs-based filesystem, you
32 should DEFINITELY imitate the algorithms found in ext2fs; this
33 is crucial to getting locking right.
34
35 netfs is used for nfs and other such things: with directories, and all
36 the actual filesystem operations being done by some other program (not
37 necessarily over a network). The nfs implementation is fairly easy to
38 understand.
39
40 Examine some translators in the trans directory to see various simple
41 examples.
42
43 Also very important is to acquire familiarity with the Hurd and Mach
44 calls provided in the GNU C library. Look at the header files in libc
45 to see what they are, and read through them. Also examine parts of
46 the libc implementation whenever you have any doubt about what an
47 interface call should do: find where the C library uses that call, and
48 that should help. It's worth, in fact, spending some time just
49 exploring the implementation of various things in the hurd C library.
50
51 You should take a look at all the libraries in the Hurd; spend time
52 reading the code. Feel free to ask questions to help understand what
53 you read.