Lines Matching refs:vnode

34 #include "vnode.h"

42 static int g_totalVnodeSize = 0; /* total vnode size */
56 PRINT_ERR("Create mutex for vnode fail, status: %d", retval);
87 struct Vnode *vnode = NULL;
90 PRINT_ERR("get vnode from free list failed, list empty but g_freeVnodeSize = %d!\n", g_freeVnodeSize);
95 vnode = ENTRY_TO_VNODE(LOS_DL_LIST_FIRST(&g_vnodeFreeList));
96 LOS_ListDelete(&vnode->actFreeEntry);
98 return vnode;
123 PRINT_ERR("VnodeAlloc failed, vnode size hit max but can't reclaim anymore!\n");
136 struct Vnode* vnode = NULL;
139 vnode = GetFromFreeList();
140 if ((vnode == NULL) && g_totalVnodeSize < LOSCFG_MAX_VNODE_SIZE) {
141 vnode = (struct Vnode *)zalloc(sizeof(struct Vnode));
145 if (vnode == NULL) {
146 vnode = VnodeReclaimLru();
149 if (vnode == NULL) {
155 vnode->type = VNODE_TYPE_UNKNOWN;
156 LOS_ListInit((&(vnode->parentPathCaches)));
157 LOS_ListInit((&(vnode->childPathCaches)));
158 LOS_ListInit((&(vnode->hashEntry)));
159 LOS_ListInit((&(vnode->actFreeEntry)));
162 LOS_ListAdd(&g_vnodeVirtualList, &(vnode->actFreeEntry));
163 vnode->vop = &g_devfsOps;
165 LOS_ListTailInsert(&g_vnodeActiveList, &(vnode->actFreeEntry));
166 vnode->vop = vop;
168 LOS_ListInit(&vnode->mapping.page_list);
169 LOS_SpinInit(&vnode->mapping.list_lock);
170 (VOID)LOS_MuxInit(&vnode->mapping.mux_lock, NULL);
171 vnode->mapping.host = vnode;
175 *newVnode = vnode;
180 int VnodeFree(struct Vnode *vnode)
182 if (vnode == NULL) {
187 if (vnode->useCount > 0) {
192 VnodePathCacheFree(vnode);
193 LOS_ListDelete(&(vnode->hashEntry));
194 LOS_ListDelete(&vnode->actFreeEntry);
196 if (vnode->vop->Reclaim) {
197 vnode->vop->Reclaim(vnode);
200 if (vnode->filePath) {
201 free(vnode->filePath);
203 if (vnode->vop == &g_devfsOps) {
204 /* for dev vnode, just free it */
205 free(vnode->data);
206 free(vnode);
209 /* for normal vnode, reclaim it to g_VnodeFreeList */
210 (void)memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
211 LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
221 struct Vnode *vnode = NULL;
225 LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(vnode, nextVnode, &g_vnodeActiveList, struct Vnode, actFreeEntry) {
226 if ((vnode->originMount == mount) && !(vnode->flag & VNODE_FLAG_MOUNT_NEW)) {
227 ret = VnodeFree(vnode);
239 struct Vnode *vnode = NULL;
241 LOS_DL_LIST_FOR_EACH_ENTRY(vnode, &g_vnodeActiveList, struct Vnode, actFreeEntry) {
242 if (vnode->originMount == mount) {
243 if ((vnode->useCount > 0) || (vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
300 static struct Vnode *ConvertVnodeIfMounted(struct Vnode *vnode)
302 if ((vnode == NULL) || !(vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
303 return vnode;
309 if ((mnt != NULL) && (mnt->vnodeBeCovered == vnode)) {
313 if (strcmp(vnode->filePath, "/dev") == 0) {
314 return vnode->newMount->vnodeCovered;
316 return vnode;
318 return vnode->newMount->vnodeCovered;
322 static void RefreshLRU(struct Vnode *vnode)
324 if (vnode == NULL || (vnode->type != VNODE_TYPE_REG && vnode->type != VNODE_TYPE_DIR) ||
325 vnode->vop == &g_devfsOps || vnode->vop == NULL) {
328 LOS_ListDelete(&(vnode->actFreeEntry));
329 LOS_ListTailInsert(&g_vnodeActiveList, &(vnode->actFreeEntry));
332 static int ProcessVirtualVnode(struct Vnode *parent, uint32_t flags, struct Vnode **vnode)
336 // only create /dev/ vnode
337 ret = VnodeAlloc(NULL, vnode);
340 (*vnode)->parent = parent;
431 // return target or parent vnode as result
473 int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags)
475 return VnodeLookupAt(path, vnode, flags, NULL);
478 int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags)
480 return VnodeLookupAt(fullpath, vnode, flags, GetCurrRootVnode());
579 int VnodeOpendir(struct Vnode *vnode, struct fs_dirent_s *dir)
581 (void)vnode;
586 int VnodeClosedir(struct Vnode *vnode, struct fs_dirent_s *dir)
588 (void)vnode;
593 int VnodeCreate(struct Vnode *parent, const char *name, int mode, struct Vnode **vnode)
616 *vnode = newVnode;
643 int VnodeGetattr(struct Vnode *vnode, struct stat *buf)
646 buf->st_mode = vnode->mode;
647 buf->st_uid = vnode->uid;
648 buf->st_gid = vnode->gid;
658 static int VnodeChattr(struct Vnode *vnode, struct IATTR *attr)
661 if (vnode == NULL || attr == NULL) {
667 vnode->mode &= S_IFMT;
668 vnode->mode = tmpMode | vnode->mode;
671 vnode->uid = attr->attr_chg_uid;
674 vnode->gid = attr->attr_chg_gid;
679 int VnodeDevLookup(struct Vnode *parentVnode, const char *path, int len, struct Vnode **vnode)
684 (void)vnode;