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 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <sys/param.h>
29 #include <sys/t_lock.h>
30 #include <sys/errno.h>
31 #include <sys/sysmacros.h>
32 #include <sys/buf.h>
33 #include <sys/systm.h>
34 #include <sys/vfs.h>
35 #include <sys/vnode.h>
36 #include <sys/kmem.h>
37 #include <sys/proc.h>
38 #include <sys/cred.h>
39 #include <sys/cmn_err.h>
40 #include <sys/debug.h>
41 #include <vm/pvn.h>
42 #include <sys/fs/pc_label.h>
43 #include <sys/fs/pc_fs.h>
44 #include <sys/fs/pc_dir.h>
45 #include <sys/fs/pc_node.h>
46 #include <sys/dirent.h>
47 #include <sys/fdio.h>
123 } else {
124 hp = &pcfhead[PCFHASH(fsp, blkno, offset)];
125 rw_enter(&pcnodes_lock, RW_READER);
126 for (pcp = hp->pch_forw;
127 pcp != (struct pcnode *)hp; pcp = pcp->pc_forw) {
128 if ((fsp == VFSTOPCFS(PCTOV(pcp)->v_vfsp)) &&
129 ((pcp->pc_flags & PC_INVAL) == 0) &&
130 (blkno == pcp->pc_eblkno) &&
131 (offset == pcp->pc_eoffset)) {
132 VN_HOLD(PCTOV(pcp));
133 rw_exit(&pcnodes_lock);
134 return (pcp);
135 }
136 }
137 rw_exit(&pcnodes_lock);
138 }
139 /*
140 * Cannot find node in active list. Allocate memory for a new node
141 * initialize it, and put it on the active list.
142 */
143 pcp = kmem_alloc(sizeof (struct pcnode), KM_SLEEP);
144 bzero(pcp, sizeof (struct pcnode));
145 vp = vn_alloc(KM_SLEEP);
146 pcp->pc_vn = vp;
147 pcp->pc_entry = *ep;
148 pcp->pc_eblkno = blkno;
149 pcp->pc_eoffset = offset;
150 pcp->pc_scluster = scluster;
151 pcp->pc_lcluster = scluster;
152 pcp->pc_lindex = 0;
153 pcp->pc_flags = 0;
154 if (ep->pcd_attr & PCA_DIR) {
155 vn_setops(vp, pcfs_dvnodeops);
156 vp->v_type = VDIR;
157 if (scluster == 0) {
158 vp->v_flag = VROOT;
159 blkno = offset = 0;
160 if (IS_FAT32(fsp)) {
161 pc_cluster32_t ncl = 0;
162
163 scluster = fsp->pcfs_rdirstart;
164 if (pc_fileclsize(fsp, scluster, &ncl)) {
|
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 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/param.h>
27 #include <sys/t_lock.h>
28 #include <sys/errno.h>
29 #include <sys/sysmacros.h>
30 #include <sys/buf.h>
31 #include <sys/systm.h>
32 #include <sys/vfs.h>
33 #include <sys/vnode.h>
34 #include <sys/kmem.h>
35 #include <sys/proc.h>
36 #include <sys/cred.h>
37 #include <sys/cmn_err.h>
38 #include <sys/debug.h>
39 #include <vm/pvn.h>
40 #include <sys/fs/pc_label.h>
41 #include <sys/fs/pc_fs.h>
42 #include <sys/fs/pc_dir.h>
43 #include <sys/fs/pc_node.h>
44 #include <sys/dirent.h>
45 #include <sys/fdio.h>
121 } else {
122 hp = &pcfhead[PCFHASH(fsp, blkno, offset)];
123 rw_enter(&pcnodes_lock, RW_READER);
124 for (pcp = hp->pch_forw;
125 pcp != (struct pcnode *)hp; pcp = pcp->pc_forw) {
126 if ((fsp == VFSTOPCFS(PCTOV(pcp)->v_vfsp)) &&
127 ((pcp->pc_flags & PC_INVAL) == 0) &&
128 (blkno == pcp->pc_eblkno) &&
129 (offset == pcp->pc_eoffset)) {
130 VN_HOLD(PCTOV(pcp));
131 rw_exit(&pcnodes_lock);
132 return (pcp);
133 }
134 }
135 rw_exit(&pcnodes_lock);
136 }
137 /*
138 * Cannot find node in active list. Allocate memory for a new node
139 * initialize it, and put it on the active list.
140 */
141 pcp = kmem_zalloc(sizeof (struct pcnode), KM_SLEEP);
142 vp = vn_alloc(KM_SLEEP);
143 pcp->pc_vn = vp;
144 pcp->pc_entry = *ep;
145 pcp->pc_eblkno = blkno;
146 pcp->pc_eoffset = offset;
147 pcp->pc_scluster = scluster;
148 pcp->pc_lcluster = scluster;
149 pcp->pc_lindex = 0;
150 pcp->pc_flags = 0;
151 if (ep->pcd_attr & PCA_DIR) {
152 vn_setops(vp, pcfs_dvnodeops);
153 vp->v_type = VDIR;
154 if (scluster == 0) {
155 vp->v_flag = VROOT;
156 blkno = offset = 0;
157 if (IS_FAT32(fsp)) {
158 pc_cluster32_t ncl = 0;
159
160 scluster = fsp->pcfs_rdirstart;
161 if (pc_fileclsize(fsp, scluster, &ncl)) {
|