diff options
| author | Shell <[email protected]> | 2024-11-12 17:47:51 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2025-01-06 19:34:16 +0800 |
| commit | 944f3d05b508d5eaeaabd8f5d2964847c80dbc3e (patch) | |
| tree | 88e5495e34196d59c5a15b2459769e82bda73c3e /components/dfs | |
| parent | 972931c991e432a1030205959f4be4351a5710d6 (diff) | |
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 <[email protected]>
Diffstat (limited to 'components/dfs')
| -rw-r--r-- | components/dfs/dfs_v2/include/dfs_mnt.h | 3 | ||||
| -rw-r--r-- | components/dfs/dfs_v2/src/dfs_mnt.c | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/components/dfs/dfs_v2/include/dfs_mnt.h b/components/dfs/dfs_v2/include/dfs_mnt.h index 207c9b6bfd..05a7458e92 100644 --- a/components/dfs/dfs_v2/include/dfs_mnt.h +++ b/components/dfs/dfs_v2/include/dfs_mnt.h @@ -64,6 +64,9 @@ rt_bool_t dfs_mnt_has_child_mnt(struct dfs_mnt *mnt, const char* fullpath); int dfs_mnt_foreach(struct dfs_mnt* (*func)(struct dfs_mnt *mnt, void *parameter), void *parameter); +typedef void (*dfs_mnt_umnt_cb_t)(struct dfs_mnt *mnt); +RT_OBJECT_HOOKLIST_DECLARE(dfs_mnt_umnt_cb_t, dfs_mnt_umnt); + #ifdef __cplusplus } #endif diff --git a/components/dfs/dfs_v2/src/dfs_mnt.c b/components/dfs/dfs_v2/src/dfs_mnt.c index 4ad73c6dee..dfae5d12ee 100644 --- a/components/dfs/dfs_v2/src/dfs_mnt.c +++ b/components/dfs/dfs_v2/src/dfs_mnt.c @@ -21,6 +21,8 @@ static struct dfs_mnt *_root_mnt = RT_NULL; +RT_OBJECT_HOOKLIST_DEFINE(dfs_mnt_umnt); + /* * mnt tree structure * @@ -257,6 +259,8 @@ int dfs_mnt_unref(struct dfs_mnt* mnt) if (mnt->flags & MNT_IS_UMOUNT) { mnt->fs_ops->umount(mnt); + + RT_OBJECT_HOOKLIST_CALL(dfs_mnt_umnt, (mnt)); } /* free full path */ |
