VOGONS


First post, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

http://sourceforge.net/tracker/index.php?func … 551&atid=467234

How-deee,

Simple direct letter to drive letter. change directory, dir, executing from different drive. left delete, rmdir, copy un-auto-ed.

patch -p0 < automount.diff from root dosbox directory.

For other platforms, would have to do something like Linux's automount by using a map file. In the meantime..

Attachments

  • Filename
    automount.diff
    File size
    2.59 KiB
    Downloads
    240 downloads
    File license
    Fair use/fair dealing exception
Last edited by ih8registrations on 2005-05-26, 00:57. Edited 1 time in total.

Reply 1 of 16, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

That's an interesting idea. Not sure that it's super-useful though unless you could somehow make it smart enough to automatically mount floppy and cdrom drives correctly too (a non-trivial task considering the different modes and such that are possible).

Reply 2 of 16, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

well that isn't very hard. we detect certain features about the drives ourselves as well. there a few windows call which tell you the drive type

I didn't look at the patch yet but We never implemented automounting ourselves for a reason.

maybe I can live with it if it happens only if you want to change to a non-mounted drive and asks for yes/no

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

Reply 3 of 16, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

I'd imagine the same reason why I didn't auto for delete and friends; errant or malicious batch file/exes. I've added exclusion of drive c and yet to be written is having automount only work from keyboard input. Once something is mounted though, auto or manual, are once again exposed to such a risk. For that, another safety precaution could be to add a confirmation for delete/overwrite/modify when coming from batch or exe.

Reply 5 of 16, by ykhwong

User metadata
Rank Oldbie
Rank
Oldbie

In shell_misc.cpp, remove all the lines related to the handling of execution from a different drive.
It will fix the bug. However, typing "d:\game\game.exe" without mounting D as a drive will not work (even though you have d:\game\game.exe in your real hard/floppy drive).

Last edited by ykhwong on 2006-06-04, 13:59. Edited 1 time in total.

Reply 6 of 16, by ykhwong

User metadata
Rank Oldbie
Rank
Oldbie

I modified your auto-mount patch a little bit. (and removed part of it for a bug)
This patch handles cd-rom drive, too.

1. General

Index: src/shell/shell_misc.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/shell/shell_misc.cpp,v
retrieving revision 1.38
diff -u -b -r1.38 shell_misc.cpp
--- src/shell/shell_misc.cpp 21 Apr 2005 21:17:46 -0000 1.38
+++ src/shell/shell_misc.cpp 25 May 2005 22:20:56 -0000
@@ -26,6 +26,7 @@
#include "regs.h"
#include "callback.h"
#include "support.h"
+#include "../dos/cdrom.h"

void DOS_Shell::ShowPrompt(void) {
Bit8u drive=DOS_GetDefaultDrive()+'A';
@@ -349,6 +349,36 @@
if ((strcmp(name + 1, ":") == 0) && isalpha(*name))
{
if (!DOS_SetDrive(toupper(name[0])-'A')) {
+#ifdef WIN32
+ // automount: attempt direct letter to drive map.
+ char mountstring[DOS_PATHLENGTH+CROSS_LEN+20];
+ int num = SDL_CDNumDrives();
+ char cdcount[200]={0};
+ char cdcount2[200]={0};
+ sprintf(cdcount,"");
+ for (int i=0; i<num; i++) {
+ strcat(cdcount,SDL_CDName(i));
+ strcat(cdcount," ");
+ };
+ sprintf(cdcount2,"%s",name);
+ strcat(cdcount2,"\\");
+
+ bool cdcount3 = false;
+ *cdcount2=toupper(*cdcount2);
+ char* temp = strstr(cdcount,cdcount2);
+ if(temp) cdcount3=true;
+ strcpy(mountstring,"MOUNT ");
+ strcat(mountstring,name);
+ strcat(mountstring," ");
+ if(cdcount3) {
+ strcat(mountstring,"-t cdrom");
+ strcat(mountstring," ");
+ }
+ strcat(mountstring,name);
+ strcat(mountstring,"\\");
+ this->ParseLine(mountstring);
+ if (!DOS_SetDrive(toupper(name[0])-'A'))
+#endif
WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0]));
}
return true;

2. Added -ioctl to cd-rom mount

Index: src/shell/shell_misc.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/shell/shell_misc.cpp,v
retrieving revision 1.38
diff -u -b -r1.38 shell_misc.cpp
--- src/shell/shell_misc.cpp 21 Apr 2005 21:17:46 -0000 1.38
+++ src/shell/shell_misc.cpp 25 May 2005 22:20:56 -0000
@@ -26,6 +26,7 @@
#include "regs.h"
#include "callback.h"
#include "support.h"
+#include "../dos/cdrom.h"

void DOS_Shell::ShowPrompt(void) {
Bit8u drive=DOS_GetDefaultDrive()+'A';
@@ -349,6 +349,36 @@
if ((strcmp(name + 1, ":") == 0) && isalpha(*name))
{
if (!DOS_SetDrive(toupper(name[0])-'A')) {
+#ifdef WIN32
+ // automount: attempt direct letter to drive map.
+ char mountstring[DOS_PATHLENGTH+CROSS_LEN+20];
+ // cd-rom mount
+ int num = SDL_CDNumDrives();
+ char cdcount[200]={0};
+ char cdcount2[200]={0};
+ sprintf(cdcount,"");
+ for (int i=0; i<num; i++) {
+ strcat(cdcount,SDL_CDName(i));
+ strcat(cdcount," ");
+ };
+ sprintf(cdcount2,"%s",name);
+ strcat(cdcount2,"\\");
+
+ bool cdcount3 = false;
+ *cdcount2=toupper(*cdcount2);
+ char* temp = strstr(cdcount,cdcount2);
+ if(temp) cdcount3=true;
+ strcpy(mountstring,"MOUNT ");
+ strcat(mountstring,name);
+ strcat(mountstring," ");
+ if(cdcount3) strcat(mountstring,"-t cdrom ");
+ strcat(mountstring,name);
+ strcat(mountstring,"\\");
+ if(cdcount3) strcat(mountstring," -ioctl");
+
+ this->ParseLine(mountstring);
+ if (!DOS_SetDrive(toupper(name[0])-'A'))
+#endif
WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0]));
}
return true;
Last edited by ykhwong on 2006-06-04, 18:11. Edited 2 times in total.

Reply 8 of 16, by ykhwong

User metadata
Rank Oldbie
Rank
Oldbie

This patch now handles floppy drive.
Added boolean 'automount' into configuration.

Index: src/shell/shell_misc.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/shell/shell_misc.cpp,v
retrieving revision 1.38
diff -u -b -r1.38 shell_misc.cpp
--- src/shell/shell_misc.cpp 21 Apr 2005 21:17:46 -0000 1.38
+++ src/shell/shell_misc.cpp 25 May 2005 22:20:56 -0000
@@ -26,6 +26,9 @@
#include "regs.h"
#include "callback.h"
#include "support.h"
+#ifdef WIN32
+#include "../dos/cdrom.h"
+#endif

void DOS_Shell::ShowPrompt(void) {
Bit8u drive=DOS_GetDefaultDrive()+'A';
@@ -349,6 +349,27 @@
if ((strcmp(name + 1, ":") == 0) && isalpha(*name))
{
if (!DOS_SetDrive(toupper(name[0])-'A')) {
+#ifdef WIN32
+ Section * sec = control->GetSection("dos");
+ Section_prop * section=static_cast<Section_prop *>(sec);
+ bool automount = section->Get_bool("automount");
+ if(automount)
+ {
+ // automount: attempt direct letter to drive map.
+ char mountstring[DOS_PATHLENGTH+CROSS_LEN+20];
+ sprintf(mountstring,"MOUNT %s ",name);
+ const char * drivename = name;
+ if(GetDriveType(drivename)==DRIVE_CDROM) strcat(mountstring,"-t cdrom ");
+ else if(GetDriveType(drivename)==DRIVE_REMOVABLE) strcat(mountstring,"-t floppy ");
+ strcat(mountstring,name);
+ strcat(mountstring,"\\");
+ if(GetDriveType(drivename)==DRIVE_CDROM) strcat(mountstring," -ioctl");
+
+ this->ParseLine(mountstring);
+ }
+failed:
+ if (!DOS_SetDrive(toupper(name[0])-'A'))
+#endif
WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0]));
}
return true;
--- ./src/dosbox.cpp Mon Jul 31 16:45:04 2006
+++ ./src/dosbox.cpp Mon Jul 31 16:32:26 2006
@@ -592,11 +592,17 @@
secprop->Add_string("umb","true");
secprop->AddInitFunction(&DOS_KeyboardLayout_Init,true);
secprop->Add_string("keyboardlayout", "none");
+#ifdef WIN32
+ secprop->Add_bool("automount","true");
+#endif
MSG_Add("DOS_CONFIGFILE_HELP",
"xms -- Enable XMS support.\n"
"ems -- Enable EMS support.\n"
"umb -- Enable UMB support (false,true,max).\n"
"keyboardlayout -- Language code of the keyboard layout (or none).\n"
+#ifdef WIN32
Show last 5 lines
+		"automount -- Enable automount.\n"
+#endif
);
// Mscdex
secprop->AddInitFunction(&MSCDEX_Init);

Attachments

  • Filename
    automount.diff
    File size
    2.24 KiB
    Downloads
    195 downloads
    File license
    Fair use/fair dealing exception

Reply 9 of 16, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

Uh uh - this sounds convenient, but also dangerous to me. Like the way Windows likes to autoplay my CD's/DVD's, hide file extensions, etc.

I would like to see more control of what gets auto-mounted and when.

I want something that allows me to declare auto-mounting of drive C for unsafe, but D and E and all local read-only media for safe. Give me something like

# automount - Allow DOSBox to automatically mount drives: true, false, paths
# autopaths - List of paths that are safe to automount when automount=paths.
automount=paths
autopaths=D:\ E:\ /mnt/cdrom

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 10 of 16, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Also imo it's dangerous because it removes the responsibility of the user.
And with the availability of frontends there's not much need for it anyways.

Still the general idea of avoiding mount is nice.

Reply 11 of 16, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

Maybe a more intelligent mount command is what is needed? Something that will try to detect the type of media being mounted and automagically use the correct mount type (-t), label, ioctl, cd-number, aspi, ...

It seems to me that we spend a lot of time asking newbies about how they mounted their virtual drives, and suggest adding this and that option.

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 12 of 16, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

> It seems to me that we spend a lot of time asking newbies about how
> they mounted their virtual drives, and suggest adding this and that option.

But frontends seem to be the more straightforward solution to this,
maybe their use should be forced even more at least for first time
users and newbies.

Reply 13 of 16, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

I agree. The work on frontends lately has been amazing....even tho I don't use them. 😀

How To Ask Questions The Smart Way
Make your games work offline

Reply 14 of 16, by ykhwong

User metadata
Rank Oldbie
Rank
Oldbie

The follwing idea was actually made to ask users to automount drives before as you see the screenshot.
I also agree that using frontend is the best choice to easily mount drives.
However, lots of newbies in my page have difficulties with mount drives in dosbox as Minimax mentioned. (Some of them do not try to use even frontends though I posted a thread about the introduction of recent frontends)

The current automount patch is basically planned to work only in win32 by ih8registrations, so it will not work on other platforms.

Attachments

  • iii.PNG
    Filename
    iii.PNG
    File size
    13.01 KiB
    Views
    1971 views
    File license
    Fair use/fair dealing exception
Last edited by ykhwong on 2006-11-11, 07:31. Edited 1 time in total.

Reply 15 of 16, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

ykhwong - I think the newbie that blindly tries to switch to C: and D: will be very confused when confronted with that question.

S/he will have no idea what all that mounting is about. They will start looking for a horse to mount and ride off into the sunset...

Better rephrase it and ask the newbie something like this:

Z:\>c:
Do really you want to give DOSBox access to everything on your real C: drive? Yes or no?

Z:\>d:
Do really you want to give DOSBox access to everything on your real D: drive? Yes or no?

Z:\>g:
Do you want to give DOSBox access to your real CD/DVD-ROM drive? Yes or no?

Z:\>i:
Do you want to give DOSBox access to your real CD/DVD-ROM drive? Yes or no?
Last edited by MiniMax on 2006-11-11, 15:15. Edited 1 time in total.

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 16 of 16, by ykhwong

User metadata
Rank Oldbie
Rank
Oldbie

oops.. It makes sense. Thanks for the suggestion. 😀

--- ./src/shell/shell.cpp	Sat Nov 11 06:52:04 2006
+++ ./src/shell/shell.cpp Sat Nov 11 06:54:00 2006
@@ -466,6 +466,10 @@
MSG_Add("SHELL_CMD_DIR_BYTES_USED","%5d File(s) %17s Bytes.\n");
MSG_Add("SHELL_CMD_DIR_BYTES_FREE","%5d Dir(s) %17s Bytes free.\n");
MSG_Add("SHELL_EXECUTE_DRIVE_NOT_FOUND","Drive %c does not exist!\nYou must \033[31mmount\033[0m it first. Type \033[1;33mintro\033[0m or \033[1;33mintro mount\033[0m for more information.\n");
+ MSG_Add("SHELL_EXECUTE_DRIVE_ACCESS_CDROM","Do you really want to give DOSBox access to your real CD-ROM drive %c [Y/N]?");
+ MSG_Add("SHELL_EXECUTE_DRIVE_ACCESS_FLOPPY","Do you really want to give DOSBox access to your real floppy drive %c [Y/N]?");
+ MSG_Add("SHELL_EXECUTE_DRIVE_ACCESS_FIXED","Do you really want to give DOSBox access to your real drive %c [Y/N]?");
+ MSG_Add("SHELL_EXECUTE_DRIVE_ACCESS_WARNING_WIN","Mounting c:\\ is NOT recommended.\n");
MSG_Add("SHELL_EXECUTE_ILLEGAL_COMMAND","Illegal command: %s.\n");
MSG_Add("SHELL_CMD_PAUSE","Press any key to continue.\n");
MSG_Add("SHELL_CMD_PAUSE_HELP","Waits for 1 keystroke to continue.\n");
--- src/shell/shell_misc.cpp 21 Apr 2005 21:17:46 -0000 1.38
+++ src/shell/shell_misc.cpp 25 May 2005 22:20:56 -0000
@@ -26,6 +26,9 @@
#include "regs.h"
#include "callback.h"
#include "support.h"
+#ifdef WIN32
+#include "../dos/cdrom.h"
+#endif

void DOS_Shell::ShowPrompt(void) {
Bit8u drive=DOS_GetDefaultDrive()+'A';
@@ -349,7 +349,68 @@
/* check for a drive change */
if (((strcmp(name + 1, ":") == 0) || (strcmp(name + 1, ":\\") == 0)) && isalpha(*name))
{
+ if (strrchr(name,'\\')) { WriteOut(MSG_Get("SHELL_EXECUTE_ILLEGAL_COMMAND"),name); return true; }
if (!DOS_SetDrive(toupper(name[0])-'A')) {
+#ifdef WIN32
+ // automount: attempt direct letter to drive map.
+ if((GetDriveType(name)==DRIVE_FIXED) && (strcasecmp(name,"c:")==0)) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_WARNING_WIN"));
+first_1:
+ if(GetDriveType(name)==DRIVE_CDROM) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_CDROM"),toupper(name[0]));
+ else if(GetDriveType(name)==DRIVE_REMOVABLE) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_FLOPPY"),toupper(name[0]));
+ else if(GetDriveType(name)==DRIVE_FIXED) WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_ACCESS_FIXED"),toupper(name[0]));
+ else { WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0])); return true; }
+first_2:
+ Bit8u c;Bit16u n=1;
+ DOS_ReadFile (STDIN,&c,&n);
+ do switch (c)
+ {
+ case 'n': case 'N':
+ {
+ DOS_WriteFile (STDOUT,&c, &n);
+ DOS_ReadFile (STDIN,&c,&n);
+ do switch (c) {
+ case 0xD: WriteOut("\n\n"); WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0])); return true;
+ case 0x08: WriteOut("\b \b"); goto first_2;
+ } while (DOS_ReadFile (STDIN,&c,&n));
+ }
+ case 'y': case 'Y':
+ {
+ DOS_WriteFile (STDOUT,&c, &n);
+ DOS_ReadFile (STDIN,&c,&n);
+ do switch (c) {
+ case 0xD: WriteOut("\n"); goto continue_1;
+ case 0x08: WriteOut("\b \b"); goto first_2;
Show last 34 lines
+				} while (DOS_ReadFile (STDIN,&c,&n));
+ }
+ case 0xD: WriteOut("\n"); goto first_1;
+ case '\t': case 0x08: goto first_2;
+ default:
+ {
+ DOS_WriteFile (STDOUT,&c, &n);
+ DOS_ReadFile (STDIN,&c,&n);
+ do switch (c) {
+ case 0xD: WriteOut("\n");goto first_1;
+ case 0x08: WriteOut("\b \b"); goto first_2;
+ } while (DOS_ReadFile (STDIN,&c,&n));
+ goto first_2;
+ }
+ } while (DOS_ReadFile (STDIN,&c,&n));
+
+continue_1:
+
+ char mountstring[DOS_PATHLENGTH+CROSS_LEN+20];
+ sprintf(mountstring,"MOUNT %s ",name);
+
+ if(GetDriveType(name)==DRIVE_CDROM) strcat(mountstring,"-t cdrom ");
+ else if(GetDriveType(name)==DRIVE_REMOVABLE) strcat(mountstring,"-t floppy ");
+ strcat(mountstring,name);
+ strcat(mountstring,"\\");
+ if(GetDriveType(name)==DRIVE_CDROM) strcat(mountstring," -ioctl");
+
+ this->ParseLine(mountstring);
+failed:
+ if (!DOS_SetDrive(toupper(name[0])-'A'))
+#endif
WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(name[0]));
}
return true;

Attachments

  • Filename
    automount.diff
    File size
    4.09 KiB
    Downloads
    192 downloads
    File license
    Fair use/fair dealing exception