Lines Matching refs:cn

190 	u_long cn;
209 cn = dep->de_StartCluster;
210 DPRINTF(("%s(start cluster=%lu)\n", __func__, cn));
217 if (cn == MSDOSFSROOT) {
233 DPRINTF(("%s(root, bn=%lu, cn=%u)\n", __func__,
257 msdosfs_fc_lookup(dep, findcn, &i, &cn);
258 DPRINTF(("%s(bpcluster=%lu i=%lu cn=%lu\n", __func__, pmp->pm_bpcluster,
259 i, cn));
275 if (cn >= (CLUST_RSRVD & pmp->pm_fatmask))
281 if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) {
282 DPRINTF(("%s(cn, %lu not in %lu..%lu)\n", __func__,
283 cn, (u_long)CLUST_FIRST, pmp->pm_maxcluster));
289 byteoffset = FATOFS(pmp, cn);
302 prevcn = cn;
312 cn = getulong((char *)bp->b_data + bo);
314 cn = getushort((char *)bp->b_data + bo);
316 cn >>= 4;
317 DPRINTF(("%s(cn=%lu masked=%lu)\n", __func__, cn,
318 cn & pmp->pm_fatmask));
319 cn &= pmp->pm_fatmask;
322 if (!MSDOSFSEOF(cn, pmp->pm_fatmask)) {
326 *bnp = cntobn(pmp, cn);
328 *cnp = cn;
329 DPRINTF(("%s(bn=%lu, cn=%lu)\n", __func__, cntobn(pmp, cn),
330 cn));
331 fc_setcache(dep, FC_LASTMAP, i, cn);
355 u_long cn;
359 cn = dep->de_fc[i].fc_frcn;
360 if (cn != FCE_EMPTY && cn <= findcn) {
361 if (closest == 0 || cn > closest->fc_frcn)
409 u_long cn = pmp->pm_nxtfree;
412 && (pmp->pm_inusemap[cn / N_INUSEBITS]
413 & (1U << (cn % N_INUSEBITS)))) {
418 for (cn = 0; cn < pmp->pm_maxcluster; cn++)
419 if (pmp->pm_inusemap[cn / N_INUSEBITS] != (u_int)-1)
421 pmp->pm_nxtfree = cn
422 + ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
510 usemap_alloc(struct msdosfsmount *pmp, u_long cn)
513 pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS);
518 usemap_free(struct msdosfsmount *pmp, u_long cn)
522 pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS));
554 * cn - which cluster is of interest
568 msdosfs_fatentry(int function, struct msdosfsmount *pmp, u_long cn,
577 __func__, function, pmp, cn, oldcontents, newcontents));
603 if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster)
606 byteoffset = FATOFS(pmp, cn);
618 if (FAT12(pmp) & (cn & 1))
627 if (cn & 1) {
814 u_long len, newst, foundl, cn, l;
841 for (cn = newst; cn <= pmp->pm_maxcluster;) {
842 idx = cn / N_INUSEBITS;
844 map |= (1U << (cn % N_INUSEBITS)) - 1;
846 cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1;
847 if ((l = chainlength(pmp, cn, count)) >= count)
848 return (chainalloc(pmp, cn, count, fillwith, retcluster, got));
850 foundcn = cn;
853 cn += l + 1;
856 cn += N_INUSEBITS - cn % N_INUSEBITS;
858 for (cn = 0; cn < newst;) {
859 idx = cn / N_INUSEBITS;
861 map |= (1U << (cn % N_INUSEBITS)) - 1;
863 cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1;
864 if ((l = chainlength(pmp, cn, count)) >= count)
865 return (chainalloc(pmp, cn, count, fillwith, retcluster, got));
867 foundcn = cn;
870 cn += l + 1;
873 cn += N_INUSEBITS - cn % N_INUSEBITS;
957 u_long cn, readcn;
965 for (cn = 0; cn < (pmp->pm_maxcluster + N_INUSEBITS) / N_INUSEBITS; cn++)
966 pmp->pm_inusemap[cn] = (u_int)-1;
974 for (cn = CLUST_FIRST; cn <= pmp->pm_maxcluster; cn++) {
975 byteoffset = FATOFS(pmp, cn);
992 if (FAT12(pmp) && (cn & 1))
997 usemap_free(pmp, cn);
1025 u_long frcn = 0, cn, got;
1046 error = msdosfs_pcbmap(dep, CLUST_END, 0, &cn, 0);
1067 cn = 0;
1069 cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1;
1070 error = msdosfs_clusteralloc(pmp, cn, count, &cn, &got);
1081 *ncp = cn;
1086 dep->de_StartCluster = cn;
1091 0, cn);
1093 msdosfs_clusterfree(pmp, cn, NULL);
1104 fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
1109 de_bn2kb(pmp, cntobn(pmp, cn++)),