VOP_LINK man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

VOP_LINK(9)		 BSD 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.

BSD				 July 24, 1996				   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net