Lines Matching refs:cn
44 static pc_cluster32_t pc_getcluster(struct pcfs *fsp, pc_cluster32_t cn);
61 pc_cluster32_t cn, ncn; /* current, next cluster number */
112 cn = ncn;
113 if (!pc_validcl(fsp, cn)) {
114 if (IS_FAT32(fsp) && cn >= PCF_LASTCLUSTER32 &&
119 cn >= PCF_LASTCLUSTER &&
125 "pc_bmap: badfs cn=%d\n", cn);
130 ncn = pc_getcluster(fsp, cn);
139 pcp->pc_lcluster = cn;
140 *dbnp = pc_cldaddr(fsp, cn);
145 while ((cn + 1) == ncn && count < *contigbp &&
148 cn = ncn;
169 pc_cluster32_t cn; /* current cluster number */
196 switch (cn = pc_alloccluster(fsp, 1)) {
202 pcp->pc_scluster = cn;
204 cn = pcp->pc_scluster;
205 if (IS_FAT32(fsp) && cn == 0)
206 cn = fsp->pcfs_rdirstart;
207 if (!pc_validcl(fsp, cn)) {
208 PC_DPRINTF1(1, "pc_balloc: badfs cn=%d\n", cn);
216 cn = pcp->pc_lcluster;
219 ncn = pc_getcluster(fsp, cn);
231 pc_setcluster(fsp, cn, ncn);
238 cn = ncn;
245 *dbnp = pc_cldaddr(fsp, cn);
257 pc_cluster32_t cn;
281 cn = pcp->pc_scluster;
282 if (IS_FAT32(fsp) && cn == 0)
283 cn = fsp->pcfs_rdirstart;
296 if (!pc_validcl(fsp, cn)) {
297 PC_DPRINTF1(1, "pc_bfree: badfs cn=%d\n", cn);
301 ncn = pc_getcluster(fsp, cn);
303 pc_setcluster(fsp, cn, PCF_FREECLUSTER);
308 pc_setcluster(fsp, cn,
311 pc_setcluster(fsp, cn,
321 cn = ncn;
332 pc_cluster32_t cn;
342 for (cn = PCF_FIRSTCLUSTER; pc_validcl(fsp, cn); cn++) {
343 if (pc_getcluster(fsp, cn) == PCF_FREECLUSTER) {
362 * cn = current cluster number in chain
365 pc_getcluster(struct pcfs *fsp, pc_cluster32_t cn)
369 if (fsp->pcfs_fatp == (uchar_t *)0 || !pc_validcl(fsp, cn))
374 fp = fsp->pcfs_fatp + (cn << 2);
375 cn = ltohi(*(pc_cluster32_t *)fp);
378 fp = fsp->pcfs_fatp + (cn << 1);
379 cn = ltohs(*(pc_cluster16_t *)fp);
382 fp = fsp->pcfs_fatp + (cn + (cn >> 1));
383 if (cn & 01) {
384 cn = (((unsigned int)*fp++ & 0xf0) >> 4);
385 cn += (*fp << 4);
387 cn = *fp++;
388 cn += ((*fp & 0x0f) << 8);
390 if (cn >= PCF_12BCLUSTER)
391 cn |= PCF_RESCLUSTER;
395 cn = PCF_ERRORCLUSTER;
397 return (cn);
402 * cn = cluster number to be set in FAT
406 pc_setcluster(struct pcfs *fsp, pc_cluster32_t cn, pc_cluster32_t ncn)
411 if (fsp->pcfs_fatp == (uchar_t *)0 || !pc_validcl(fsp, cn))
414 pc_mark_fat_updated(fsp, cn);
417 fp = fsp->pcfs_fatp + (cn << 2);
421 fp = fsp->pcfs_fatp + (cn << 1);
426 fp = fsp->pcfs_fatp + (cn + (cn >> 1));
427 if (cn & 01) {
457 pc_cluster32_t cn;
463 for (cn = fsp->pcfs_nxfrecls; pc_validcl(fsp, cn); cn++) {
464 if (pc_getcluster(fsp, cn) == PCF_FREECLUSTER) {
468 pc_setcluster(fsp, cn, PCF_LASTCLUSTERMARK32);
473 pc_setcluster(fsp, cn, PCF_LASTCLUSTERMARK);
481 bp->b_blkno = pc_cldaddr(fsp, cn);
491 fsp->pcfs_nxfrecls = cn + 1;
492 return (cn);