-
- /*
- * If deleting, and at end of pathname, return
- * parameters which can be used to remove file.
- */
- if (nameiop == DELETE && (flags & ISLASTCN)) {
- /*
- * Write access to directory required to delete files.
- */
- if ((retval = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_proc)))
- goto exit;
-
- if (isDot) { /* Want to return ourselves */
- VREF(dvp);
- *vpp = dvp;
- goto exit;
- } else if (flags & ISDOTDOT) {
- retval = hfs_getcnode(hfsmp, dcp->c_parentcnid,
- NULL, 0, NULL, NULL, &tvp);
- if (retval)
- goto exit;
- } else {
- retval = hfs_getcnode(hfsmp, attr.ca_fileid,
- &desc, wantrsrc, &attr, &fork, &tvp);
- if (retval)
- goto exit;
- }
-
- /*
- * If directory is "sticky", then user must own
- * the directory, or the file in it, else she
- * may not delete it (unless she's root). This
- * implements append-only directories.
- */
- if ((dcp->c_mode & S_ISTXT) &&
- (cred->cr_uid != 0) &&
- (cred->cr_uid != dcp->c_uid) &&
- (tvp->v_type != VLNK) &&
- (hfs_owner_rights(hfsmp, VTOC(tvp)->c_uid, cred, p, false))) {
- vput(tvp);
- retval = EPERM;
- goto exit;
- }
-
- /*
- * If this is a link node then we need to save the name
- * (of the link) so we can delete it from the catalog b-tree.
- * In this case, hfs_remove will then free the component name.
- *
- * DJB - IS THIS STILL NEEDED????
- */
- if (tvp && (VTOC(tvp)->c_flag & C_HARDLINK))
- cnp->cn_flags |= SAVENAME;
-
- if (!(flags & LOCKPARENT))
- VOP_UNLOCK(dvp, 0, p);
- *vpp = tvp;
- goto exit;
- }
-
- /*
- * If renaming, return the cnode and save the current name.
- */
- if (nameiop == RENAME && wantparent && (flags & ISLASTCN)) {
- if ((retval = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_proc)) != 0)
- goto exit;
- /*
- * Careful about locking second cnode.
- */
- if (isDot) {
- retval = EISDIR;
- goto exit;
- } else if (flags & ISDOTDOT) {
- retval = hfs_getcnode(hfsmp, dcp->c_parentcnid,
- NULL, 0, NULL, NULL, &tvp);
- if (retval)
- goto exit;
- } else {
- retval = hfs_getcnode(hfsmp, attr.ca_fileid,
- &desc, wantrsrc, &attr, &fork, &tvp);
- if (retval)