Lines Matching +full:vp +full:- +full:p

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2000-2001 Boris Popov
56 extern struct vop_vector smbfs_vnodeops; /* XXX -> .h file */
74 bcopy(name, cp, nmlen - 1); in smbfs_name_alloc()
75 cp[nmlen - 1] = 0; in smbfs_name_alloc()
87 smbfs_vnode_cmp(struct vnode *vp, void *_sc) in smbfs_vnode_cmp() argument
92 np = (struct smbnode *) vp->v_data; in smbfs_vnode_cmp()
94 if (np->n_parent != sc->n_parent || np->n_nmlen != sc->n_nmlen || in smbfs_vnode_cmp()
95 bcmp(sc->n_name, np->n_name, sc->n_nmlen) != 0) in smbfs_vnode_cmp()
109 struct vnode *vp, *vp2; in smbfs_node_alloc() local
111 char *p, *rpath; in smbfs_node_alloc() local
117 if (smp->sm_root != NULL && dvp == NULL) { in smbfs_node_alloc()
124 vp = VTOSMB(VTOSMB(dvp)->n_parent)->n_vnode; in smbfs_node_alloc()
125 error = vget(vp, LK_EXCLUSIVE); in smbfs_node_alloc()
127 *vpp = vp; in smbfs_node_alloc()
145 (void)VOP_GETATTR(*vpp, &vattr, td->td_ucred); in smbfs_node_alloc()
152 if (((*vpp)->v_type == VDIR && in smbfs_node_alloc()
153 (np->n_dosattr & SMB_FA_DIR) == 0) || in smbfs_node_alloc()
154 ((*vpp)->v_type == VREG && in smbfs_node_alloc()
155 (np->n_dosattr & SMB_FA_DIR) != 0)) { in smbfs_node_alloc()
174 vp = *vpp; in smbfs_node_alloc()
181 p = rpath; in smbfs_node_alloc()
182 bcopy(dirnm, p, dirlen); in smbfs_node_alloc()
183 p += dirlen; in smbfs_node_alloc()
185 *p++ = sep; in smbfs_node_alloc()
187 bcopy(name, p, nmlen); in smbfs_node_alloc()
188 p += nmlen; in smbfs_node_alloc()
190 *p = '\0'; in smbfs_node_alloc()
191 MPASS(p == rpath + rplen); in smbfs_node_alloc()
192 lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); in smbfs_node_alloc()
194 vp->v_type = fap->fa_attr & SMB_FA_DIR ? VDIR : VREG; in smbfs_node_alloc()
195 vp->v_data = np; in smbfs_node_alloc()
196 np->n_vnode = vp; in smbfs_node_alloc()
197 np->n_mount = VFSTOSMBFS(mp); in smbfs_node_alloc()
198 np->n_rpath = rpath; in smbfs_node_alloc()
199 np->n_rplen = rplen; in smbfs_node_alloc()
200 np->n_nmlen = nmlen; in smbfs_node_alloc()
201 np->n_name = smbfs_name_alloc(name, nmlen); in smbfs_node_alloc()
202 np->n_ino = fap->fa_ino; in smbfs_node_alloc()
205 np->n_parent = dvp; in smbfs_node_alloc()
206 np->n_parentino = VTOSMB(dvp)->n_ino; in smbfs_node_alloc()
207 if (/*vp->v_type == VDIR &&*/ (dvp->v_vflag & VV_ROOT) == 0) { in smbfs_node_alloc()
209 np->n_flag |= NREFPARENT; in smbfs_node_alloc()
211 } else if (vp->v_type == VREG) in smbfs_node_alloc()
212 SMBERROR("new vnode '%s' born without parent ?\n", np->n_name); in smbfs_node_alloc()
213 error = insmntque(vp, mp); in smbfs_node_alloc()
218 vn_set_state(vp, VSTATE_CONSTRUCTED); in smbfs_node_alloc()
219 error = vfs_hash_insert(vp, smbfs_hash(name, nmlen), LK_EXCLUSIVE, in smbfs_node_alloc()
233 struct vnode *vp; in smbfs_nget() local
240 error = smbfs_node_alloc(mp, dvp, dnp->n_rpath, dnp->n_rplen, in smbfs_nget()
241 name, nmlen, sep, fap, &vp); in smbfs_nget()
244 sep, fap, &vp); in smbfs_nget()
247 MPASS(vp != NULL); in smbfs_nget()
249 smbfs_attr_cacheenter(vp, fap); in smbfs_nget()
250 *vpp = vp; in smbfs_nget()
260 struct vnode *vp = ap->a_vp; in smbfs_reclaim() local
262 struct smbnode *np = VTOSMB(vp); in smbfs_reclaim()
263 struct smbmount *smp = VTOSMBFS(vp); in smbfs_reclaim()
265 SMBVDEBUG("%s,%d\n", np->n_name, vrefcnt(vp)); in smbfs_reclaim()
267 KASSERT((np->n_flag & NOPEN) == 0, ("file not closed before reclaim")); in smbfs_reclaim()
269 dvp = (np->n_parent && (np->n_flag & NREFPARENT)) ? in smbfs_reclaim()
270 np->n_parent : NULL; in smbfs_reclaim()
275 vfs_hash_remove(vp); in smbfs_reclaim()
276 if (np->n_name) in smbfs_reclaim()
277 smbfs_name_free(np->n_name); in smbfs_reclaim()
278 if (np->n_rpath) in smbfs_reclaim()
279 free(np->n_rpath, M_SMBNODENAME); in smbfs_reclaim()
281 vp->v_data = NULL; in smbfs_reclaim()
288 smp->sm_didrele = 1; in smbfs_reclaim()
297 struct ucred *cred = td->td_ucred; in smbfs_inactive()
298 struct vnode *vp = ap->a_vp; in smbfs_inactive() local
299 struct smbnode *np = VTOSMB(vp); in smbfs_inactive()
303 SMBVDEBUG("%s: %d\n", VTOSMB(vp)->n_name, vrefcnt(vp)); in smbfs_inactive()
304 if ((np->n_flag & NOPEN) != 0) { in smbfs_inactive()
307 smbfs_vinvalbuf(vp, td); in smbfs_inactive()
308 if (vp->v_type == VREG) { in smbfs_inactive()
309 VOP_GETATTR(vp, &va, cred); in smbfs_inactive()
310 smbfs_smb_close(np->n_mount->sm_share, np->n_fid, in smbfs_inactive()
311 &np->n_mtime, scred); in smbfs_inactive()
312 } else if (vp->v_type == VDIR) { in smbfs_inactive()
313 if (np->n_dirseq != NULL) { in smbfs_inactive()
314 smbfs_findclose(np->n_dirseq, scred); in smbfs_inactive()
315 np->n_dirseq = NULL; in smbfs_inactive()
318 np->n_flag &= ~NOPEN; in smbfs_inactive()
319 smbfs_attr_cacheremove(vp); in smbfs_inactive()
322 if (np->n_flag & NGONE) in smbfs_inactive()
323 vrecycle(vp); in smbfs_inactive()
331 smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap) in smbfs_attr_cacheenter() argument
333 struct smbnode *np = VTOSMB(vp); in smbfs_attr_cacheenter()
335 if (vp->v_type == VREG) { in smbfs_attr_cacheenter()
336 if (np->n_size != fap->fa_size) { in smbfs_attr_cacheenter()
337 np->n_size = fap->fa_size; in smbfs_attr_cacheenter()
338 vnode_pager_setsize(vp, np->n_size); in smbfs_attr_cacheenter()
340 } else if (vp->v_type == VDIR) { in smbfs_attr_cacheenter()
341 np->n_size = 16384; /* should be a better way ... */ in smbfs_attr_cacheenter()
344 np->n_mtime = fap->fa_mtime; in smbfs_attr_cacheenter()
345 np->n_dosattr = fap->fa_attr; in smbfs_attr_cacheenter()
346 np->n_attrage = time_second; in smbfs_attr_cacheenter()
351 smbfs_attr_cachelookup(struct vnode *vp, struct vattr *va) in smbfs_attr_cachelookup() argument
353 struct smbnode *np = VTOSMB(vp); in smbfs_attr_cachelookup()
354 struct smbmount *smp = VTOSMBFS(vp); in smbfs_attr_cachelookup()
357 diff = time_second - np->n_attrage; in smbfs_attr_cachelookup()
360 va->va_type = vp->v_type; /* vnode type (for create) */ in smbfs_attr_cachelookup()
361 va->va_flags = 0; /* flags defined for file */ in smbfs_attr_cachelookup()
362 if (vp->v_type == VREG) { in smbfs_attr_cachelookup()
363 va->va_mode = smp->sm_file_mode; /* files access mode and type */ in smbfs_attr_cachelookup()
364 if (np->n_dosattr & SMB_FA_RDONLY) { in smbfs_attr_cachelookup()
365 va->va_mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); in smbfs_attr_cachelookup()
366 va->va_flags |= UF_READONLY; in smbfs_attr_cachelookup()
368 } else if (vp->v_type == VDIR) { in smbfs_attr_cachelookup()
369 va->va_mode = smp->sm_dir_mode; /* files access mode and type */ in smbfs_attr_cachelookup()
372 va->va_size = np->n_size; in smbfs_attr_cachelookup()
373 va->va_nlink = 1; /* number of references to file */ in smbfs_attr_cachelookup()
374 va->va_uid = smp->sm_uid; /* owner user id */ in smbfs_attr_cachelookup()
375 va->va_gid = smp->sm_gid; /* owner group id */ in smbfs_attr_cachelookup()
376 va->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0]; in smbfs_attr_cachelookup()
377 va->va_fileid = np->n_ino; /* file id */ in smbfs_attr_cachelookup()
378 if (va->va_fileid == 0) in smbfs_attr_cachelookup()
379 va->va_fileid = 2; in smbfs_attr_cachelookup()
380 va->va_blocksize = SSTOVC(smp->sm_share)->vc_txmax; in smbfs_attr_cachelookup()
381 va->va_mtime = np->n_mtime; in smbfs_attr_cachelookup()
382 va->va_atime = va->va_ctime = va->va_mtime; /* time file changed */ in smbfs_attr_cachelookup()
383 va->va_gen = VNOVAL; /* generation number of file */ in smbfs_attr_cachelookup()
384 if (np->n_dosattr & SMB_FA_HIDDEN) in smbfs_attr_cachelookup()
385 va->va_flags |= UF_HIDDEN; in smbfs_attr_cachelookup()
386 if (np->n_dosattr & SMB_FA_SYSTEM) in smbfs_attr_cachelookup()
387 va->va_flags |= UF_SYSTEM; in smbfs_attr_cachelookup()
391 if ((vp->v_type != VDIR) && (np->n_dosattr & SMB_FA_ARCHIVE)) in smbfs_attr_cachelookup()
392 va->va_flags |= UF_ARCHIVE; in smbfs_attr_cachelookup()
393 va->va_rdev = NODEV; /* device the special file represents */ in smbfs_attr_cachelookup()
394 va->va_bytes = va->va_size; /* bytes of disk space held by file */ in smbfs_attr_cachelookup()
395 va->va_filerev = 0; /* file modification number */ in smbfs_attr_cachelookup()
396 va->va_vaflags = 0; /* operations flags */ in smbfs_attr_cachelookup()