VOP_REMOVE, VOP_RMDIR -- remove a file or directory
#include <sys/param.h>
#include <sys/vnode.h>
int
VOP_REMOVE(struct vnode *dvp, struct vnode *vp,
struct componentname *cnp);
int
VOP_RMDIR(struct vnode *dvp, struct vnode *vp,
struct componentname *cnp);
These entry points remove files and directories respectively.
The arguments are:
dvp the vnode of the directory
vp the vnode of the file to be removed
cnp pathname information about the file
Both dvp and vp should be locked on entry and remain locked on return.
Zero is returned on success, otherwise an error code is returned.
int
vop_remove(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
{
int error = 0;
if (vp is immutable) {
error = EPERM;
goto out;
}
/*
* Remove name cnp->cn_nameptr from directory and update link count
* of vp.
*/
...;
/*
* Careful about trying to remove ".". XXX this should be handled
* higher up.
*/
if (dvp == vp)
vrele(vp);
else
vput(vp);
vput(dvp);
return error;
}
[EPERM] The file is immutable.
[ENOTEMPTY] An attempt was made to remove a directory which is not
empty.
vnode(9), VOP_LOOKUP(9)
This man page was written by Doug Rabson.
FreeBSD 5.2.1 July 24, 1996 FreeBSD 5.2.1 [ Back ] |