5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2015 Joyent, Inc.
26 */
27
28 #include <sys/param.h>
29 #include <sys/errno.h>
30 #include <sys/systm.h>
31 #include <sys/sysmacros.h>
32 #include <sys/buf.h>
33 #include <sys/vfs.h>
34 #include <sys/kmem.h>
35 #include <sys/vnode.h>
36 #include <sys/debug.h>
37 #include <sys/cmn_err.h>
38 #include <sys/sunddi.h>
39 #include <sys/fs/pc_label.h>
40 #include <sys/fs/pc_fs.h>
41 #include <sys/fs/pc_dir.h>
42 #include <sys/fs/pc_node.h>
43
44 static int pc_makedirentry(struct pcnode *dp, struct pcdir *direntries,
45 int ndirentries, struct vattr *vap, offset_t offset);
809 pcp->pc_flags |= PC_CHG;
810 brelse(bp);
811 if (error) {
812 pc_mark_irrecov(VFSTOPCFS(vp->v_vfsp));
813 error = EIO;
814 goto done;
815 }
816 /* No need to fix ".." if we're renaming within a dir */
817 if (oldisdir && dp != tdp) {
818 if ((error = pc_dirfixdotdot(pcp, dp, tdp)) != 0) {
819 goto done;
820 }
821 }
822 if ((error = pc_nodeupdate(pcp)) != 0) {
823 goto done;
824 }
825 }
826
827 if (error == 0) {
828 vnevent_rename_src(PCTOV(pcp), PCTOV(dp), snm, ctp);
829 if (dp != tdp)
830 vnevent_rename_dest_dir(PCTOV(tdp), ctp);
831 }
832
833 done:
834 if (tpcp != NULL)
835 VN_RELE(PCTOV(tpcp));
836 VN_RELE(PCTOV(pcp));
837
838 return (error);
839 }
840
841 /*
842 * Fix the ".." entry of the child directory so that it points to the
843 * new parent directory instead of the old one.
844 */
845 static int
846 pc_dirfixdotdot(struct pcnode *dp, /* child directory being moved */
847 struct pcnode *opdp, /* old parent directory */
848 struct pcnode *npdp) /* new parent directory */
849 {
850 pc_cluster32_t cn;
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2016 Joyent, Inc.
26 */
27
28 #include <sys/param.h>
29 #include <sys/errno.h>
30 #include <sys/systm.h>
31 #include <sys/sysmacros.h>
32 #include <sys/buf.h>
33 #include <sys/vfs.h>
34 #include <sys/kmem.h>
35 #include <sys/vnode.h>
36 #include <sys/debug.h>
37 #include <sys/cmn_err.h>
38 #include <sys/sunddi.h>
39 #include <sys/fs/pc_label.h>
40 #include <sys/fs/pc_fs.h>
41 #include <sys/fs/pc_dir.h>
42 #include <sys/fs/pc_node.h>
43
44 static int pc_makedirentry(struct pcnode *dp, struct pcdir *direntries,
45 int ndirentries, struct vattr *vap, offset_t offset);
809 pcp->pc_flags |= PC_CHG;
810 brelse(bp);
811 if (error) {
812 pc_mark_irrecov(VFSTOPCFS(vp->v_vfsp));
813 error = EIO;
814 goto done;
815 }
816 /* No need to fix ".." if we're renaming within a dir */
817 if (oldisdir && dp != tdp) {
818 if ((error = pc_dirfixdotdot(pcp, dp, tdp)) != 0) {
819 goto done;
820 }
821 }
822 if ((error = pc_nodeupdate(pcp)) != 0) {
823 goto done;
824 }
825 }
826
827 if (error == 0) {
828 vnevent_rename_src(PCTOV(pcp), PCTOV(dp), snm, ctp);
829 vnevent_rename_dest_dir(PCTOV(tdp), PCTOV(pcp), tnm, ctp);
830 }
831
832 done:
833 if (tpcp != NULL)
834 VN_RELE(PCTOV(tpcp));
835 VN_RELE(PCTOV(pcp));
836
837 return (error);
838 }
839
840 /*
841 * Fix the ".." entry of the child directory so that it points to the
842 * new parent directory instead of the old one.
843 */
844 static int
845 pc_dirfixdotdot(struct pcnode *dp, /* child directory being moved */
846 struct pcnode *opdp, /* old parent directory */
847 struct pcnode *npdp) /* new parent directory */
848 {
849 pc_cluster32_t cn;
|