Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
VOP_LINK(9)	       FreeBSD Kernel Developer's Manual	   VOP_LINK(9)

NAME
     VOP_LINK -- create	a new name for a file

SYNOPSIS
     #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

     AT&T UNIX vp
	 the vnode of the file to be linked

     cnp
	 pathname information about the	file

     The directory vnode is unlocked and released on exit.

LOCKS
     The directory, dvp	should be locked on entry and will be unlocked and
     released on exit.	The file vp should not be locked.

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

	 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.
	      */
	     ...;
	 }

	 free(cnp->cn_pnbuf, M_NAMEI);
     out1:
	 if (vp	!= dvp)
	     VOP_UNLOCK(vp);
     out2:
	 vput(dvp);

	 return	error;
     }

ERRORS
     [EPERM]		the file is immutable

SEE ALSO
     vnode(9)

AUTHORS
     This man page was written by Doug Rabson.

FreeBSD	11.1			 July 24, 1996			  FreeBSD 11.1

NAME | SYNOPSIS | DESCRIPTION | LOCKS | RETURN VALUES | PSEUDOCODE | ERRORS | SEE ALSO | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=VOP_LINK&sektion=9&manpath=FreeBSD+2.2.1-RELEASE>

home | help