#include <unistd.h>
#include <sys/reboot.h>

int reboot(int flag);


------------------------------------
#include <unistd.h>
#include <sys/reboot.h>
3 int main()
4 {
5     /* 同步磁盘数据,将缓存数据回写到硬盘,以防数据丢失 */
6     sync();
7     return reboot(RB_AUTOBOOT);
8 }




vim /usr/include/sys/reboot.h
--------------------------------------------------
#define RB_AUTOBOOT          0x01234567
#define RB_HALT_SYSTEM       0xcdef0123
#define RB_ENABLE_CAD        0x89abcdef
#define RB_DISABLE_CAD       0
#define RB_POWER_OFF         0x4321fedc
 




1 sys_reboot() -->
2     kernel_restart() -->
3        kernel_restart_prepare()
4        machine_restart()




linux-2.6.21.7/include/linux/reboot.h
--------------------------------------------
#define    LINUX_REBOOT_CMD_RESTART     0x01234567
#define    LINUX_REBOOT_CMD_HALT        0xCDEF0123
#define    LINUX_REBOOT_CMD_CAD_ON      0x89ABCDEF
#define    LINUX_REBOOT_CMD_CAD_OFF     0x00000000
#define    LINUX_REBOOT_CMD_POWER_OFF   0x4321FEDC
#define    LINUX_REBOOT_CMD_RESTART2    0xA1B2C3D4
#define    LINUX_REBOOT_CMD_SW_SUSPEND  0xD000FCE2
#define    LINUX_REBOOT_CMD_KEXEC       0x45584543
Logo

更多推荐