Module Name: src
Committed By: christos
Date: Mon Jul 7 17:45:42 UTC 2014
Modified Files:
src/sbin/fsck_msdos: dir.c fat.c
Log Message:
From: http://marc.info/?t=140304310700005&r=1&w=2
When truncating cluster chains fix the length of the cluster head.
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/fsck_msdos/dir.c
cvs rdiff -u -r1.24 -r1.25 src/sbin/fsck_msdos/fat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/fsck_msdos/dir.c
diff -u src/sbin/fsck_msdos/dir.c:1.25 src/sbin/fsck_msdos/dir.c:1.26
--- src/sbin/fsck_msdos/dir.c:1.25 Sun Feb 20 16:42:50 2011
+++ src/sbin/fsck_msdos/dir.c Mon Jul 7 13:45:42 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.25 2011/02/20 21:42:50 christos Exp $ */
+/* $NetBSD: dir.c,v 1.26 2014/07/07 17:45:42 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: dir.c,v 1.25 2011/02/20 21:42:50 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.26 2014/07/07 17:45:42 christos Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -420,12 +420,14 @@ checksize(struct bootblock *boot, struct
fullpath(dir));
if (ask(1, "Drop superfluous clusters")) {
cl_t cl;
- u_int32_t sz = 0;
+ u_int32_t sz, len;
- for (cl = dir->head; (sz += boot->ClusterSize) < dir->size;)
+ for (cl = dir->head, len = sz = 0;
+ (sz += boot->ClusterSize) < dir->size; len++)
cl = fat[cl].next;
clearchain(boot, fat, fat[cl].next);
fat[cl].next = CLUST_EOF;
+ fat[dir->head].length = len;
return FSFATMOD;
} else
return FSERROR;
Index: src/sbin/fsck_msdos/fat.c
diff -u src/sbin/fsck_msdos/fat.c:1.24 src/sbin/fsck_msdos/fat.c:1.25
--- src/sbin/fsck_msdos/fat.c:1.24 Thu Jan 17 11:45:48 2013
+++ src/sbin/fsck_msdos/fat.c Mon Jul 7 13:45:42 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: fat.c,v 1.24 2013/01/17 16:45:48 jakllsch Exp $ */
+/* $NetBSD: fat.c,v 1.25 2014/07/07 17:45:42 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fat.c,v 1.24 2013/01/17 16:45:48 jakllsch Exp $");
+__RCSID("$NetBSD: fat.c,v 1.25 2014/07/07 17:45:42 christos Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -355,7 +355,15 @@ tryclear(struct bootblock *boot, struct
clearchain(boot, fat, head);
return FSFATMOD;
} else if (ask(0, "Truncate")) {
+ uint32_t len;
+ cl_t p;
+
+ for (p = head, len = 0;
+ p >= CLUST_FIRST && p < boot->NumClusters;
+ p = fat[p].next, len++)
+ continue;
*truncp = CLUST_EOF;
+ fat[head].length = len;
return FSFATMOD;
} else
return FSERROR;