Add the utility function vn_commname() to retrieve the command name
from the vfs namecache, when available. Reviewed by: rwatson, rdivacky Tested by: pho
This commit is contained in:
parent
bc04791c82
commit
0a3af16a75
@ -838,3 +838,22 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
|
||||
*retbuf = bp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
vn_commname(struct vnode *vp, char *buf, u_int buflen)
|
||||
{
|
||||
struct namecache *ncp;
|
||||
int l;
|
||||
|
||||
CACHE_LOCK();
|
||||
ncp = TAILQ_FIRST(&vp->v_cache_dst);
|
||||
if (!ncp) {
|
||||
CACHE_UNLOCK();
|
||||
return (ENOENT);
|
||||
}
|
||||
l = min(ncp->nc_nlen, buflen - 1);
|
||||
memcpy(buf, ncp->nc_name, l);
|
||||
CACHE_UNLOCK();
|
||||
buf[l] = '\0';
|
||||
return (0);
|
||||
}
|
||||
|
@ -579,6 +579,7 @@ int speedup_syncer(void);
|
||||
vn_fullpath(FIRST_THREAD_IN_PROC(p), (p)->p_textvp, rb, rfb)
|
||||
int vn_fullpath(struct thread *td, struct vnode *vn,
|
||||
char **retbuf, char **freebuf);
|
||||
int vn_commname(struct vnode *vn, char *buf, u_int buflen);
|
||||
int vaccess(enum vtype type, mode_t file_mode, uid_t file_uid,
|
||||
gid_t file_gid, mode_t acc_mode, struct ucred *cred,
|
||||
int *privused);
|
||||
|
Loading…
x
Reference in New Issue
Block a user