Deleted Added
full compact
dir.c (203874) dir.c (209364)
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[] =
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 203874 2010-02-14 12:31:28Z kib $";
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) {
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 || boot->bpbRootClust >= boot->NumClusters) {
245 if (boot->bpbRootClust < CLUST_FIRST ||
246 boot->bpbRootClust >= boot->NumClusters) {
246 pfatal("Root directory starts with cluster out of range(%u)",
247 boot->bpbRootClust);
248 return FSFATAL;
249 }
250 cl = fat[boot->bpbRootClust].next;
251 if (cl < CLUST_FIRST
252 || (cl >= CLUST_RSRVD && cl< CLUST_EOFS)
253 || fat[boot->bpbRootClust].head != boot->bpbRootClust) {

--- 97 unchanged lines hidden (view full) ---

351removede(int f, struct bootblock *boot, struct fatEntry *fat, u_char *start,
352 u_char *end, cl_t startcl, cl_t endcl, cl_t curcl, char *path, int type)
353{
354 switch (type) {
355 case 0:
356 pwarn("Invalid long filename entry for %s\n", path);
357 break;
358 case 1:
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:
359 pwarn("Invalid long filename entry at end of directory %s\n", path);
360 pwarn("Invalid long filename entry at end of directory %s\n",
361 path);
360 break;
361 case 2:
362 pwarn("Invalid long filename entry for volume label\n");
363 break;
364 }
365 if (ask(0, "Remove")) {
366 if (startcl != curcl) {
367 if (delete(f, boot, fat,

--- 45 unchanged lines hidden (view full) ---

413 return FSERROR;
414 } else if (physicalSize - dir->size >= boot->ClusterSize) {
415 pwarn("%s has too many clusters allocated\n",
416 fullpath(dir));
417 if (ask(1, "Drop superfluous clusters")) {
418 cl_t cl;
419 u_int32_t sz = 0;
420
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
421 for (cl = dir->head; (sz += boot->ClusterSize) < dir->size;)
423 for (cl = dir->head; (sz += boot->ClusterSize) <
424 dir->size;)
422 cl = fat[cl].next;
423 clearchain(boot, fat, fat[cl].next);
424 fat[cl].next = CLUST_EOF;
425 return FSFATMOD;
426 } else
427 return FSERROR;
428 }
429 return FSOK;

--- 27 unchanged lines hidden (view full) ---

457 */
458 return FSOK;
459 }
460 shortSum = -1;
461 vallfn = invlfn = empty = NULL;
462 do {
463 if (!(boot->flags & FAT32) && !dir->parent) {
464 last = boot->bpbRootDirEnts * 32;
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;
465 off = boot->bpbResSectors + boot->bpbFATs * boot->FATsecs;
468 off = boot->bpbResSectors + boot->bpbFATs *
469 boot->FATsecs;
466 } else {
467 last = boot->bpbSecPerClust * boot->bpbBytesPerSec;
468 off = cl * boot->bpbSecPerClust + boot->ClusterOffset;
469 }
470
471 off *= boot->bpbBytesPerSec;
472 if (lseek(f, off, SEEK_SET) != off
473 || read(f, buffer, last) != last) {

--- 68 unchanged lines hidden (view full) ---

542 if (!invlfn) {
543 invlfn = p;
544 invcl = cl;
545 }
546 vallfn = NULL;
547 }
548 lidx = *p & LRNOMASK;
549 t = longName + --lidx * 13;
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;
550 for (k = 1; k < 11 && t < longName + sizeof(longName); k += 2) {
554 for (k = 1; k < 11 && t < longName +
555 sizeof(longName); k += 2) {
551 if (!p[k] && !p[k + 1])
552 break;
553 *t++ = p[k];
554 /*
555 * Warn about those unusable chars in msdosfs here? XXX
556 */
557 if (p[k + 1])
558 t[-1] = '?';

--- 447 unchanged lines hidden ---
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 ---