4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/t_lock.h>
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/signal.h>
37 #include <sys/vnode.h>
43 #include <sys/pathname.h>
44 #include <sys/fs/ufs_inode.h>
45 #include <sys/fs/ufs_fs.h>
46 #include <sys/mount.h>
47 #include <sys/fs/ufs_fsdir.h>
48 #include <sys/fs/ufs_trans.h>
49 #include <sys/fs/ufs_panic.h>
50 #include <sys/fs/ufs_quota.h>
51 #include <sys/errno.h>
52 #include <sys/debug.h>
54 #include <sys/sysmacros.h>
55 #include <sys/cmn_err.h>
56 #include <sys/cpuvar.h>
57 #include <sys/unistd.h>
67 struct inode
*ip
, *sdp
;
71 if (flags
& LOOKUP_XATTR
) {
72 if (ip
&& ((ip
->i_oeftflag
) != 0)) {
75 error
= ufs_iget(vfsp
, ip
->i_oeftflag
, sip
, cr
);
82 * Make sure it really is an ATTRDIR
84 if ((sdp
->i_mode
& IFMT
) != IFATTRDIR
) {
85 cmn_err(CE_NOTE
, "ufs_getattrdir: inode %d"
86 " points to attribute directory %d "
87 "which is not an attribute directory;"
88 "run fsck on file system",
89 (int)ip
->i_number
, (int)sdp
->i_number
);
93 ITOV(sdp
)->v_type
= VDIR
;
94 ITOV(sdp
)->v_flag
|= V_XATTRDIR
;
97 } else if (flags
& CREATE_XATTR_DIR
) {
98 error
= ufs_xattrmkdir(ip
, sip
, 1, cr
);
104 } else if (flags
& CREATE_XATTR_DIR
) {
105 error
= ufs_xattrmkdir(ip
, sip
, 1, cr
);
115 * Unhook an attribute directory from a parent file/dir
116 * Only do so, if we are the only user of the vnode.
119 ufs_unhook_shadow(struct inode
*ip
, struct inode
*sip
)
121 struct vnode
*datavp
= ITOV(ip
);
122 struct vnode
*dirvp
= ITOV(sip
);
126 ASSERT(RW_WRITE_HELD(&sip
->i_contents
));
127 ASSERT(RW_WRITE_HELD(&ip
->i_contents
));
129 if (vn_is_readonly(ITOV(ip
)))
132 if (ip
->i_ufsvfs
== NULL
|| sip
->i_ufsvfs
== NULL
)
135 hno
= INOHASH(ip
->i_number
);
139 mutex_enter(&datavp
->v_lock
);
140 mutex_enter(&dirvp
->v_lock
);
142 if (dirvp
->v_count
!= 1 && datavp
->v_count
!= 1) {
143 mutex_exit(&dirvp
->v_lock
);
144 mutex_exit(&datavp
->v_lock
);
150 * Delete shadow from ip
155 TRANS_INODE(sip
->i_ufsvfs
, sip
);
164 TRANS_INODE(ip
->i_ufsvfs
, ip
);
168 mutex_exit(&dirvp
->v_lock
);
169 mutex_exit(&datavp
->v_lock
);