feat: add system reboot and process teardown support

The patch introduces support for system reboot functionality and process teardown,
allowing for a clean shutdown and unmounting of the root filesystem. This is
necessary for ensuring a proper system shutdown process, especially when dealing
with resource cleanup and ensuring that all processes have exited before system
shutdown.

Changes:
- Added `lwp_teardown()` function to handle process cleanup and system teardown.
- Introduced `lwp_pid_wait_for_empty()` to wait for process ID table emptiness
  before proceeding with shutdown.
- Updated `dfs_mnt_unref()` to trigger callbacks when unmounting a filesystem.
- Added new reboot types (`RB_AUTOBOOT`, `RB_POWER_OFF`) and implemented their
  corresponding actions, including cleanup of processes and unmounting root
  filesystem.
- Extended `sys_reboot()` to handle reboot and power off types with appropriate
  callbacks for process and filesystem teardown.
- Introduced callback mechanism for root filesystem unmount notifications.

Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
Shell
2024-11-12 17:47:51 +08:00
committed by Rbb666
parent 972931c991
commit 944f3d05b5
8 changed files with 117 additions and 7 deletions

View File

@@ -26,7 +26,7 @@ struct rt_lwp;
struct lwp_avl_struct *lwp_get_pid_ary(void);
int lwp_pid_init(void);
int lwp_pid_wait_for_empty(int wait_flags, rt_tick_t to);
int lwp_pid_for_each(int (*cb)(pid_t pid, void *data), void *data);
void lwp_pid_put(struct rt_lwp *lwp);
void lwp_pid_lock_take(void);