VOGONS


First post, by Malvineous

User metadata
Rank Oldbie
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.

Reply 1 of 6, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

Thanks 😉 I'm not sure myself whether SF or Vogons is abetter place. I tend to use SF more.
I moved the topic into the patches subforum. Normal users are not allowed to start new topics there, you did nothing wrong 😉

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 2 of 6, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Oh phew, thought I stuffed up for a minute there 😀 Thanks!

Reply 3 of 6, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

commited in 3965, with changed error message.
Thanks!

Water flows down the stream
How to ask questions the smart way!

Reply 4 of 6, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Excellent, many thanks!

Reply 5 of 6, by acd2001

User metadata
Rank Newbie
Rank
Newbie

In visual studio S_ISDIR (a posix function) throw an error.
You must define it:

#ifndef S_ISDIR
#define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
#endif

Reply 6 of 6, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

*sigh*

Thanks for the report. The joys of multi platform.

I went with this:

#if defined(WIN32)
#ifndef S_ISDIR
#define S_ISDIR(m) (((m)&S_IFMT)==S_IFDIR)
#endif
#endif

Water flows down the stream
How to ask questions the smart way!