First post, by Malvineous
- Rank
- Oldbie
Hi all,
I'm not sure where to submit patches for DOSBox - is here ok or should they go to the SF page?
Either way I recently tried to install DOS onto an SD card via DOSBox, but IMGMOUNT was complaining that /dev/sdd was a folder so I needed to use the MOUNT command instead. The MOUNT command of course didn't work because /dev/sdd is not actually a folder.
I tracked the problem down to a bug in the folder test code, and the following patch fixes it:
Index: src/dos/dos_programs.cpp
===================================================================
--- src/dos/dos_programs.cpp (revision 3911)
+++ src/dos/dos_programs.cpp (working copy)
@@ -298,7 +298,7 @@
return;
}
/* Not a switch so a normal directory/file */
- if (!(test.st_mode & S_IFDIR)) {
+ if (!S_ISDIR(test.st_mode)) {
#ifdef OS2
HFILE cdrom_fd = 0;
ULONG ulAction = 0;
@@ -1216,7 +1216,7 @@
}
}
}
- if ((test.st_mode & S_IFDIR)) {
+ if (S_ISDIR(test.st_mode)) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_MOUNT"));
return;
}
@@ -1377,6 +1377,10 @@
} else {
FILE *newDisk = fopen(temp_line.c_str(), "rb+");
+ if (!newDisk) {
+ WriteOut(MSG_Get("PROGRAM_IMGMOUNT_FILE_NOT_FOUND"));
+ return;
+ }
fseek(newDisk,0L, SEEK_END);
imagesize = (ftell(newDisk) / 1024);
According to the docs you aren't supposed to test the bits directly, but use comparison macros instead, which is what this patch does. After this I have no problem using IMGMOUNT to pass /dev/sdd through as a raw DOSBox hard disk.
The last bit of code at the end of the patch prevents a crash if you try to IMGMOUNT a file or device that you don't have read access to.