DragonFly On-Line Manual Pages

Search: Section:  


VOP_LINK(9)	      DragonFly Kernel Developer's Manual	   VOP_LINK(9)

NAME

VOP_LINK -- create a new name for a file

SYNOPSIS

#include <sys/param.h> #include <sys/vnode.h> int VOP_LINK(struct vnode *dvp, struct vnode *vp, struct componentname *cnp);

DESCRIPTION

This links a new name in the specified directory to an existing file. Its arguments are: dvp the vnode of the directory vp the vnode of the file to be linked cnp pathname information about the file The pathname info must be released on exit. The directory and file vnodes should NOT be released on exit.

LOCKS

The directory, dvp is locked on entry and should remain locked on return. The file vp is not locked on entry and should remain that way on return. If your VOP code locks vp, it must be sure to unlock prior to returning.

RETURN VALUES

Zero is returned if the file was linked successfully, otherwise an error is returned.

PSEUDOCODE

int vop_link(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { int error = 0; if (vp->v_mount != dvp->v_mount) { VOP_ABORTOP(dvp, cnp); error = EXDEV; goto out2; } if (vp != dvp && (error = VOP_LOCK(vp))) { VOP_ABORTOP(dvp, cnp); goto out2; } /* * now that we've locked vp, we have to use out1 instead of out2 */ if (vp would have too many links) { VOP_ABORTOP(dvp, cnp); error = EMLINK; goto out1; } if (vp is immutable) { VOP_ABORTOP(dvp, cnp); error = EPERM; goto out1; } /* * Increment link count of vp and write back the on-disc version of it. */ ...; if (!error) { /* * Add the new name to the directory. */ ...; } kfree(cnp->cn_pnbuf, M_NAMEI); out1: if (vp != dvp) VOP_UNLOCK(vp); out2: return error; }

ERRORS

[EPERM] the file is immutable

SEE ALSO

vnode(9), vn_lock(9)

AUTHORS

This man page was originally written by Doug Rabson. DragonFly 4.1 July 24, 1996 DragonFly 4.1

Search: Section: