DOSdosfsck 2.8.0 beta release! (djgpp port of the Linux tool / chkdsk)

Eric Auer <[email protected]>
Newsgroups gmane.os.freedos.devel
Message-ID <[email protected]>
Hi all,
I am proud to present sort-of-a-DOS-port of DOSFSCK 2.8,
a great Linux tool which is part of DOSFSTOOLS and which is able to:
- check FAT12, FAT16 and FAT32 filesystems for all kinds of errors
- simulate the changes before actually writing them
- undelete or drop files (small bonus feature)
- repair most of the error types that it can detect

The port was done using DJGPP, http://www.delorie.com/djgpp/
with the tools mak3791b, djdev203, bnu213b and gcc32b (I have
downloaded but not used other stuff as well. The 4 files are some
6.7 MB download and in total my djgpp tree is 18 MB including the
dosfsck project and a floppy disk image.).

The original DOSFSTOOLS site is
ftp://ftp.uni-erlangen.de/pub/Linux/LOCAL/dosfstools/

The current version can only work with diskimage files, BUT
there is a driver for DOS that makes your whole drive accessible
through a device ("filename"), if you really dare to let this BETA
release chew on your actual partitions... The driver can be found
somewhere on the www.FreeDos.org links page or something, I think.
Just create a diskimage of your favourite problematic floppy or
partition and see what dosfsck can do for now :-)).

Things I needed to change for the port:
- copy over types.h (the version with __u32 and so on in it) into the sources
- copy over msdos_fs.h and fd.h into the sources and remove all references to
  further Unix-only header files from them
- add loff_t typedefs to io.h, lfn.c and msdos_fs.h (kludgy)
- add #ifdefs to use the local copies of the Unix specific headers where
  appropriate (see above)
- add #ifdef to use local copy of version.h (normally, mkdosfs and dosfsck
  would share it, but I have ripped dosfsck out of the package only!)
- add #ifdef to -not- use getopt.h as djgpp has this in unistd.h instead
- add some debugging output to io.c
- add the O_BINARY flag to open in io.c (with #ifdef). Yuck. Dos and text-EOF.
- not much more :-))

Things YOU can hopefully improve:
- either, add DOS sector access functionality to io.c "if no image used"
  (it would be a pity to lost the ability to use images)
- or, add BIOS sector access and partition table parsing to io.c "if no
  image used" (see above). Currently, DJGPP only offers an easy interface
  to CHS BIOS access, see:
  http://www.delorie.com/djgpp/doc/libc-2.02/ ­> biosdisk
  So for LBA or DOS sector access, you need to use the less comfortable
  generic "real mode interrupt" interfaces. Sometimes you will run into
  additional troubles with buffers, but all typical DOS interrupt calls
  (at least) are known to the int86 implementation and buffers should get
  automatically copied to/from DOS address space.

Further testing is appreciated.
Do not try to port to 16bit C compilers for DOS. This tool can use very
much RAM in some cases (several megabytes) and DJGPP helps a lot with
porting because it has a very Unix-ish libc implementation that even
simulates some Unix properties on DOS, for example a DJGPP compiled
program knows the aliases \dev\null and /dev/null to the NUL device of DOS.

I would love to see the port completed, because at least for 386 systems,
the port of DOSFSCK to DOS -finally- gives us a really good scandisk tool.
You can use the dosio.c and dosio.h which I copied from e2fstools for Linux
and which are not yet used at all, for inspiration for writing the BIOS
disk access, I mean. Or, probably better, use the DOS sector read/write API
(a bit tricky maybe because you have to connect 16bit and 32bit things,
by hand, while biosdisk does so automatically).

Sample use:
C:\HOME\DJGPP\SRC\DOSFSCK>dosfsck -l -r -v -V \home\djgpp\diskimg\full.bin
Or, without the -l (so it will not list all found files):
C:\HOME\DJGPP\SRC\DOSFSCK>dosfsck -r -v -V \home\djgpp\diskimg\full.bin

dosfsck 2.8 (28 Feb 2001)
dosfsck 2.8, 28 Feb 2001, FAT32, LFN
fs_open(path='\home\djgpp\diskimg\full.bin', rw=1) =7
Boot sector contents:
System ID "FreeDOS "
Media byte 0xf0 (5.25" or 3.5" HD floppy)
       512 bytes per logical sector
       512 bytes per cluster
         1 reserved sector
First FAT starts at byte 512 (sector 1)
         2 FATs, 12 bit entries
      4608 bytes per FAT (= 9 sectors)
Root directory starts at byte 9728 (sector 19)
       224 root directory entries
Data area starts at byte 16896 (sector 33)
      2847 data clusters (1457664 bytes)
18 sectors/track, 2 heads
         0 hidden sectors
      2880 sectors total
Starting check/repair pass.
Checking for unused clusters.
Starting verification pass.
Checking for unused clusters.
\home\djgpp\diskimg\full.bin: 116 files, 848/2847 clusters
fs_close(write=1)
fs_flush()

Of course, the output looks far more impressive when you have some
errors on the filesystem ;-)).

You can find a snapshot of my directory (with .o files and other unneeded
things inside... not even getopt.h is needed, I just forgot to delete it) at:

http://www.coli.uni-sb.de/~eric/stuff/soft/specials/ ->
       dosdosfsck-2.8.0.zip

and a really old version of the manpage, converted to plain text, at:
http://www.coli.uni-sb.de/~eric/stuff/soft/specials/dosfsck.txt

The version number is derived from the 2.8 version number of the Linux
version... And I call it beta because the tool is pretty good and I do
not think that I have thrown it back into alpha state by porting. But
feel free to beautify and "compatibility-ify" my changes, I would appreciate
the port to become part of the main sources of dosfstools.

Have a nice day everybody and happy testing, porting and bugfixing.

Greetings, Eric

PS: Of course this tool may cause your computer to fall apart or something,
but I do not believe that I broke it, and it has proven to be reliable in
the past. Just want to say, be careful, as usual. But currently it can only
crash and/or damage the image file you are testing it with, so possible
damage is quite limited.



PS: The program runs in xDOSEMU in Linux as well, as does the compiler.
Do not forget to give dosemu enough DPMI available,
like this: In dosemu.conf, write: $_dpmi = (0x6000) # 12 MByte DPMI RAM for DOS
Especially the compiler itself needs quite some DPMI RAM. You also need to
set two environment variables for the compiler, like in my autoexec.bat:
path c:\bin;c:\gnu;c:\dosemu;c:\home\djgpp\bin
set DJGPP=c:\home\djgpp\djgpp.env
The .env file is both a configuration file and a marker for which directory
djgpp can find itself in. You do not need to edit the .env file. I had to
edit limits.h of djgpp to point to syslim.h instead of syslimits.h and copy
syslimits.h to syslim.h, because long filenames were not available! Everything
else of the compiler runs very much out of the box. Just type "make"...
in the dosfsck directory, I mean. Do not forget to remove the .o when you
change between Dos and Linux compiles :-).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.