Commit Graph

21 Commits

Author SHA1 Message Date
Xin LI
cf955ebf6f Remove unneeded blank line. No functional change.
MFC after:	2 weeks
2019-08-30 06:06:12 +00:00
Xin LI
55d26365b1 Use calloc().
MFC after:	2 weeks
2019-08-19 05:24:42 +00:00
Xin LI
51a1c26a18 Don't increment cl after increment.
MFC after:	3 days
2019-06-04 07:02:20 +00:00
Xin LI
2bf0ee64f9 Restore the ability of checking and fixing next free
cluster in FSINFO that was lost in r203872.

Obtained from:	NetBSD
MFC after:	2 weeks
2019-04-04 23:16:36 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Pedro F. Giffuni
ea4cbe3197 msdosfs: Assorted fixes from other BSDs.
When truncating cluster chains fix the length of the cluster head.
http://marc.info/?t=140304310700005&r=1&w=2

Avoid infinite loops in cluster chain linked lists.
http://marc.info/?l=openbsd-tech&m=140275150804337&w=2

Avoid off-by-one on FAT12 filesystems.
http://marc.info/?l=openbsd-tech&m=140234174104724&w=2

Obtained from:	NetBSD (from OpenBSD)
MFC after:	1 week
2014-07-14 20:58:02 +00:00
Pedro F. Giffuni
21f0d83866 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.

It must be noted that we never supported all the checks that NetBSD does
as some of them would cause failures with a freshly created FAT32
from MS-Windows.

While here, bring some space fixes.

Obtained from:	NetBSD (rev. 1.22)
MFC after:	3 days
2014-07-14 20:17:09 +00:00
Ulrich Spörlein
3bbc4438c9 Make fsck and fsck_msdosfs WARNS=6 clean
- sprinkle const
- add volatile qualifier to avoid vfork clobbering

Inspired by:	NetBSD
PR:		bin/139802
Reviewed by:	ed
2012-10-21 12:01:19 +00:00
Ulrich Spörlein
6cf357bc6c sbin/fsck: s/perror/perr/ to avoid shadowing
- rename some other vars too
- merge NetBSD license changes

Obtained from:	NetBSD
PR:		bin/139802
Reviewed by:	ed
2012-10-21 12:01:11 +00:00
Brian Somers
48790afa7b Fix some style(9), although there's a lot more issues here.
Fix some casting errors.

PR:		142384
Submitted by:	giffunip at tutopia dot com
Obtained from:	NetBSD
MFC after:	3 weeks
2010-06-20 09:40:54 +00:00
Konstantin Belousov
75fb535394 Rename fields to match better the msdosfs headers. This work is still
incomplete as some info doesn't really belong to the structs where it is
defined.

Submitted by:	Pedro F. Giffuni <giffunip tutopia com>
Reviewed by:	bde
MFC after:	2 weeks
2010-02-14 12:31:28 +00:00
Konstantin Belousov
6069db97f6 Bug fixes from NetBSD
- fix sign-compare issues.
- ANSIfy a couple of functions.
- Remove more duplicate #includes.
- Memory leak found by Coverity on NetBSD.

Submitted by:	Pedro F. Giffuni <giffunip tutopia com>
Reviewed by:	bde
MFC after:	2 weeks
2010-02-14 12:30:30 +00:00
Konstantin Belousov
a1882ff2a2 License changes from NetBSD.
Move to 2 clause license, approved by Wolfgang Solfrank.

Submitted by:	Pedro F. Giffuni <giffunip tutopia com>
MFC after:	2 weeks
2010-02-14 12:28:43 +00:00
Yaroslav Tykhiy
bb0e602de4 Spot two more bugs WRT adherence to the local prompt style. 2008-01-31 13:22:13 +00:00
Yaroslav Tykhiy
dc401d4927 Use consistent style in user prompts: the question is in a new line
and begins with a capital letter.  The rest of pwarn/ask pairs here
follows this style.

Requested by:	bde
2008-01-31 13:16:29 +00:00
Bruce Evans
910da6c689 Fixed some bugs in checkdirty(). The check for the clean bit was
combined with the the signature check in a wrong way (basically
(dirty:= signature_recognised() && !clean) instead of
(mightbedirty:= !signature_recognized || !clean), so file systems
with unrecognized signatures were considered clean.  Many of the
don't-care and reserved bits were not ignored, so some file systems
with valid signatures were unrecognized.  One of my FAT32 file systems
has a signature of f8,ff,ff,ff,ff,ff,ff,f7 when dirty, but only
f8,ff,ff,0f,ff,ff,ff,07 was recognised as dirty for FAT32, so the
fail-unsafeness made my file system always considered clean.

Check the i/o non-error bit in checkdirty().  Its absence would give
an unrecognized signature in code that is unaware of it, but we now
mask it out of the signature so we have to check it explicitly.  This
combines naturally with the check of the clean bit.

Reviewed by:	rnordier (except for final details)
2004-02-05 15:18:18 +00:00
Bruce Evans
8e9c564a11 Document the dirty flag and other bits in the first 2 FAT entries
better.  There is a related I/O error flag which we don't support in
the kernel but must support here.  (Support for bits that we don't
understand here is mostly automatic by fail-safeness, but checkdirty()
has fail-unsafeness.)  There are some reserved and don't-care bits
that weren't fully documented and aren't always masked properly.  The
comment about the bits in readfat() will be removed when the masking
is fixed.

Submitted by:	rnordier
2004-02-05 06:55:12 +00:00
Bruce Evans
a270f31ebd Prepare to fix checkdirty() by moving it from check.c to fat.c. It is
identical to a subset of readfat(), so it belongs near readfat() if not
in it.
2004-02-05 06:32:16 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Warner Losh
b70cd7ee68 o __P removed
o ansi function prototypes
o unifdef -D__STDC__
o __dead2 on usage prototype
o remove now-bogus main prototype
2002-03-20 22:57:10 +00:00
David E. O'Brien
0121b42aca Add fsck_msdosfs.
Obtained from:	NetBSD
2001-07-09 10:35:18 +00:00