* @brief Internal function to create a new address space for page cache * * This function allocates and initializes a new address space structure for page caching. * It sets up all necessary lists, locks, and initial values for the address space. * * @param[in] dentry Directory entry containing mount point and path information (can be NULL) * @param[in] vnode Pointer to the vnode structure
| 670 | * @see dfs_aspace_create() for the public interface to create address spaces |
| 671 | */ |
| 672 | static struct dfs_aspace *_dfs_aspace_create(struct dfs_dentry *dentry, |
| 673 | struct dfs_vnode *vnode, |
| 674 | const struct dfs_aspace_ops *ops) |
| 675 | { |
| 676 | struct dfs_aspace *aspace; |
| 677 | |
| 678 | aspace = rt_calloc(1, sizeof(struct dfs_aspace)); |
| 679 | if (aspace) |
| 680 | { |
| 681 | rt_list_init(&aspace->list_active); |
| 682 | rt_list_init(&aspace->list_inactive); |
| 683 | rt_list_init(&aspace->list_dirty); |
| 684 | rt_list_insert_after(&aspace->list_active, &aspace->list_inactive); |
| 685 | |
| 686 | aspace->avl_root.root_node = 0; |
| 687 | aspace->avl_page = 0; |
| 688 | |
| 689 | rt_mutex_init(&aspace->lock, rt_thread_self()->parent.name, RT_IPC_FLAG_PRIO); |
| 690 | rt_atomic_store(&aspace->ref_count, 1); |
| 691 | |
| 692 | aspace->pages_count = 0; |
| 693 | aspace->vnode = vnode; |
| 694 | aspace->ops = ops; |
| 695 | |
| 696 | if (dentry && dentry->mnt) |
| 697 | { |
| 698 | aspace->mnt = dentry->mnt; |
| 699 | aspace->fullpath = rt_strdup(dentry->mnt->fullpath); |
| 700 | aspace->pathname = rt_strdup(dentry->pathname); |
| 701 | } |
| 702 | |
| 703 | dfs_aspace_insert(aspace); |
| 704 | } |
| 705 | |
| 706 | return aspace; |
| 707 | } |
| 708 | |
| 709 | /** |
| 710 | * @brief Create or lookup an address space for page caching |
no test coverage detected