Lines Matching defs:fat

36 __RCSID("$NetBSD: fat.c,v 1.12 2000/10/10 20:24:52 is Exp $");
38 "$FreeBSD: src/sbin/fsck_msdosfs/fat.c,v 1.9 2008/01/31 13:22:13 yar Exp $";
138 checkclnum(struct bootblock *boot, int fat, cl_t cl, cl_t *next)
153 cl, fat,
209 struct fatEntry *fat;
219 fat = calloc(boot->NumClusters, sizeof(struct fatEntry));
220 if (fat == NULL) {
289 fat[cl].next = p[0] + (p[1] << 8)
291 fat[cl].next &= boot->ClustMask;
292 ret |= checkclnum(boot, no, cl, &fat[cl].next);
297 fat[cl].next = p[0] + (p[1] << 8);
298 ret |= checkclnum(boot, no, cl, &fat[cl].next);
303 fat[cl].next = (p[0] + (p[1] << 8)) & 0x0fff;
304 ret |= checkclnum(boot, no, cl, &fat[cl].next);
308 fat[cl].next = ((p[1] >> 4) + (p[2] << 4)) & 0x0fff;
309 ret |= checkclnum(boot, no, cl, &fat[cl].next);
317 *fp = fat;
420 clearchain(struct bootblock *boot, struct fatEntry *fat, cl_t head)
425 if (fat[p].head != head)
427 q = fat[p].next;
428 fat[p].next = fat[p].head = CLUST_FREE;
429 fat[p].length = 0;
434 tryclear(struct bootblock *boot, struct fatEntry *fat, cl_t head, cl_t *trunc)
437 clearchain(boot, fat, head);
450 checkfat(struct bootblock *boot, struct fatEntry *fat)
462 if (fat[head].head != 0 /* cluster already belongs to some chain */
463 || fat[head].next == CLUST_FREE
464 || fat[head].next == CLUST_BAD)
470 p = fat[p].next) {
477 fat[p].head = head;
482 fat[head].length = fat[head].next == CLUST_FREE ? 0 : len;
492 if (fat[head].head != head)
498 (n = fat[p].next) >= CLUST_FIRST && n < boot->NumClusters && wdk;
500 if (fat[n].head != head)
510 ret |= tryclear(boot, fat, head, &fat[p].next);
516 ret |= tryclear(boot, fat, head, &fat[p].next);
520 head, fat[n].head, n);
521 conf = tryclear(boot, fat, head, &fat[p].next);
522 if (ask(1, "Clear chain starting at %u", h = fat[n].head)) {
529 p = fat[p].next) {
530 if (h != fat[p].head) {
537 fat[p].head = head;
540 clearchain(boot, fat, h);
553 writefat(int fs, struct bootblock *boot, struct fatEntry *fat, int correct_fat)
617 if (fat[cl].next == CLUST_FREE)
619 *p++ = (u_char)fat[cl].next;
620 *p++ = (u_char)(fat[cl].next >> 8);
621 *p++ = (u_char)(fat[cl].next >> 16);
623 *p++ |= (fat[cl].next >> 24)&0x0f;
626 if (fat[cl].next == CLUST_FREE)
628 *p++ = (u_char)fat[cl].next;
629 *p++ = (u_char)(fat[cl].next >> 8);
632 if (fat[cl].next == CLUST_FREE)
635 && fat[cl + 1].next == CLUST_FREE)
637 *p++ = (u_char)fat[cl].next;
638 *p++ = (u_char)((fat[cl].next >> 8) & 0xf)
639 |(u_char)(fat[cl+1].next << 4);
640 *p++ = (u_char)(fat[++cl].next >> 4);
661 checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat)
669 if (fat[head].head != head
670 || fat[head].next == CLUST_FREE
671 || (fat[head].next >= CLUST_RSRVD
672 && fat[head].next < CLUST_EOFS)
673 || (fat[head].flags & FAT_USED))
677 head, fat[head].length);
678 mod |= ret = reconnect(dosfs, boot, fat, head);
683 clearchain(boot, fat, head);
688 clearchain(boot, fat, head);
706 if ((boot->FSNext >= boot->NumClusters) || (fat[boot->FSNext].next != CLUST_FREE)) {
711 if (fat[head].next == CLUST_FREE) {
725 if (boot->NumFree && fat[boot->FSNext].next != CLUST_FREE) {
730 if (fat[head].next == CLUST_FREE) {