Lines Matching refs:fat

29 __RCSID("$NetBSD: fat.c,v 1.12 2000/10/10 20:24:52 is Exp $");
132 checkclnum(struct bootblock *boot, u_int fat, cl_t cl, cl_t *next)
147 cl, fat,
200 struct fatEntry *fat;
211 fat = malloc(len = boot->NumClusters * sizeof(struct fatEntry));
212 if (fat == NULL) {
217 (void)memset(fat, 0, len);
282 fat[cl].next = p[0] + (p[1] << 8)
284 fat[cl].next &= boot->ClustMask;
285 ret |= checkclnum(boot, no, cl, &fat[cl].next);
290 fat[cl].next = p[0] + (p[1] << 8);
291 ret |= checkclnum(boot, no, cl, &fat[cl].next);
296 fat[cl].next = (p[0] + (p[1] << 8)) & 0x0fff;
297 ret |= checkclnum(boot, no, cl, &fat[cl].next);
301 fat[cl].next = ((p[1] >> 4) + (p[2] << 4)) & 0x0fff;
302 ret |= checkclnum(boot, no, cl, &fat[cl].next);
311 free(fat);
314 *fp = fat;
417 clearchain(struct bootblock *boot, struct fatEntry *fat, cl_t head)
422 if (fat[p].head != head)
424 q = fat[p].next;
425 fat[p].next = fat[p].head = CLUST_FREE;
426 fat[p].length = 0;
431 tryclear(struct bootblock *boot, struct fatEntry *fat, cl_t head, cl_t *trunc)
434 clearchain(boot, fat, head);
447 checkfat(struct bootblock *boot, struct fatEntry *fat)
459 if (fat[head].head != 0 /* cluster already belongs to some chain */
460 || fat[head].next == CLUST_FREE
461 || fat[head].next == CLUST_BAD)
467 p = fat[p].next) {
468 fat[p].head = head;
473 fat[head].length = fat[head].next == CLUST_FREE ? 0 : len;
483 if (fat[head].head != head)
488 (n = fat[p].next) >= CLUST_FIRST && n < boot->NumClusters;
490 if (fat[n].head != head)
498 ret |= tryclear(boot, fat, head, &fat[p].next);
504 ret |= tryclear(boot, fat, head, &fat[p].next);
508 head, fat[n].head, n);
509 conf = tryclear(boot, fat, head, &fat[p].next);
510 if (ask(0, "Clear chain starting at %u", h = fat[n].head)) {
517 p = fat[p].next) {
518 if (h != fat[p].head) {
525 fat[p].head = head;
528 clearchain(boot, fat, h);
541 writefat(int fs, struct bootblock *boot, struct fatEntry *fat, int correct_fat)
605 if (fat[cl].next == CLUST_FREE)
607 *p++ = (u_char)fat[cl].next;
608 *p++ = (u_char)(fat[cl].next >> 8);
609 *p++ = (u_char)(fat[cl].next >> 16);
611 *p++ |= (fat[cl].next >> 24)&0x0f;
614 if (fat[cl].next == CLUST_FREE)
616 *p++ = (u_char)fat[cl].next;
617 *p++ = (u_char)(fat[cl].next >> 8);
620 if (fat[cl].next == CLUST_FREE)
623 && fat[cl + 1].next == CLUST_FREE)
625 *p++ = (u_char)fat[cl].next;
626 *p++ = (u_char)((fat[cl].next >> 8) & 0xf)
627 |(u_char)(fat[cl+1].next << 4);
628 *p++ = (u_char)(fat[++cl].next >> 4);
649 checklost(int dosfs, struct bootblock *boot, struct fatEntry *fat)
657 if (fat[head].head != head
658 || fat[head].next == CLUST_FREE
659 || (fat[head].next >= CLUST_RSRVD
660 && fat[head].next < CLUST_EOFS)
661 || (fat[head].flags & FAT_USED))
665 head, fat[head].length);
666 mod |= ret = reconnect(dosfs, boot, fat, head);
670 clearchain(boot, fat, head);