1 |
199 |
simons |
This file is a registry of magic numbers which are in use. When you
|
2 |
|
|
add a magic number to a structure, you should also add it to this
|
3 |
|
|
file, since it is best if the magic numbers used by various structures
|
4 |
|
|
are unique.
|
5 |
|
|
|
6 |
|
|
It is a *very* good idea to protect kernel data structures with magic
|
7 |
|
|
numbers. This allows you to check at run time whether (a) a structure
|
8 |
|
|
has been clobbered, or (b) you've passed the wrong structure to a
|
9 |
|
|
routine. This last is especially useful --- particularly when you are
|
10 |
|
|
passing pointers to structures via a void * pointer. The tty code,
|
11 |
|
|
for example, does this frequently to pass driver-specific and line
|
12 |
|
|
discipline-specific structures back and forth.
|
13 |
|
|
|
14 |
|
|
The way to use magic numbers is to declare then at the beginning of
|
15 |
|
|
the structure, like so:
|
16 |
|
|
|
17 |
|
|
struct tty_ldisc {
|
18 |
|
|
int magic;
|
19 |
|
|
...
|
20 |
|
|
};
|
21 |
|
|
|
22 |
|
|
Please follow this discipline when you are adding future enhancements
|
23 |
|
|
to the kernel! It has saved me countless hours of debugging,
|
24 |
|
|
especially in the screwy cases where an array has been overrun and
|
25 |
|
|
structures following the array have been overwritten. Using this
|
26 |
|
|
discipline, these cases get detected quickly and safely.
|
27 |
|
|
|
28 |
|
|
Theodore Ts'o
|
29 |
|
|
31-Mar-94
|
30 |
|
|
|
31 |
|
|
The magic table is current to Linux 1.3.98.
|
32 |
|
|
|
33 |
|
|
Michael Chastain
|
34 |
|
|
|
35 |
|
|
6 May 1996
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
Magic Name Number Structure File
|
40 |
|
|
===========================================================================
|
41 |
|
|
RISCOM8_MAGIC 0x0907 struct riscom_port drivers/char/riscom8.h
|
42 |
|
|
APM_BIOS_MAGIC 0x4101 struct apm_struct include/linux/apm_bios.h
|
43 |
|
|
CYCLADES_MAGIC 0x4359 struct cyclades_port include/linux/cyclades.h
|
44 |
|
|
FASYNC_MAGIC 0x4601 struct fasync_struct include/linux/fs.h
|
45 |
|
|
PTY_MAGIC 0x5001 struct pty_struct drivers/char/pty.c
|
46 |
|
|
PPP_MAGIC 0x5002 struct ppp_struct include/linux/if_ppp.h
|
47 |
|
|
SERIAL_MAGIC 0x5301 struct async_struct include/linux/serial.h
|
48 |
|
|
SLIP_MAGIC 0x5302 struct slip drivers/net/slip.h
|
49 |
|
|
STRIP_MAGIC 0x5303 struct strip drivers/net/strip.c
|
50 |
|
|
TTY_MAGIC 0x5401 struct tty_struct include/linux/tty.h
|
51 |
|
|
TTY_DRIVER_MAGIC 0x5402 struct tty_driver include/linux/tty_driver.h
|
52 |
|
|
TTY_LDISC_MAGIC 0x5403 struct tty_ldisc include/linux/tty_ldisc.h
|
53 |
|
|
SCC_MAGIC 0x8530 struct scc_channel include/linux/scc.h
|
54 |
|
|
ISDN_ASYNC_MAGIC 0x49344C01 modem_info include/linux/isdn.h
|
55 |
|
|
ISDN_NET_MAGIC 0x49344C02 isdn_net_ndev include/linux/isdn.h
|
56 |
|
|
STLI_BOARDMAGIC 0x4bc6c825 stlibrd_t include/linux/istallion.h
|
57 |
|
|
STLI_PORTMAGIC 0xe671c7a1 stliport_t include/linux/istallion.h
|
58 |
|
|
STL_PANELMAGIC 0x7ef621a1 stlpanel_t include/linux/stallion.h
|
59 |
|
|
STL_BOARDMAGIC 0xa2267f52 stlbrd_t include/linux/stallion.h
|
60 |
|
|
STL_PORTMAGIC 0x5a7182c9 stlport_t include/linux/stallion.h
|
61 |
|
|
PCXX_MAGIC 0x5c6df104 struct channel drivers/char/pcxx.h
|
62 |
|
|
BAYCOM_MAGIC 0x3105bac0 struct baycom_state drivers/char/baycom.c
|
63 |
|
|
|