Lines Matching full:cn
86 usemap_alloc(struct msdosfsmount *pmp, u_long cn);
88 usemap_free(struct msdosfsmount *pmp, u_long cn);
136 u_long cn; in pcbmap() local
148 cn = dep->de_StartCluster; in pcbmap()
155 if (cn == MSDOSFSROOT) { in pcbmap()
189 fc_lookup(dep, findcn, &i, &cn); in pcbmap()
198 if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD) in pcbmap()
200 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
270 cn = dep->de_fc[i].fc_frcn; in fc_lookup()
271 if (cn != FCE_EMPTY && cn <= findcn) { in fc_lookup()
272 if (closest == NULL || cn > closest->fc_frcn) in fc_lookup()
382 usemap_alloc(struct msdosfsmount *pmp, u_long cn) in usemap_alloc() argument
385 assert(cn <= pmp->pm_maxcluster); in usemap_alloc()
387 assert((pmp->pm_inusemap[cn / N_INUSEBITS] & (1 << (cn % N_INUSEBITS))) in usemap_alloc()
391 pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS); in usemap_alloc()
397 usemap_free(struct msdosfsmount *pmp, u_long cn) in usemap_free() argument
400 assert(cn <= pmp->pm_maxcluster); in usemap_free()
402 assert((pmp->pm_inusemap[cn / N_INUSEBITS] & (1 << (cn % N_INUSEBITS))) in usemap_free()
407 pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1U << (cn % N_INUSEBITS)); in usemap_free()
433 * cn - which cluster is of interest
447 fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents, in fatentry() argument
457 function, pmp, cn, oldcontents, newcontents); in fatentry()
486 if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) in fatentry()
489 byteoffset = FATOFS(pmp, cn); in fatentry()
502 if (FAT12(pmp) & (cn & 1)) in fatentry()
514 if (cn & 1) { in fatentry()
738 u_long len, newst, foundl, cn, l; in clusteralloc1() local
753 for (cn = newst; cn <= pmp->pm_maxcluster;) { in clusteralloc1()
754 idx = cn / N_INUSEBITS; in clusteralloc1()
756 map |= (1U << (cn % N_INUSEBITS)) - 1; in clusteralloc1()
758 cn = idx * N_INUSEBITS + ffs(map ^ FULL_RUN) - 1; in clusteralloc1()
759 if ((l = chainlength(pmp, cn, count)) >= count) in clusteralloc1()
760 return (chainalloc(pmp, cn, count, fillwith, retcluster, got)); in clusteralloc1()
762 foundcn = cn; in clusteralloc1()
765 cn += l + 1; in clusteralloc1()
768 cn += N_INUSEBITS - cn % N_INUSEBITS; in clusteralloc1()
770 for (cn = 0; cn < newst;) { in clusteralloc1()
771 idx = cn / N_INUSEBITS; in clusteralloc1()
773 map |= (1U << (cn % N_INUSEBITS)) - 1; in clusteralloc1()
775 cn = idx * N_INUSEBITS + ffs(map ^ FULL_RUN) - 1; in clusteralloc1()
776 if ((l = chainlength(pmp, cn, count)) >= count) in clusteralloc1()
777 return (chainalloc(pmp, cn, count, fillwith, retcluster, got)); in clusteralloc1()
779 foundcn = cn; in clusteralloc1()
782 cn += l + 1; in clusteralloc1()
785 cn += N_INUSEBITS - cn % N_INUSEBITS; in clusteralloc1()
870 u_long bn, bo, bsize, byteoffset, cn, readcn; in fillinusemap() local
879 for (cn = 0; cn < (pmp->pm_maxcluster + N_INUSEBITS) / N_INUSEBITS; cn++) in fillinusemap()
880 pmp->pm_inusemap[cn] = FULL_RUN; in fillinusemap()
888 for (cn = 0; cn <= pmp->pm_maxcluster; cn++) { in fillinusemap()
889 byteoffset = FATOFS(pmp, cn); in fillinusemap()
905 if (FAT12(pmp) && (cn & 1)) in fillinusemap()
913 if (cn == 0 && readcn != ((pmp->pm_fatmask & 0xffffff00) | in fillinusemap()
922 usemap_free(pmp, cn); in fillinusemap()
927 for (cn = pmp->pm_maxcluster + 1; cn < (pmp->pm_maxcluster + in fillinusemap()
928 N_INUSEBITS) / N_INUSEBITS; cn++) in fillinusemap()
929 pmp->pm_inusemap[cn / N_INUSEBITS] |= 1U << (cn % N_INUSEBITS); in fillinusemap()
955 u_long cn, got; in m_extendfile() local
976 error = pcbmap(dep, 0xffff, 0, &cn, 0); in m_extendfile()
997 cn = 0; in m_extendfile()
999 cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1; in m_extendfile()
1000 error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got); in m_extendfile()
1011 *ncp = cn; in m_extendfile()
1016 dep->de_StartCluster = cn; in m_extendfile()
1021 0, cn); in m_extendfile()
1023 clusterfree(pmp, cn); in m_extendfile()
1033 fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1); in m_extendfile()
1039 cntobn(pmp, cn++), in m_extendfile()