Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\reboot.c Create Date:2022-07-28 09:33:02
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Reboot system call: for obvious reasons only root may call it,* and even root needs to set up some magic numbers in the registers* so that some mistake won't make this reboot the whole machine.* You can also set the meaning of the ctrl-alt-del-key here.

Proto:SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, void __user *, arg)

Type:

Parameter:Nothing

313  pid_ns = task_active_pid_ns(current process)
315  ret = 0
318  If Not ns_capable(user_ns, Allow use of reboot() ) Then Return -EPERM
322  If magic1 != Magic values required to use _reboot() system call. || magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && magic2 != LINUX_REBOOT_MAGIC2B && magic2 != LINUX_REBOOT_MAGIC2C Then Return -EINVAL
334  ret = reboot_pid_ns(pid_ns, cmd)
335  If ret Then Return ret
341  If cmd == LINUX_REBOOT_CMD_POWER_OFF && Not pm_power_off Then cmd = LINUX_REBOOT_CMD_HALT
344  mutex_lock( & system_transition_mutex)
346  Case cmd == Commands accepted by the _reboot() system call.* RESTART Restart system using default command and mode.* HALT Stop OS and give system control to ROM monitor, if any.* CAD_ON Ctrl-Alt-Del sequence causes RESTART command.
347  kernel_restart - reboot the system*@cmd: pointer to buffer containing command to execute for restart* or %NULL* Shutdown everything and perform a clean reboot.* This is not safe to call in interrupt context.
348  Break
350  Case cmd == LINUX_REBOOT_CMD_CAD_ON
351  his indicates whether you can reboot with ctrl-alt-del: the default is yes = 1
352  Break
354  Case cmd == LINUX_REBOOT_CMD_CAD_OFF
355  his indicates whether you can reboot with ctrl-alt-del: the default is yes = 0
356  Break
358  Case cmd == LINUX_REBOOT_CMD_HALT
359  kernel_halt - halt the system* Shutdown everything and perform a clean system halt.
360  do_exit(0)
361  panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
363  Case cmd == LINUX_REBOOT_CMD_POWER_OFF
364  kernel_power_off - power_off the system* Shutdown everything and perform a clean system power_off.
365  do_exit(0)
366  Break
368  Case cmd == LINUX_REBOOT_CMD_RESTART2
369  ret = Copy a NUL terminated string from userspace
370  If ret < 0 Then
371  ret = -EFAULT
372  Break
374  buffer[ size of buffer - 1] = '\0'
376  kernel_restart - reboot the system*@cmd: pointer to buffer containing command to execute for restart* or %NULL* Shutdown everything and perform a clean reboot.* This is not safe to call in interrupt context.
377  Break
380  Case cmd == LINUX_REBOOT_CMD_KEXEC
381  ret = Move into place and start executing a preloaded standalone* executable. If nothing was preloaded return an error.
382  Break
391  Default
392  ret = -EINVAL
393  Break
395  mutex_unlock( & system_transition_mutex)
396  Return ret