* @brief Create a new dfs_mnt structure instance. * * This function allocates memory to create a new dfs_mnt structure instance and initializes it. * If the memory allocation is successful, it copies the input path string into the instance and initializes related lists and flags. * * @param[in] path The path string to be mounted. This path information will be copied to the newly created dfs_m
| 50 | * if the memory allocation fails, returns RT_NULL. |
| 51 | */ |
| 52 | struct dfs_mnt *dfs_mnt_create(const char *path) |
| 53 | { |
| 54 | struct dfs_mnt *mnt = rt_calloc(1, sizeof(struct dfs_mnt)); |
| 55 | if (mnt) |
| 56 | { |
| 57 | LOG_I("create mnt at %s", path); |
| 58 | |
| 59 | mnt->fullpath = rt_strdup(path); |
| 60 | rt_list_init(&mnt->sibling); |
| 61 | rt_list_init(&mnt->child); |
| 62 | mnt->flags |= MNT_IS_ALLOCED; |
| 63 | rt_atomic_store(&(mnt->ref_count), 1); |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | rt_set_errno(-ENOMEM); |
| 68 | } |
| 69 | |
| 70 | return mnt; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @brief Insert a child mount point into the mount tree. |
no test coverage detected