Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the purpose of the magic number in linux reboots? [closed]

Tags:

linux

reboot

On the Wikipedia page for Linus Torvalds, it states that:

'The Linux kernel's reboot system call accepts their dates of birth (written in hexadecimal) as magic values'.

And documentation for the Linux reboot function shows that it needs two magic numbers, 'magic' and 'magic2' too reboot.

What is the purpose of these magic numbers? Why can't the function operate without them?

Thanks

like image 349
jambolina Avatar asked Dec 16 '22 06:12

jambolina


1 Answers

A quick google of your question yields the answer;

http://www.eeggs.com/items/44291.html

In order to prevent the reboot() system call being called inadvertently, you must pass it a pair of magic values in the first two parameters. The first magic value is 0xfee1dead. The second magic value is one of:

$ grep LINUX_REBOOT_MAGIC include/linux/*.h
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC1 0xfee1dead
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2 672274793
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2A 85072278
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2B 369367448
include/linux/reboot.h:#define LINUX_REBOOT_MAGIC2C 537993216

These are dates of significance to Linus; hint you can use perl to convert them into dates:

$ perl -e 'print localtime(672274793). "\n";'

Sun Apr 21 18:59:53 1991

This is the date that Linus first started writing Linux. The significance of other dates is left as an exercise for the reader ;-)

like image 168
Mike Makuch Avatar answered Jan 19 '23 00:01

Mike Makuch