URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [Documentation/] [magic-number.txt] - Rev 1782
Compare with Previous | Blame | View Log
This file is a registry of magic numbers which are in use. When youadd a magic number to a structure, you should also add it to thisfile, since it is best if the magic numbers used by various structuresare unique.It is a *very* good idea to protect kernel data structures with magicnumbers. This allows you to check at run time whether (a) a structurehas been clobbered, or (b) you've passed the wrong structure to aroutine. This last is especially useful --- particularly when you arepassing pointers to structures via a void * pointer. The tty code,for example, does this frequently to pass driver-specific and linediscipline-specific structures back and forth.The way to use magic numbers is to declare then at the beginning ofthe structure, like so:struct tty_ldisc {int magic;...};Please follow this discipline when you are adding future enhancementsto the kernel! It has saved me countless hours of debugging,especially in the screwy cases where an array has been overrun andstructures following the array have been overwritten. Using thisdiscipline, these cases get detected quickly and safely.Theodore Ts'o31-Mar-94The magic table is current to Linux 1.3.98.Michael Chastain<mec@duracef.shout.net>6 May 1996Magic Name Number Structure File===========================================================================RISCOM8_MAGIC 0x0907 struct riscom_port drivers/char/riscom8.hAPM_BIOS_MAGIC 0x4101 struct apm_struct include/linux/apm_bios.hCYCLADES_MAGIC 0x4359 struct cyclades_port include/linux/cyclades.hFASYNC_MAGIC 0x4601 struct fasync_struct include/linux/fs.hPTY_MAGIC 0x5001 struct pty_struct drivers/char/pty.cPPP_MAGIC 0x5002 struct ppp_struct include/linux/if_ppp.hSERIAL_MAGIC 0x5301 struct async_struct include/linux/serial.hSLIP_MAGIC 0x5302 struct slip drivers/net/slip.hSTRIP_MAGIC 0x5303 struct strip drivers/net/strip.cTTY_MAGIC 0x5401 struct tty_struct include/linux/tty.hTTY_DRIVER_MAGIC 0x5402 struct tty_driver include/linux/tty_driver.hTTY_LDISC_MAGIC 0x5403 struct tty_ldisc include/linux/tty_ldisc.hSCC_MAGIC 0x8530 struct scc_channel include/linux/scc.hISDN_ASYNC_MAGIC 0x49344C01 modem_info include/linux/isdn.hISDN_NET_MAGIC 0x49344C02 isdn_net_ndev include/linux/isdn.hSTLI_BOARDMAGIC 0x4bc6c825 stlibrd_t include/linux/istallion.hSTLI_PORTMAGIC 0xe671c7a1 stliport_t include/linux/istallion.hSTL_PANELMAGIC 0x7ef621a1 stlpanel_t include/linux/stallion.hSTL_BOARDMAGIC 0xa2267f52 stlbrd_t include/linux/stallion.hSTL_PORTMAGIC 0x5a7182c9 stlport_t include/linux/stallion.hPCXX_MAGIC 0x5c6df104 struct channel drivers/char/pcxx.hBAYCOM_MAGIC 0x3105bac0 struct baycom_state drivers/char/baycom.c
