Lines Matching defs:cn

81 		usemap_alloc(struct msdosfsmount *pmp, u_long cn);
82 static int usemap_free(struct msdosfsmount *pmp, u_long cn);
136 u_long cn;
150 cn = dep->de_StartCluster;
157 if (cn == MSDOSFSROOT) {
191 fc_lookup(dep, findcn, &i, &cn);
200 if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD)
202 byteoffset = FATOFS(pmp, cn);
213 prevcn = cn;
220 cn = getulong(bp->b_data + bo);
222 cn = getushort(bp->b_data + bo);
224 cn >>= 4;
225 cn &= pmp->pm_fatmask;
233 if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD)
234 cn |= ~pmp->pm_fatmask;
237 if (!MSDOSFSEOF(pmp, cn)) {
241 *bnp = cntobn(pmp, cn);
243 *cnp = cn;
244 fc_setcache(dep, FC_LASTMAP, i, cn);
266 u_long cn;
272 cn = dep->de_fc[i].fc_frcn;
273 if (cn != FCE_EMPTY && cn <= findcn) {
274 if (closest == NULL || cn > closest->fc_frcn)
386 usemap_alloc(struct msdosfsmount *pmp, u_long cn)
391 KASSERT(cn <= pmp->pm_maxcluster, ("cn too large %lu %lu", cn,
395 KASSERT((pmp->pm_inusemap[cn / N_INUSEBITS] &
396 (1U << (cn % N_INUSEBITS))) == 0,
397 ("Allocating used sector %ld %ld %x", cn, cn % N_INUSEBITS,
398 (unsigned)pmp->pm_inusemap[cn / N_INUSEBITS]));
399 pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS);
406 usemap_free(struct msdosfsmount *pmp, u_long cn)
411 KASSERT(cn <= pmp->pm_maxcluster, ("cn too large %lu %lu", cn,
415 if ((pmp->pm_inusemap[cn / N_INUSEBITS] &
416 (1U << (cn % N_INUSEBITS))) == 0) {
418 pmp->pm_mountp->mnt_stat.f_mntonname, cn, cn % N_INUSEBITS,
419 (unsigned)pmp->pm_inusemap[cn / N_INUSEBITS]);
425 pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS));
454 * cn - which cluster is of interest
468 fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents,
478 function, pmp, cn, oldcontents, newcontents);
507 if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster)
510 byteoffset = FATOFS(pmp, cn);
522 if (FAT12(pmp) & (cn & 1))
534 if (cn & 1) {
763 u_long len, newst, foundl, cn, l;
781 for (cn = newst; cn <= pmp->pm_maxcluster;) {
782 idx = cn / N_INUSEBITS;
784 map |= (1U << (cn % N_INUSEBITS)) - 1;
786 cn = idx * N_INUSEBITS + ffs(map ^ FULL_RUN) - 1;
787 if ((l = chainlength(pmp, cn, count)) >= count)
788 return (chainalloc(pmp, cn, count, fillwith, retcluster, got));
790 foundcn = cn;
793 cn += l + 1;
796 cn += N_INUSEBITS - cn % N_INUSEBITS;
798 for (cn = 0; cn < newst;) {
799 idx = cn / N_INUSEBITS;
801 map |= (1U << (cn % N_INUSEBITS)) - 1;
803 cn = idx * N_INUSEBITS + ffs(map ^ FULL_RUN) - 1;
804 if ((l = chainlength(pmp, cn, count)) >= count)
805 return (chainalloc(pmp, cn, count, fillwith, retcluster, got));
807 foundcn = cn;
810 cn += l + 1;
813 cn += N_INUSEBITS - cn % N_INUSEBITS;
903 u_long bn, bo, bsize, byteoffset, cn, readcn;
913 for (cn = 0; cn < (pmp->pm_maxcluster + N_INUSEBITS) / N_INUSEBITS; cn++)
914 pmp->pm_inusemap[cn] = FULL_RUN;
922 for (cn = 0; cn <= pmp->pm_maxcluster; cn++) {
923 byteoffset = FATOFS(pmp, cn);
938 if (FAT12(pmp) && (cn & 1))
946 if (cn == 0 && readcn != ((pmp->pm_fatmask & 0xffffff00) |
955 error = usemap_free(pmp, cn);
965 for (cn = pmp->pm_maxcluster + 1; cn < (pmp->pm_maxcluster +
966 N_INUSEBITS) / N_INUSEBITS; cn++)
967 pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS);
993 u_long cn, got;
1015 error = pcbmap(dep, 0xffff, 0, &cn, 0);
1036 cn = 0;
1038 cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1;
1039 error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got);
1050 *ncp = cn;
1055 dep->de_StartCluster = cn;
1060 0, cn);
1062 clusterfree(pmp, cn);
1072 fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
1081 cntobn(pmp, cn++),