dosemu2 / dosemu2

Run DOS programs under linux:
http://dosemu2.github.io/dosemu2/
GNU General Public License v2.0
560 stars 58 forks source link

Booting with -K and -I "disk { hdimage ... }" shadows one of the drives used for disk image partitions #768

Closed ecm-pushbx closed 5 years ago

ecm-pushbx commented 5 years ago

Describe the bug When booting with both a -K directory and -I "disk { hdimage ... }", drive G is first used for a partition in the disk image, but then seems to also be used to redirect to the -K directory.

To Reproduce

$ rm fat-128m.img
$ truncate -s "$((128 * 1024 * 1024))" fat-128m.img
$ /sbin/fdisk fat-128m.img

Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xa4de813e.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-262143, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-262143, default 262143): 

Created a new partition 1 of type 'Linux' and of size 127 MiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 6
Changed type of partition 'Linux' to 'FAT16'.

Command (m for help): w
The partition table has been altered.
Syncing disks.

$ dosemu -dumb -K "$PWD" -I "disk { hdimage fat-128m.img }"
ERROR: hdimage size is not cylinder-aligned (5104 sectors), truncated!
                                                                      dosemu2 2.0pre8-20190125-883-g8318127b4
Configured: 2019-01-14 13:29:43 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=   127 MB
dosemu XMS 3.0 & UMB support enabled                                           
dosemu EMS driver rev 0.8 installed.
EMUFS host file and print access available
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190125-883-g8318127b4
G:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\[home]\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
G: = \\LINUX\FS\[home]\test\20190131\ attrib = READ/WRITE
G:\>dir
 Volume in drive G is ST 20190131
 Directory of G:\

HARD     IMG    536,870,912  01-31-19  1:18p
FLOPP~V4 CLE     1,474,560  01-31-19  1:24p
FORMAT   ZIP        31,218  01-31-19 12:57p
HARDI~JN CLE    536,870,912  01-31-19  1:18p
FLOPPY   IMG     1,474,560  01-31-19  1:24p
FAT-128M IMG    134,217,728  01-31-19  1:29p
         6 file(s)   1,210,939,890 bytes
         0 dir(s)      2,588 Mega bytes free
G:\>exitemu
$ 

Attach the log boot.log

stsp commented 5 years ago

Currently we only have find_free_drive() that looks through redirected drives. But in this case we need to also check fatfs drives, and I wonder if this is the only such place. Andrew, would you like to take a look at fixing this?

ecm-pushbx commented 5 years ago

Now drive S: is always used for the -K directory. I'm not sure this is as intended?

stsp commented 5 years ago

No, its not. But for me its still G: dosemu -K ./ -E dir -T maps G for me. Please provide more info on reproducing.

ecm-pushbx commented 5 years ago
$ mkdir -p test/20190211
$ cd test/20190211
$ touch test.dat
$ dosemu -K ./ -E dir -T -dumb
dosemu2 2.0pre8-20190204-914-g0b782f4e1
Configured: 2019-02-02 21:16:27 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
CONFIG.SYS error in line 8                                                     
>>>device=dosemu\umb.sys
         ^
UMBs unavailable!
CONFIG.SYS error in line 9
>>>devicehigh=dosemu\ems.sys
             ^
UMBs unavailable!
CONFIG.SYS error in line 10
>>>devicehigh=dosemu\emufs.sys
             ^
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190204-914-g0b782f4e1
About to Execute : dir
 Volume in drive S is ST 20190211
 Directory of S:\

TEST     DAT             0  02-11-19  3:47p
         1 file(s)              0 bytes
         0 dir(s)      3,736 Mega bytes free
C:\>exitemu
$ rm ~/.dosemu/drive_c/kernel.sys 
$ dosemu -K ./ -E dir -T -dumb
dosemu2 2.0pre8-20190204-914-g0b782f4e1
Configured: 2019-02-02 21:16:27 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

ERROR: fdpp booting, this is very experimental!
FDPP kernel 0.1beta4 [GIT: beta-4-14-g2227711] (compiled Feb  2 2019)
Kernel compatibility 7.10 - GNUC - 80386 CPU required - FAT32 support

Written by Stas Sergeev, FDPP project.
Based on FreeDOS sources (C) Pasquale J. Villani and The FreeDOS Project.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
dosemu XMS 3.0 & UMB support enabled                                           
dosemu EMS driver rev 0.8 installed.
EMUFS host file and print access available
Kernel: allocated 115 Diskbuffers = 62560 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190204-914-g0b782f4e1
About to Execute : dir
 Volume in drive S is ST 20190211
 Directory of S:\

TEST     DAT             0  02-11-19  3:47p
         1 file(s)              0 bytes
         0 dir(s)      3,736 Mega bytes free
C:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\[home]\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
S: = \\LINUX\FS\[home]\test\20190211\ attrib = READ/WRITE
C:\>exitemu
$ 

boot.log

stsp commented 5 years ago

Andrew, do you see something like this?

stsp commented 5 years ago

Is this still reproducible?

ecm-pushbx commented 5 years ago

Nope, now I get G: there as expected:

$ touch test.dat
$ dosemu -K ./ -E dir -T -dumb
dosemu2 2.0pre8-20190220-937-gb936b31d6
Configured: 2019-02-20 12:21:28 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
dosemu XMS 3.0 & UMB support enabled                                           
dosemu EMS driver rev 0.8 installed.
EMUFS host file and print access available
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190220-937-gb936b31d6
About to Execute : dir
 Volume in drive G is ST 20190211
 Directory of G:\

TEST     DAT             0  02-23-19 12:19p
         1 file(s)              0 bytes
         0 dir(s)      3,632 Mega bytes free
C:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\[home]\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
G: = \\LINUX\FS\[home]\test\20190211\ attrib = READ/WRITE
C:\>exitemu
$ 
andrewbird commented 5 years ago

Just looking at your log, previous run was with FDPP, latest was with FreeDOS. Not sure if that's significant?

ecm-pushbx commented 5 years ago

With the patch applied (at revision gb936b31d6) I get a different shadowing behaviour if there is more than one partition per disk image. Two partitions are skipped, but the third (which is actually still in the first image's disk) is shadowed. This is the image I used: hard.zip (I use the same file copied to hard2.img to use two images.)

$ dosemu -K ./ -E dir -T -dumb -I "disk { hdimage hard.img } disk { hdimage hard2.img }"
ERROR: hdimage size is not cylinder-aligned (4351 sectors), truncated!
                                                                      ERROR: hdimage size is not cylinder-aligned (4351 sectors), truncated!
                                                            dosemu2 2.0pre8-20190220-937-gb936b31d6
Configured: 2019-02-20 12:21:28 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=    12 MB
H: HD6, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=    12 MB
I: HD5, Pri[ 2], CHS=    1-167-39, start=    13 MB, size=   128 MB
J: HD5, Pri[ 3], CHS=   17-248-40, start=   141 MB, size=   371 MB
K: HD6, Pri[ 2], CHS=    1-167-39, start=    13 MB, size=   128 MB
L: HD6, Pri[ 3], CHS=   17-248-40, start=   141 MB, size=   371 MB
dosemu XMS 3.0 & UMB support enabled                                           
dosemu EMS driver rev 0.8 installed.
EMUFS host file and print access available
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190220-937-gb936b31d6
About to Execute : dir
 Volume in drive I is ST 20190131
 Directory of I:\

COMMAND  ZIP        97,241  01-31-19  2:00p
HARD     IMG    536,870,912  01-31-19  3:17p
FLOPP~V4 CLE     1,474,560  01-31-19  1:24p
FORMAT   ZIP        31,218  01-31-19 12:57p
HARD2    IMG    536,870,912  01-31-19  3:17p
HARDI~JN CLE    536,870,912  01-31-19  1:18p
FLOPPY   IMG     1,474,560  02-05-19  3:24p
FAT-128M IMG    134,217,728  01-31-19  1:29p
         8 file(s)   1,747,908,043 bytes
         0 dir(s)      3,620 Mega bytes free
C:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\[home]\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
I: = \\LINUX\FS\[home]\test\20190131\ attrib = READ/WRITE
C:\>exitemu
$ bdiff hard2.img hard.img 
File: hard2.img
Files are identical.
$ 7za -tzip a hard.zip hard.img

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs AMD A10-7870K Radeon R7, 12 Compute Cores 4C+8G (630F81),ASM,AES-NI)

Scanning the drive:
1 file, 536870912 bytes (512 MiB)

Creating archive: hard.zip

Items to compress: 1

Files read from disk: 1
Archive size: 632224 bytes (618 KiB)
Everything is Ok
$ 

boot.log

ecm-pushbx commented 5 years ago

Just looking at your log, previous run was with FDPP, latest was with FreeDOS. Not sure if that's significant?

Same run with FDPP also results in G: being used now:

$ mv ~/.dosemu/drive_c/{kernel.sys,kernel.old}
$ cd ~/test/20190211/
$ touch test.dat
$ dosemu -K ./ -E dir -T -dumb
dosemu2 2.0pre8-20190220-937-gb936b31d6
Configured: 2019-02-20 12:21:28 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

ERROR: fdpp booting, this is very experimental!
FDPP kernel 0.1beta4 [GIT: beta-4-29-g5e24555] (compiled Feb 20 2019)
Kernel compatibility 7.10 - GNUC - 80386 CPU required - FAT32 support

Written by Stas Sergeev, FDPP project.
Based on FreeDOS sources (C) Pasquale J. Villani and The FreeDOS Project.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
dosemu XMS 3.0 & UMB support enabled                                           
dosemu EMS driver rev 0.8 installed.
EMUFS host file and print access available
Kernel: allocated 115 Diskbuffers = 62560 Bytes in HMA
Starting shell: c:\command.com /e:1024 /k %FDPP_AUTOEXEC%
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190220-937-gb936b31d6
About to Execute : dir
 Volume in drive G is ST 20190211
 Directory of G:\

TEST     DAT             0  02-23-19 12:30p
         1 file(s)              0 bytes
         0 dir(s)      3,650 Mega bytes free
C:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\[home]\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
G: = \\LINUX\FS\[home]\test\20190211\ attrib = READ/WRITE
C:\>exitemu
ecm-pushbx commented 5 years ago

The new shadowing behaviour also happens with FDPP too:

$ cd ~/test/20190131
$ dosemu -K ./ -E dir -T -dumb -I "disk { hdimage hard.img } disk { hdimage hard2.img }"
ERROR: hdimage size is not cylinder-aligned (4351 sectors), truncated!
                                                                      ERROR: hdimage size is not cylinder-aligned (4351 sectors), truncated!
                                                            dosemu2 2.0pre8-20190220-937-gb936b31d6
Configured: 2019-02-20 12:21:28 +0100
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

ERROR: fdpp booting, this is very experimental!
FDPP kernel 0.1beta4 [GIT: beta-4-29-g5e24555] (compiled Feb 20 2019)
Kernel compatibility 7.10 - GNUC - 80386 CPU required - FAT32 support

Written by Stas Sergeev, FDPP project.
Based on FreeDOS sources (C) Pasquale J. Villani and The FreeDOS Project.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=    12 MB
H: HD6, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=    12 MB
I: HD5, Pri[ 2], CHS=    1-167-39, start=    13 MB, size=   128 MB
J: HD5, Pri[ 3], CHS=   17-248-40, start=   141 MB, size=   371 MB
K: HD6, Pri[ 2], CHS=    1-167-39, start=    13 MB, size=   128 MB
L: HD6, Pri[ 3], CHS=   17-248-40, start=   141 MB, size=   371 MB
dosemu XMS 3.0 & UMB support enabled                                           
dosemu EMS driver rev 0.8 installed.
EMUFS host file and print access available
Kernel: allocated 115 Diskbuffers = 62560 Bytes in HMA
Starting shell: c:\command.com /e:1024 /k %FDPP_AUTOEXEC%
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190220-937-gb936b31d6
About to Execute : dir
 Volume in drive I is ST 20190131
 Directory of I:\

COMMAND  ZIP        97,241  01-31-19  2:00p
HARD     IMG    536,870,912  01-31-19  3:17p
FLOPP~V4 CLE     1,474,560  01-31-19  1:24p
FORMAT   ZIP        31,218  01-31-19 12:57p
HARD2    IMG    536,870,912  01-31-19  3:17p
HARDI~JN CLE    536,870,912  01-31-19  1:18p
HARD     ZIP       632,224  02-23-19 12:26p
FLOPPY   IMG     1,474,560  02-05-19  3:24p
FAT-128M IMG    134,217,728  01-31-19  1:29p
         9 file(s)   1,748,540,267 bytes
         0 dir(s)      3,650 Mega bytes free
C:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\[home]\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
I: = \\LINUX\FS\[home]\test\20190131\ attrib = READ/WRITE
C:\>exitemu
$ 

boot.log

ecm-pushbx commented 5 years ago

An idea I had is that you could check for an empty CDS entry then use that drive for the -K directory. That should fix this for all cases.

stsp commented 5 years ago

No, will just move it upwards, together with boot drives. Why 2 partitions are skipped? I guess you have 2 different hdimages?

ecm-pushbx commented 5 years ago

No, will just move it upwards, together with boot drives. Why 2 partitions are skipped? I guess you have 2 different hdimages?

Yes, I have hard.img and hard2.img (a copy of the first one). Each of those has (the same) 3 partitions with FAT file systems. It seems you made it skip as many drives as there are images (ie, 2) but you should make it skip all drives that are already mounted by DOS.

stsp commented 5 years ago

Hmm this wasn't fixed by the boot drive relocation, the way I thought it could. So instead of scanning "drives" array, we probably need to ask DOS if the drive is free. Andrew, would you like to take a look into that? :)

ecm-pushbx commented 5 years ago

As I wrote, "you should make it skip all drives that are already mounted by DOS." For that, you need to check the CDS until you find an entry that has both validity flags clear.

andrewbird commented 5 years ago

@ecm-pushbx of course you are correct that checking CDS flags is a good solution, but I have a personal goal to limit CDS access to only within the redirector itself. I found an alternative in asking DOS to return the filesystem sizes for each drive until it returns 'invalid drive' error. I suspect it might be quite slow in comparison, but it won't be called repeatedly or frequently so I think it's acceptable. I used your test images but paraphrased your setup somewhat, so it would be good to get a confirmation that it's good for you too?

ecm-pushbx commented 5 years ago

of course you are correct that checking CDS flags is a good solution, but I have a personal goal to limit CDS access to only within the redirector itself.

Well, you already need to access the CDS to actually install the drive. Free space and FS size calls tend to be unreliable, I think to recall.

With the test from this comment https://github.com/stsp/dosemu2/issues/768#issuecomment-466640588 it seems to run as expected now:

$ dosemu -K ./ -E dir -T -dumb -I "disk { hdimage hard.img } disk { hdimage hard2.img }"
ERROR: hdimage size is not cylinder-aligned (4351 sectors), truncated!
                                                                      ERROR: hdimage size is not cylinder-aligned (4351 sectors), truncated!
                                                            dosemu2 2.0pre8-20190715-1151-gde1667e74
Configured: 2019-07-15 21:03:58 +0200
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=    12 MB
H: HD6, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=    12 MB
I: HD5, Pri[ 2], CHS=    1-167-39, start=    13 MB, size=   128 MB
J: HD5, Pri[ 3], CHS=   17-248-40, start=   141 MB, size=   371 MB
K: HD6, Pri[ 2], CHS=    1-167-39, start=    13 MB, size=   128 MB
L: HD6, Pri[ 3], CHS=   17-248-40, start=   141 MB, size=   371 MB

It is odd that it first lists the first primary partition for each unit (C: to F: all are "first primary partition" too), and then the subsequent partitions for each unit. But I think that's just a generic DOS quirk that is followed by FreeDOS too. (Maybe that "DLA sort" setting is related to that.)

EMUFS host file and print access available                                     
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
dosemu CDROM driver installed (V0.2)
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190715-1151-gde1667e74
About to Execute : dir
 Volume in drive M is ST 20190715
 Directory of M:\

BOOT1~-$ LOG         4,590  07-15-19  9:01p
HARD     IMG    536,870,912  01-31-19  3:17p
HARD2    IMG    536,870,912  07-15-19  9:06p
HARD     ZIP       632,224  07-15-19  9:05p
FAT-128M IMG    134,217,728  07-15-19  9:01p
         5 file(s)   1,208,596,366 bytes
         0 dir(s)      2,210 Mega bytes free
M:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\home\evln\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
M: = \\LINUX\FS\home\evln\test\20190715\ attrib = READ/WRITE
M:\>dir
 Volume in drive M is ST 20190715

 Directory of M:\

BOOT1~-$ LOG         4,590  07-15-19  9:01p
HARD     IMG    536,870,912  01-31-19  3:17p
HARD2    IMG    536,870,912  07-15-19  9:06p
HARD     ZIP       632,224  07-15-19  9:05p
FAT-128M IMG    134,217,728  07-15-19  9:01p
         5 file(s)   1,208,596,366 bytes
         0 dir(s)      2,210 Mega bytes free
M:\>dir G:
 Volume in drive G has no label
 Volume Serial Number is 1157-14F5
File not found.
M:\>dir H:
 Volume in drive H has no label
 Volume Serial Number is 1157-14F5
File not found.
M:\>dir I:
 Volume in drive I has no label
 Volume Serial Number is 225F-14F5
File not found.
M:\>dir J:
 Volume in drive J has no label
 Volume Serial Number is 2D48-14F5
File not found.
M:\>dir M:
 Volume in drive M is ST 20190715

 Directory of M:\

BOOT1~-$ LOG         4,590  07-15-19  9:01p
HARD     IMG    536,870,912  01-31-19  3:17p
HARD2    IMG    536,870,912  07-15-19  9:06p
HARD     ZIP       632,224  07-15-19  9:05p
FAT-128M IMG    134,217,728  07-15-19  9:01p
         5 file(s)   1,208,596,366 bytes
         0 dir(s)      2,210 Mega bytes free
M:\>dir K:
 Volume in drive K has no label
 Volume Serial Number is 225F-14F5
File not found.
M:\>dir L:
 Volume in drive L has no label
 Volume Serial Number is 2D48-14F5
File not found.
M:\>dir M:
 Volume in drive M is ST 20190715

 Directory of M:\

BOOT1~-$ LOG         4,590  07-15-19  9:01p
HARD     IMG    536,870,912  01-31-19  3:17p
HARD2    IMG    536,870,912  07-15-19  9:06p
HARD     ZIP       632,224  07-15-19  9:05p
FAT-128M IMG    134,217,728  07-15-19  9:01p
         5 file(s)   1,208,596,366 bytes
         0 dir(s)      2,210 Mega bytes free
M:\>dir N:
File not found. - 'N:'
M:\>
M:\>cp 

M:\>exitemu

boot.3.log

However, the original test (from the first post in this issue) fails now, as follows:

$ dosemu -dumb -K "$PWD" -I "disk { hdimage fat-128m.img }"
ERROR: hdimage size is not cylinder-aligned (5104 sectors), truncated!
                                                                      dosemu2 2.0pre8-20190715-1151-gde1667e74
Configured: 2019-07-15 21:03:58 +0200
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=   127 MB
EMUFS host file and print access available                                     
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
dosemu CDROM driver installed (V0.2)
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190715-1151-gde1667e74
Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? Terminated
                                              Terminated with signal 15

boot.2.log

Entering any of the options to the critical error handler just continues with more and more of its prompts. This might be because the partition isn't formatted (all zeros).

So, this seems to be mainly due to setting the wrong drive. (Sets G: but should set H:). Here's a run from before rebuilding dosemu:

$ dosemu -dumb -K "$PWD" -I "disk { hdimage fat-128m.img }"
ERROR: hdimage size is not cylinder-aligned (5104 sectors), truncated!
                                                                      dosemu2 2.0pre8-20190614-1095-g6aa6b8eae
Configured: 2019-06-12 22:00:27 +0200
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=   127 MB
EMUFS host file and print access available                                     
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190614-1095-g6aa6b8eae
H:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\home\evln\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
H: = \\LINUX\FS\home\evln\test\20190715\ attrib = READ/WRITE
H:\>dir
 Volume in drive H is ST 20190715
 Directory of H:\

FAT-128M IMG    134,217,728  07-15-19  9:01p
         1 file(s)    134,217,728 bytes
         0 dir(s)      3,234 Mega bytes free
H:\>exitemu

boot.1.log

And another earlier run (no boot.log for this, sorry):

$ dosemu -dumb -K "$PWD" -I "disk { hdimage fat-128m.img }"
ERROR: hdimage size is not cylinder-aligned (5104 sectors), truncated!
                                                                      dosemu2 2.0pre8-20190614-1095-g6aa6b8eae
Configured: 2019-06-12 22:00:27 +0200
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=   127 MB
EMUFS host file and print access available                                     
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190614-1095-g6aa6b8eae
H:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\home\evln\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
H: = \\LINUX\FS\home\evln\test\20190715\ attrib = READ/WRITE
H:\>dir
 Volume in drive H is ST 20190715
 Directory of H:\

FAT-128M IMG    134,217,728  07-15-19  8:59p
         1 file(s)    134,217,728 bytes
         0 dir(s)      3,234 Mega bytes free
H:\>dir G:
 Volume in drive G Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? 
has no label
 Volume Serial Number is 0112-0000
Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? 
Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? 
File not found.
H:\>

I managed to load DOS with only the HDD image without the -K switch. This way I was able to format the partition. After that, dosemu with both the HDD image as well as the -K switch works as expected now, it even goes to the correct drive (the -K one). Don't know why it kept accessing G: when it was unformatted, though.

$ dosemu -dumb -I "disk { hdimage fat-128m.img }"
ERROR: hdimage size is not cylinder-aligned (5104 sectors), truncated!
                                                                      dosemu2 2.0pre8-20190715-1151-gde1667e74
Configured: 2019-07-15 21:03:58 +0200
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=   127 MB
EMUFS host file and print access available                                     
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
dosemu CDROM driver installed (V0.2)
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190715-1151-gde1667e74
C:\>dir G:
 Volume in drive G Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? 
has no label
 Volume Serial Number is 0112-0000
Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? 
Error reading from drive G: DOS area: general failure
(A)bort, (I)gnore, (R)etry, (F)ail? 
File not found.
C:\>format G:

 WARNING: ALL DATA ON NON-REMOVABLE DISK
 DRIVE G: WILL BE LOST! PLEASE CONFIRM!
 Proceed with format (YES/NO)? YES
##  Boot sector unreadable, disk not yet formatted
 Disk size: 127 Mbytes, FAT16. ***
Cannot find existing format - not saving UNFORMAT data.
Please enter volume label (max. 11 chars): 
No label, disk will have no creation timestamp.
 QuickFormatting (only flushing metadata)
 Warning: Resets bad cluster marks if any.
 Preparing FAT area...
100 percent completed.

QuickFormat complete.

   133,169,152  bytes total disk space (disk size)
   132,890,624  bytes available on disk (free clusters)

         2,048  bytes in each allocation unit.
        64,888 allocation units on disk.

 Volume Serial Number is 1F24-1CFD
C:\>dir G:
 Volume in drive G has no label
 Volume Serial Number is 1F24-1CFD
File not found.
C:\>exitemu
$ 
$ 
$ dosemu -dumb -K "$PWD" -I "disk { hdimage fat-128m.img }"
ERROR: hdimage size is not cylinder-aligned (5104 sectors), truncated!
                                                                      dosemu2 2.0pre8-20190715-1151-gde1667e74
Configured: 2019-07-15 21:03:58 +0200
Please test against a recent version before reporting bugs and problems.
Get the latest code at http://stsp.github.io/dosemu2
Submit Bugs via https://github.com/stsp/dosemu2/issues
Ask for help in mail list: linux-msdos@vger.kernel.org

FreeDOS kernel - SVN (build 2042 OEM:0xfd) [compiled Sep 22 2017]
Kernel compatibility 7.10 - BORLANDC - FAT32 support

(C) Copyright 1995-2012 Pasquale J. Villani and The FreeDOS Project.
All Rights Reserved. This is free software and comes with ABSOLUTELY NO
WARRANTY; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2, or (at your option) any later version.
C: HD1, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
D: HD2, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
E: HD3, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
F: HD4, Pri[ 1], CHS=    0-1-1, start=     0 MB, size=  2000 MB
G: HD5, Pri[ 1], CHS=    0-32-33, start=     1 MB, size=   127 MB
EMUFS host file and print access available                                     
dosemu XMS 3.0 & UMB support enabled
dosemu EMS driver rev 0.8 installed.
dosemu CDROM driver installed (V0.2)
Kernel: allocated 30 Diskbuffers = 15960 Bytes in HMA
BLASTER=A220 I5 D1 H5 P330 T6
MIDI=SYNTH:2 MAP:E MODE:0
Welcome to dosemu2!
    Build 2.0pre8-20190715-1151-gde1667e74
H:\>dir G:
 Volume in drive G has no label
 Volume Serial Number is 1F24-1CFD
File not found.
H:\>lredir
Current Drive Redirections:
C: = \\LINUX\FS\home\evln\.dosemu\drive_c\ attrib = READ/WRITE
D: = \\LINUX\FS\usr\local\share\dosemu\dosemu2-cmds-0.2\ attrib = READ/WRITE
E: = \\LINUX\FS\usr\local\share\fdpp\ attrib = READ/WRITE
F: = \\LINUX\FS\usr\local\share\dosemu\freedos\ attrib = READ/WRITE
H: = \\LINUX\FS\home\evln\test\20190715\ attrib = READ/WRITE
H:\>exitemu
$ 

boot.4.log

ecm-pushbx commented 5 years ago

It is odd that it first lists the first primary partition for each unit (C: to F: all are "first primary partition" too), and then the subsequent partitions for each unit.

To clarify, it first sets up the first-primary partitions of all units, and then subsequent partitions, which in this case are subsequent-primary partitions. I would have expected logical partitions to be set up last, but wasn't aware that subsequent-primary partitions also are relegated to the second run.

andrewbird commented 5 years ago

Well, you already need to access the CDS to actually install the drive.

Yes and no, CDS access from inside the redirector is fine as we can use int2f/1217 to get it (because we have DOS stack), from outside we have to use int21/52 get the start of the CDS array and compute it by knowing its size.

It is odd that it first lists the first primary partition for each unit (C: to F: all are "first primary partition" too), and then the subsequent partitions for each unit. But I think that's just a generic DOS quirk that is followed by FreeDOS too.

Yep I think if people were designing this afresh it wouldn't be like that, but that's how DOS has always done it.

So, this seems to be mainly due to setting the wrong drive. (Sets G: but should set H:).

Mmm, that's likely due to DOS's get disk usage function failing on an unformatted partition, it's a bit of a corner case but what are your thoughts @stsp ?

stsp commented 5 years ago

corner case but what are your thoughts @stsp ?

Yes, I think querying free space on unformatted partition is silly as there are no free space (you can't write to it before fs is created). Can you try ah=69h, get serial number instead?

andrewbird commented 5 years ago

@stsp, almost. Int21/69h is DOS 4+ , only works with physical disks and returns error for missing serial number, but you made me think a little harder. I've added in a check to get the DPB, which works for formatted and unformatted physical drives, then if nothing found it does the get disk space check to pick up the network drives.. @ecm-pushbx it works for me, could you confirm?