1/* 2 * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank 3 * Copyright (c) 1995 Martin Husemann 4 * Some structure declaration borrowed from Paul Popelka 5 * (paulp@uts.amdahl.com), see /sys/msdosfs/ for reference. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 29#include <sys/cdefs.h> 30#ifndef lint 31__RCSID("$NetBSD: dir.c,v 1.14 1998/08/25 19:18:15 ross Exp $"); 32static const char rcsid[] = |
33 "$FreeBSD: head/sbin/fsck_msdosfs/dir.c 209364 2010-06-20 09:40:54Z brian $"; |
34#endif /* not lint */ 35 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> 39#include <ctype.h> 40#include <unistd.h> 41#include <time.h> --- 195 unchanged lines hidden (view full) --- 237 free(buffer); 238 free(delbuf); 239 perror("No space for directory entry"); 240 return FSFATAL; 241 } 242 243 memset(rootDir, 0, sizeof *rootDir); 244 if (boot->flags & FAT32) { |
245 if (boot->bpbRootClust < CLUST_FIRST || 246 boot->bpbRootClust >= boot->NumClusters) { |
247 pfatal("Root directory starts with cluster out of range(%u)", 248 boot->bpbRootClust); 249 return FSFATAL; 250 } 251 cl = fat[boot->bpbRootClust].next; 252 if (cl < CLUST_FIRST 253 || (cl >= CLUST_RSRVD && cl< CLUST_EOFS) 254 || fat[boot->bpbRootClust].head != boot->bpbRootClust) { --- 97 unchanged lines hidden (view full) --- 352removede(int f, struct bootblock *boot, struct fatEntry *fat, u_char *start, 353 u_char *end, cl_t startcl, cl_t endcl, cl_t curcl, char *path, int type) 354{ 355 switch (type) { 356 case 0: 357 pwarn("Invalid long filename entry for %s\n", path); 358 break; 359 case 1: |
360 pwarn("Invalid long filename entry at end of directory %s\n", 361 path); |
362 break; 363 case 2: 364 pwarn("Invalid long filename entry for volume label\n"); 365 break; 366 } 367 if (ask(0, "Remove")) { 368 if (startcl != curcl) { 369 if (delete(f, boot, fat, --- 45 unchanged lines hidden (view full) --- 415 return FSERROR; 416 } else if (physicalSize - dir->size >= boot->ClusterSize) { 417 pwarn("%s has too many clusters allocated\n", 418 fullpath(dir)); 419 if (ask(1, "Drop superfluous clusters")) { 420 cl_t cl; 421 u_int32_t sz = 0; 422 |
423 for (cl = dir->head; (sz += boot->ClusterSize) < 424 dir->size;) |
425 cl = fat[cl].next; 426 clearchain(boot, fat, fat[cl].next); 427 fat[cl].next = CLUST_EOF; 428 return FSFATMOD; 429 } else 430 return FSERROR; 431 } 432 return FSOK; --- 27 unchanged lines hidden (view full) --- 460 */ 461 return FSOK; 462 } 463 shortSum = -1; 464 vallfn = invlfn = empty = NULL; 465 do { 466 if (!(boot->flags & FAT32) && !dir->parent) { 467 last = boot->bpbRootDirEnts * 32; |
468 off = boot->bpbResSectors + boot->bpbFATs * 469 boot->FATsecs; |
470 } else { 471 last = boot->bpbSecPerClust * boot->bpbBytesPerSec; 472 off = cl * boot->bpbSecPerClust + boot->ClusterOffset; 473 } 474 475 off *= boot->bpbBytesPerSec; 476 if (lseek(f, off, SEEK_SET) != off 477 || read(f, buffer, last) != last) { --- 68 unchanged lines hidden (view full) --- 546 if (!invlfn) { 547 invlfn = p; 548 invcl = cl; 549 } 550 vallfn = NULL; 551 } 552 lidx = *p & LRNOMASK; 553 t = longName + --lidx * 13; |
554 for (k = 1; k < 11 && t < longName + 555 sizeof(longName); k += 2) { |
556 if (!p[k] && !p[k + 1]) 557 break; 558 *t++ = p[k]; 559 /* 560 * Warn about those unusable chars in msdosfs here? XXX 561 */ 562 if (p[k + 1]) 563 t[-1] = '?'; --- 447 unchanged lines hidden --- |