From owner-svn-src-stable-9@FreeBSD.ORG Thu Jul 17 02:43:54 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D6A831E7; Thu, 17 Jul 2014 02:43:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C29B52F0E; Thu, 17 Jul 2014 02:43:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6H2hsCX069656; Thu, 17 Jul 2014 02:43:54 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6H2hsnj069644; Thu, 17 Jul 2014 02:43:54 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201407170243.s6H2hsnj069644@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 17 Jul 2014 02:43:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r268785 - stable/9/sbin/fsck_msdosfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2014 02:43:55 -0000 Author: pfg Date: Thu Jul 17 02:43:53 2014 New Revision: 268785 URL: http://svnweb.freebsd.org/changeset/base/268785 Log: MFC r268628, r268631, r268635: Convert *rootDir from external to static. fsck_msdosfs: be a bit more permissive. The free space value in the FSInfo block is merely unitialized when it is 0xffffffff. This fixes a bug found in NetBSD. Respect FSFIXFAT. Fix some whitespace issues while here. Obtained from: NetBSD (CVS rev. 1.22, rev. 1.9), OpenBSD (misc) Modified: stable/9/sbin/fsck_msdosfs/check.c stable/9/sbin/fsck_msdosfs/dir.c stable/9/sbin/fsck_msdosfs/ext.h stable/9/sbin/fsck_msdosfs/fat.c Directory Properties: stable/9/sbin/fsck_msdosfs/ (props changed) Modified: stable/9/sbin/fsck_msdosfs/check.c ============================================================================== --- stable/9/sbin/fsck_msdosfs/check.c Thu Jul 17 02:33:40 2014 (r268784) +++ stable/9/sbin/fsck_msdosfs/check.c Thu Jul 17 02:43:53 2014 (r268785) @@ -142,7 +142,7 @@ checkfilesys(const char *fname) goto out; /* now write the FATs */ - if (mod & FSFATMOD) { + if (mod & (FSFATMOD|FSFIXFAT)) { if (ask(1, "Update FATs")) { mod |= writefat(dosfs, &boot, fat, mod & FSFIXFAT); if (mod & FSFATAL) Modified: stable/9/sbin/fsck_msdosfs/dir.c ============================================================================== --- stable/9/sbin/fsck_msdosfs/dir.c Thu Jul 17 02:33:40 2014 (r268784) +++ stable/9/sbin/fsck_msdosfs/dir.c Thu Jul 17 02:43:53 2014 (r268785) @@ -206,7 +206,7 @@ static char longName[DOSLONGNAMELEN] = " static u_char *buffer = NULL; static u_char *delbuf = NULL; -struct dosDirEntry *rootDir; +static struct dosDirEntry *rootDir; static struct dosDirEntry *lostDir; /* Modified: stable/9/sbin/fsck_msdosfs/ext.h ============================================================================== --- stable/9/sbin/fsck_msdosfs/ext.h Thu Jul 17 02:33:40 2014 (r268784) +++ stable/9/sbin/fsck_msdosfs/ext.h Thu Jul 17 02:43:53 2014 (r268785) @@ -26,7 +26,7 @@ */ #ifndef EXT_H -#define EXT_H +#define EXT_H #include @@ -43,8 +43,6 @@ extern int preen; /* we are preening */ extern int rdonly; /* device is opened read only (supersedes above) */ extern int skipclean; /* skip clean file systems if preening */ -extern struct dosDirEntry *rootDir; - /* * function declarations */ @@ -71,8 +69,8 @@ int checkfilesys(const char *); #define FSFATMOD 4 /* The FAT was modified */ #define FSERROR 8 /* Some unrecovered error remains */ #define FSFATAL 16 /* Some unrecoverable error occurred */ -#define FSDIRTY 32 /* File system is dirty */ -#define FSFIXFAT 64 /* Fix file system FAT */ +#define FSDIRTY 32 /* File system is dirty */ +#define FSFIXFAT 64 /* Fix file system FAT */ /* * read a boot block in a machine independent fashion and translate Modified: stable/9/sbin/fsck_msdosfs/fat.c ============================================================================== --- stable/9/sbin/fsck_msdosfs/fat.c Thu Jul 17 02:33:40 2014 (r268784) +++ stable/9/sbin/fsck_msdosfs/fat.c Thu Jul 17 02:43:53 2014 (r268785) @@ -240,7 +240,7 @@ readfat(int fs, struct bootblock *boot, ret |= FSDIRTY; else { /* just some odd byte sequence in FAT */ - + switch (boot->ClustMask) { case CLUST32_MASK: pwarn("%s (%02x%02x%02x%02x%02x%02x%02x%02x)\n", @@ -260,7 +260,7 @@ readfat(int fs, struct bootblock *boot, break; } - + if (ask(1, "Correct")) ret |= FSFIXFAT; } @@ -651,7 +651,7 @@ checklost(int dosfs, struct bootblock *b cl_t head; int mod = FSOK; int ret; - + for (head = CLUST_FIRST; head < boot->NumClusters; head++) { /* find next untravelled chain */ if (fat[head].head != head @@ -675,8 +675,9 @@ checklost(int dosfs, struct bootblock *b if (boot->bpbFSInfo) { ret = 0; - if (boot->FSFree != boot->NumFree) { - pwarn("Free space in FSInfo block (%d) not correct (%d)\n", + if (boot->FSFree != 0xffffffffU && + boot->FSFree != boot->NumFree) { + pwarn("Free space in FSInfo block (%u) not correct (%u)\n", boot->FSFree, boot->NumFree); if (ask(1, "Fix")) { boot->FSFree = boot->NumFree;