Lines Matching refs:clst

1116 	DWORD clst		/* Cluster# to be converted */  in clst2sect()  argument
1119 clst -= 2; /* Cluster number is origin from 2 */ in clst2sect()
1120 if (clst >= fs->n_fatent - 2) return 0; /* Is it invalid cluster number? */ in clst2sect()
1121 return fs->database + (LBA_t)fs->csize * clst; /* Start sector number of the cluster */ in clst2sect()
1133 DWORD clst /* Cluster number to get the value */ in get_fat() argument
1141 if (clst < 2 || clst >= fs->n_fatent) { /* Check if in valid range */ in get_fat()
1149 bc = (UINT)clst; bc += bc / 2; in get_fat()
1154 val = (clst & 1) ? (wc >> 4) : (wc & 0xFFF); /* Adjust bit position */ in get_fat()
1158 if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))) != FR_OK) break; in get_fat()
1159 val = ld_word(fs->win + clst * 2 % SS(fs)); /* Simple WORD array */ in get_fat()
1163 if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; in get_fat()
1164 …val = ld_dword(fs->win + clst * 4 % SS(fs)) & 0x0FFFFFFF; /* Simple DWORD array but mask out upper… in get_fat()
1169 DWORD cofs = clst - obj->sclust; /* Offset from start cluster */ in get_fat()
1173 val = (cofs == clen) ? 0x7FFFFFFF : clst + 1; /* No data on the FAT, generate the value */ in get_fat()
1177 val = clst + 1; /* Generate the value */ in get_fat()
1184 if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))) != FR_OK) break; in get_fat()
1185 val = ld_dword(fs->win + clst * 4 % SS(fs)) & 0x7FFFFFFF; in get_fat()
1211 DWORD clst, /* FAT index number (cluster number) to be changed */ in put_fat() argument
1220 if (clst >= 2 && clst < fs->n_fatent) { /* Check if in valid range */ in put_fat()
1223 bc = (UINT)clst; bc += bc / 2; /* bc: byte offset of the entry */ in put_fat()
1227 *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; /* Update 1st byte */ in put_fat()
1232 …*p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); /* Update 2nd byte… in put_fat()
1237 res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); in put_fat()
1239 st_word(fs->win + clst * 2 % SS(fs), (WORD)val); /* Simple WORD array */ in put_fat()
1247 res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); in put_fat()
1250 val = (val & 0x0FFFFFFF) | (ld_dword(fs->win + clst * 4 % SS(fs)) & 0xF0000000); in put_fat()
1252 st_dword(fs->win + clst * 4 % SS(fs), val); in put_fat()
1276 DWORD clst, /* Cluster number to scan from */ in find_bitmap() argument
1285 clst -= 2; /* The first bit in the bitmap corresponds to cluster #2 */ in find_bitmap()
1286 if (clst >= fs->n_fatent - 2) clst = 0; in find_bitmap()
1287 scl = val = clst; ctr = 0; in find_bitmap()
1302 if (val == clst) return 0; /* All cluster scanned? */ in find_bitmap()
1316 DWORD clst, /* Cluster number to change from */ in change_bitmap() argument
1326 clst -= 2; /* The first bit corresponds to cluster #2 */ in change_bitmap()
1327 sect = fs->bitbase + clst / 8 / SS(fs); /* Sector address */ in change_bitmap()
1328 i = clst / 8 % SS(fs); /* Byte offset in the sector */ in change_bitmap()
1329 bm = 1 << (clst % 8); /* Bit mask in the byte */ in change_bitmap()
1401 DWORD clst, /* Cluster to remove a chain from */ in remove_chain() argument
1409 DWORD scl = clst, ecl = clst; in remove_chain()
1415 if (clst < 2 || clst >= fs->n_fatent) return FR_INT_ERR; /* Check if in valid range */ in remove_chain()
1425 nxt = get_fat(obj, clst); /* Get cluster status */ in remove_chain()
1430 res = put_fat(fs, clst, 0); /* Mark the cluster 'free' on the FAT */ in remove_chain()
1455 clst = nxt; /* Next cluster */ in remove_chain()
1456 } while (clst < fs->n_fatent); /* Repeat while not the last link */ in remove_chain()
1465 clst = obj->sclust; /* Follow the chain to check if it gets contiguous */ in remove_chain()
1466 while (clst != pclst) { in remove_chain()
1467 nxt = get_fat(obj, clst); in remove_chain()
1470 if (nxt != clst + 1) break; /* Not contiguous? */ in remove_chain()
1471 clst++; in remove_chain()
1473 if (clst == pclst) { /* Has the chain got contiguous again? */ in remove_chain()
1496 DWORD clst /* Cluster# to stretch, 0:Create a new chain */ in create_chain() argument
1504 if (clst == 0) { /* Create a new chain */ in create_chain()
1509 cs = get_fat(obj, clst); /* Check the cluster status */ in create_chain()
1513 scl = clst; /* Cluster to start to find */ in create_chain()
1524 if (clst == 0) { /* Is it a new chain? */ in create_chain()
1533 if (ncl == clst + 1) { /* Is the cluster next to previous one? */ in create_chain()
1537 res = fill_last_frag(obj, clst, ncl); /* Fill last fragment on the FAT and link it to new one */ in create_chain()
1545 if (scl == clst) { /* Stretching an existing chain? */ in create_chain()
1571 if (res == FR_OK && clst != 0) { in create_chain()
1572 res = put_fat(fs, clst, ncl); /* Link it from the previous one if needed */ in create_chain()
1629 DWORD clst /* Directory table to clear */ in dir_clear() argument
1638 sect = clst2sect(fs, clst); /* Top of the cluster */ in dir_clear()
1671 DWORD csz, clst; in dir_sdi() local
1679 clst = dp->obj.sclust; /* Table start cluster (0:root) */ in dir_sdi()
1680 if (clst == 0 && fs->fs_type >= FS_FAT32) { /* Replace cluster# 0 with root cluster# */ in dir_sdi()
1681 clst = (DWORD)fs->dirbase; in dir_sdi()
1685 if (clst == 0) { /* Static table (root-directory on the FAT volume) */ in dir_sdi()
1692 clst = get_fat(&dp->obj, clst); /* Get next cluster */ in dir_sdi()
1693 if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ in dir_sdi()
1694 …if (clst < 2 || clst >= fs->n_fatent) return FR_INT_ERR; /* Reached to end of table or internal er… in dir_sdi()
1697 dp->sect = clst2sect(fs, clst); in dir_sdi()
1699 dp->clust = clst; /* Current cluster# */ in dir_sdi()
1719 DWORD ofs, clst; in dir_next() local
1737 clst = get_fat(&dp->obj, dp->clust); /* Get next cluster */ in dir_next()
1738 if (clst <= 1) return FR_INT_ERR; /* Internal error */ in dir_next()
1739 if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ in dir_next()
1740 if (clst >= fs->n_fatent) { /* It reached end of dynamic table */ in dir_next()
1745 clst = create_chain(&dp->obj, dp->clust); /* Allocate a cluster */ in dir_next()
1746 if (clst == 0) return FR_DENIED; /* No free cluster */ in dir_next()
1747 if (clst == 1) return FR_INT_ERR; /* Internal error */ in dir_next()
1748 if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ in dir_next()
1749 if (dir_clear(fs, clst) != FR_OK) return FR_DISK_ERR; /* Clean up the stretched table */ in dir_next()
1756 dp->clust = clst; /* Initialize data for new cluster */ in dir_next()
1757 dp->sect = clst2sect(fs, clst); in dir_next()
3663 DWORD cl, bcs, clst, tm; local
3810 clst = fp->obj.sclust; /* Follow the cluster chain */
3812 clst = get_fat(&fp->obj, clst);
3813 if (clst <= 1) res = FR_INT_ERR;
3814 if (clst == 0xFFFFFFFF) res = FR_DISK_ERR;
3816 fp->clust = clst;
3818 sc = clst2sect(fs, clst);
3859 DWORD clst; local
3878 clst = fp->obj.sclust; /* Follow cluster chain from the origin */
3882 clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */
3886 clst = get_fat(&fp->obj, fp->clust); /* Follow cluster chain on the FAT */
3889 if (clst < 2) ABORT(fs, FR_INT_ERR);
3890 if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
3891 fp->clust = clst; /* Update current cluster */
3959 DWORD clst; local
3980 clst = fp->obj.sclust; /* Follow from the origin */
3981 if (clst == 0) { /* If no cluster is allocated, */
3982 clst = create_chain(&fp->obj, 0); /* create a new cluster chain */
3987 clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */
3991 clst = create_chain(&fp->obj, fp->clust); /* Follow or stretch cluster chain on the FAT */
3994 if (clst == 0) break; /* Could not allocate a new cluster (disk full) */
3995 if (clst == 1) ABORT(fs, FR_INT_ERR);
3996 if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
3997 fp->clust = clst; /* Update current cluster */
3998 if (fp->obj.sclust == 0) fp->obj.sclust = clst; /* Set start cluster if the first write */
4374 DWORD clst, bcs; local
4460 clst = fp->clust;
4462 clst = fp->obj.sclust; /* start from the first cluster */
4464 if (clst == 0) { /* If no cluster chain, create a new chain */
4465 clst = create_chain(&fp->obj, 0);
4466 if (clst == 1) ABORT(fs, FR_INT_ERR);
4467 if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
4468 fp->obj.sclust = clst;
4471 fp->clust = clst;
4473 if (clst != 0) {
4482 clst = create_chain(&fp->obj, clst); /* Follow chain with forceed stretch */
4483 if (clst == 0) { /* Clip file size in case of disk full */
4489 clst = get_fat(&fp->obj, clst); /* Follow cluster chain if not in write mode */
4491 if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
4492 if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR);
4493 fp->clust = clst;
4497 nsect = clst2sect(fs, clst); /* Current sector */
4758 DWORD nfree, clst, stat; local
4775 clst = 2; obj.fs = fs;
4777 stat = get_fat(&obj, clst);
4781 } while (++clst < fs->n_fatent);
4788 clst = fs->n_fatent - 2; /* Number of clusters */
4796 for (b = 8, bm = fs->win[i]; b && clst; b--, clst--) {
4801 } while (clst);
4805 clst = fs->n_fatent; /* Number of entries */
4821 } while (--clst);
5499 DWORD n, clst, stcl, scl, ncl, tcl, lclst; local
5529 scl = clst = stcl; ncl = 0;
5531 n = get_fat(&fp->obj, clst);
5532 if (++clst >= fs->n_fatent) clst = 2;
5538 scl = clst; ncl = 0; /* Not a free cluster */
5540 if (clst == stcl) { res = FR_DENIED; break; } /* No contiguous cluster? */
5544 for (clst = scl, n = tcl; n; clst++, n--) { /* Create a cluster chain on the FAT */
5545 res = put_fat(fs, clst, (n == 1) ? 0xFFFFFFFF : clst + 1);
5547 lclst = clst;
5590 DWORD clst; local
5609 clst = (fp->fptr == 0) ? /* On the top of the file? */
5611 if (clst <= 1) ABORT(fs, FR_INT_ERR);
5612 if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);
5613 fp->clust = clst; /* Update current cluster */