VOP_REMOVE(9)

VOP_REMOVE9

Remove a file or directory

Usage

#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);

Overview

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.

Locks

Both dvp and vp should be locked on entry and remain locked on return.

Return values

Zero is returned on success, otherwise an error code is returned.

Pseudocode

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;
}

Errors

[EPERM]

The file is immutable.

[ENOTEMPTY]

An attempt was made to remove a directory which is not empty.

Authors

This manual page was written by Doug Rabson.

From freebsd-manpages 6.0-5 in Debian 4.0 (Etch). Parsed by carta from the page's mdoc source.