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