diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index d45fc7837d82..427209f3bb64 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -953,3 +953,26 @@ vn_extattr_set(struct vnode *vp, int ioflg, const char *attrname, int buflen, return (error); } + +int +vn_extattr_rm(struct vnode *vp, int ioflg, const char *attrname, struct proc *p) +{ + struct mount *mp; + int error; + + if ((ioflg & IO_NODELOCKED) == 0) { + if ((error = vn_start_write(vp, &mp, V_WAIT)) != 0) + return (error); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); + } + + /* authorize attribute removal as kernel */ + error = VOP_SETEXTATTR(vp, attrname, NULL, NULL, p); + + if ((ioflg & IO_NODELOCKED) == 0) { + vn_finished_write(mp); + VOP_UNLOCK(vp, 0, p); + } + + return (error); +} diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 247d772eadf4..10b2ad4849e2 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -601,6 +601,8 @@ int vn_extattr_get __P((struct vnode *vp, int ioflg, const char *attrname, int *buflen, char *buf, struct proc *p)); int vn_extattr_set __P((struct vnode *vp, int ioflg, const char *attrname, int buflen, char *buf, struct proc *p)); +int vn_extattr_rm(struct vnode *vp, int ioflg, const char *attrname, + struct proc *p); int vfs_cache_lookup __P((struct vop_lookup_args *ap)); int vfs_object_create __P((struct vnode *vp, struct proc *p, struct ucred *cred));