1 /* Copyright 1994,1996-2002,2005-2007,2009 Alain Knaff.
2 * This file is part of mtools.
4 * Mtools is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Mtools is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
26 #include "sysincludes.h"
35 void mmount(int argc, char **argv, int type)
41 char name[EXPAND_BUF];
43 union bootsector boot;
46 if (argc<2 || !argv[1][0] || argv[1][1] != ':' || argv[1][2]){
47 fprintf(stderr,"Usage: %s -V drive:\n", argv[0]);
50 drive = toupper(argv[1][0]);
51 Stream= find_device(drive, O_RDONLY, &dev, &boot, name, &media, 0, NULL);
58 if ( dev.partition ) {
60 sprintf(part_name, "%d", dev.partition %1000);
61 strcat(name, part_name);
64 /* and finally mount it */
67 fprintf(stderr,"fork failed\n");
71 open("/dev/null", O_RDWR | O_BINARY | O_LARGEFILE);
72 argv[1] = strdup("mount");
74 execvp("mount", argv + 1 );
76 execlp("mount", "mount", name, NULL);
80 while ( wait(&status) != pid );
82 if ( WEXITSTATUS(status) == 0 )
84 argv[0] = strdup("mount");
85 argv[1] = strdup("-r");
86 if(!argv[0] || !argv[1]){
91 execvp("mount", argv);
93 execlp("mount", "mount","-r", name, NULL);
101 void mmount(int argc, char **argv, int type)
103 fprintf(stderr,"This command is only available for LINUX \n");