VOGONS


First post, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Hi all,

Has anyone tried to mount real disk devices in DOSBox under Linux? I can't find any comments on the forum or Google so I'm wondering whether I am doing something wrong.

I am trying to mount a 4GB SD card (via a USB adapter) which appears on my system as /dev/sdd. I am trying to mount it like this:

imgmount 2 /dev/sdd -t hdd -fs none -size 512,63,16,7803

But that gives me the DOSBox error "To mount directories, use the MOUNT command, not the IMGMOUNT command." Weirdly I can "mount c /dev/sdd" and it doesn't give me an error, but running a "dir c:" command tells me "File *.* not found" (which would make sense, as /dev/sdd is a device file, not a folder.) I am hoping to boot real DOS and format/install it onto the SD card, for use in a real PC.

Is there a trick to mounting a raw device as a file? I'd like to avoid mounting a 4GB file instead, because then every time I want to make a change on the SD card I have to read 4GB off it and write 4GB back again which takes forever.

Last edited by Malvineous on 2015-12-18, 12:16. Edited 1 time in total.

Reply 1 of 3, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

imgmount is for mounting images *not* devices. Why don't you mount the device in linux and then mount the volume in Dosbox?

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 3, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Thanks for the quick reply!

What's the difference in this case between an image and a device file? They are both (in my case) 4GB files, just on different underlying storage devices. If I open a 4GB file or /dev/sdd in my hex editor, they are identical in size and content. I can mount a 4GB file in DOSBox then copy it over the top of /dev/sdd to use the SD card in a real machine, so I am just hoping to skip the copy step and have DOSBox access the SD card directly, just like any other Linux program does when you tell it to operate on the file /dev/sdd.

I'm not sure what you mean by mounting the device and then mounting the volume. I want to run FDISK on the device within DOSBox, which means it can't be mounted under Linux, unless I'm missing something? I don't think you normally mount .img files in Linux before passing them to DOSBox, so this wouldn't be any different as I'm attempting to do the same thing.

Reply 3 of 3, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

I had a look at the DOSBox source code and I discovered it is a bug in the way the image file's attributes are checked. DOSBox thinks the device file is a directory when it is not. Using the correct check function solves the problem and I am able to mount my SD card directly in DOSBox.

diff -ru dosbox.orig/src/dos/dos_programs.cpp dosbox/src/dos/dos_programs.cpp
--- dosbox.orig/src/dos/dos_programs.cpp 2015-05-02 19:31:20.867019736 +1000
+++ dosbox/src/dos/dos_programs.cpp 2015-12-18 22:08:22.422102325 +1000
@@ -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);